Panda3D
 All Classes Functions Variables Enumerations
nodePointerTo.h
00001 // Filename: nodePointerTo.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 NODEPOINTERTO_H
00016 #define NODEPOINTERTO_H
00017 
00018 #include "pandabase.h"
00019 #include "nodePointerToBase.h"
00020 
00021 ////////////////////////////////////////////////////////////////////
00022 //       Class : NodePointerTo
00023 // Description : This implements the special NodePointerTo template
00024 //               class, which works just like PointerTo except it
00025 //               manages the objects node_ref_count instead of the
00026 //               normal ref_count.
00027 ////////////////////////////////////////////////////////////////////
00028 template <class T>
00029 class NodePointerTo : public NodePointerToBase<T> {
00030 public:
00031   // By hiding this template from interrogate, we improve compile-time
00032   // speed and memory utilization.
00033 #ifndef CPPPARSER
00034   typedef TYPENAME NodePointerToBase<T>::To To;
00035   INLINE NodePointerTo(To *ptr = (To *)NULL);
00036   INLINE NodePointerTo(const NodePointerTo<T> &copy);
00037   INLINE ~NodePointerTo();
00038 
00039   INLINE To &operator *() const;
00040   INLINE To *operator -> () const;
00041 
00042   // MSVC.NET 2005 insists that we use T *, and not To *, here.
00043   INLINE operator T *() const;
00044 
00045   INLINE To *p() const;
00046 
00047   INLINE NodePointerTo<T> &operator = (To *ptr);
00048   INLINE NodePointerTo<T> &operator = (const NodePointerTo<T> &copy);
00049 #endif  // CPPPARSER
00050 };
00051 
00052 
00053 ////////////////////////////////////////////////////////////////////
00054 //       Class : NodeConstPointerTo
00055 // Description : A NodeConstPointerTo is similar to a NodePointerTo,
00056 //               except it keeps a const pointer to the thing.
00057 ////////////////////////////////////////////////////////////////////
00058 template <class T>
00059 class NodeConstPointerTo : public NodePointerToBase<T> {
00060 public:
00061   // By hiding this template from interrogate, we improve compile-time
00062   // speed and memory utilization.
00063 #ifndef CPPPARSER
00064   typedef TYPENAME NodePointerToBase<T>::To To;
00065   INLINE NodeConstPointerTo(const To *ptr = (const To *)NULL);
00066   INLINE NodeConstPointerTo(const NodePointerTo<T> &copy);
00067   INLINE NodeConstPointerTo(const NodeConstPointerTo<T> &copy);
00068   INLINE ~NodeConstPointerTo();
00069 
00070   INLINE const To &operator *() const;
00071   INLINE const To *operator -> () const;
00072   INLINE operator const T *() const;
00073 
00074   INLINE const To *p() const;
00075 
00076   INLINE NodeConstPointerTo<T> &operator = (const To *ptr);
00077   INLINE NodeConstPointerTo<T> &operator = (const NodePointerTo<T> &copy);
00078   INLINE NodeConstPointerTo<T> &operator = (const NodeConstPointerTo<T> &copy);
00079 #endif  // CPPPARSER
00080 };
00081 
00082 #define NPT(type) NodePointerTo< type >
00083 #define NCPT(type) NodeConstPointerTo< type >
00084 
00085 #include "nodePointerTo.I"
00086 
00087 #endif
 All Classes Functions Variables Enumerations