Panda3D
|
00001 // Filename: pointerToVoid.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 POINTERTOVOID_H 00016 #define POINTERTOVOID_H 00017 00018 #include "pandabase.h" 00019 #include "pnotify.h" 00020 #include "memoryBase.h" 00021 #include "atomicAdjust.h" 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Class : PointerToVoid 00025 // Description : This is the non-template part of the base class for 00026 // PointerTo and ConstPointerTo. It is necessary so we 00027 // can keep a pointer to a non-template class within the 00028 // ReferenceCount object, to implement weak reference 00029 // pointers--we need to have something to clean up when 00030 // the ReferenceCount object destructs. 00031 // 00032 // This is the base class for PointerToBase<T>. 00033 //////////////////////////////////////////////////////////////////// 00034 class EXPCL_PANDAEXPRESS PointerToVoid : public MemoryBase { 00035 protected: 00036 INLINE PointerToVoid(); 00037 INLINE ~PointerToVoid(); 00038 00039 private: 00040 INLINE PointerToVoid(const PointerToVoid ©); 00041 00042 PUBLISHED: 00043 INLINE bool is_null() const; 00044 INLINE size_t get_hash() const; 00045 00046 public: 00047 // These comparison functions are common to all things PointerTo, so 00048 // they're defined up here. 00049 INLINE bool operator < (const void *other) const; 00050 INLINE bool operator < (const PointerToVoid &other) const; 00051 00052 INLINE bool operator == (const PointerToVoid &other) const; 00053 INLINE bool operator != (const PointerToVoid &other) const; 00054 00055 protected: 00056 // Within the PointerToVoid class, we only store a void pointer. 00057 // This is actually the (To *) pointer that is typecast to (void *) 00058 // from the derived template classes. 00059 00060 // It is tempting to try to store a (ReferenceCount *) pointer here, 00061 // but this is not useful because it prohibits defining, say, 00062 // PT(PandaNode), or a PointerTo any class that inherits virtually 00063 // from ReferenceCount. (You can't downcast past a virtual 00064 // inheritance level, but you can always cross-cast from a void 00065 // pointer.) 00066 AtomicAdjust::Pointer _void_ptr; 00067 }; 00068 00069 #include "pointerToVoid.I" 00070 00071 #endif