00001 // Filename: nodePointerToBase.h 00002 // Created by: drose (07May05) 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 NODEPOINTERTOBASE_H 00016 #define NODEPOINTERTOBASE_H 00017 00018 #include "pandabase.h" 00019 #include "pointerToVoid.h" 00020 #include "memoryUsage.h" 00021 #include "config_express.h" 00022 00023 //////////////////////////////////////////////////////////////////// 00024 // Class : NodePointerToBase 00025 // Description : This is similar to PointerToBase, but it manages 00026 // objects of type NodeReferenceCount or 00027 // NodeCachedReferenceCount, and it updates the 00028 // node_ref_count instead of the regular ref_count. It 00029 // is intended for use only in PandaNode, to hold a 00030 // pointer to RenderState and TransformState, although 00031 // it could be used by any object that wanted to 00032 // maintain a separate reference count for reporting 00033 // purposes. 00034 //////////////////////////////////////////////////////////////////// 00035 template <class T> 00036 class NodePointerToBase : public PointerToVoid { 00037 public: 00038 typedef T To; 00039 00040 protected: 00041 INLINE NodePointerToBase(To *ptr); 00042 INLINE NodePointerToBase(const NodePointerToBase<T> ©); 00043 INLINE ~NodePointerToBase(); 00044 00045 void reassign(To *ptr); 00046 INLINE void reassign(const NodePointerToBase<To> ©); 00047 00048 // No assignment or retrieval functions are declared in 00049 // NodePointerToBase, because we will have to specialize on const 00050 // vs. non-const later. 00051 00052 PUBLISHED: 00053 INLINE void clear(); 00054 00055 void output(ostream &out) const; 00056 }; 00057 00058 template<class T> 00059 INLINE ostream &operator <<(ostream &out, const NodePointerToBase<T> &pointer) { 00060 pointer.output(out); 00061 return out; 00062 } 00063 00064 #include "nodePointerToBase.I" 00065 00066 #endif