00001 // Filename: weakReferenceList.h 00002 // Created by: drose (27Sep04) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef WEAKREFERENCELIST_H 00016 #define WEAKREFERENCELIST_H 00017 00018 #include "pandabase.h" 00019 #include "pset.h" 00020 #include "mutexImpl.h" 00021 00022 class WeakPointerToVoid; 00023 00024 //////////////////////////////////////////////////////////////////// 00025 // Class : WeakReferenceList 00026 // Description : This is a list of WeakPointerTo's that share a 00027 // reference to a given ReferenceCount object. It is 00028 // stored in a separate class since it is assumed that 00029 // most ReferenceCount objects do not need to store this 00030 // list at all; this avoids bloating every 00031 // ReferenceCount object in the world with the size of 00032 // this object. 00033 //////////////////////////////////////////////////////////////////// 00034 class EXPCL_PANDAEXPRESS WeakReferenceList { 00035 public: 00036 WeakReferenceList(); 00037 ~WeakReferenceList(); 00038 00039 void add_reference(WeakPointerToVoid *ptv); 00040 void clear_reference(WeakPointerToVoid *ptv); 00041 00042 private: 00043 typedef pset<WeakPointerToVoid *> Pointers; 00044 Pointers _pointers; 00045 MutexImpl _lock; 00046 }; 00047 00048 #include "weakReferenceList.I" 00049 00050 #endif