open_toontown_panda3d/panda/src/express/nodePointerTo.h

92 lines
3.1 KiB
C++

// Filename: nodePointerTo.h
// Created by: drose (07May05)
//
////////////////////////////////////////////////////////////////////
//
// PANDA 3D SOFTWARE
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
//
// All use of this software is subject to the terms of the Panda 3d
// Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
//
// To contact the maintainers of this program write to
// panda3d-general@lists.sourceforge.net .
//
////////////////////////////////////////////////////////////////////
#ifndef NODEPOINTERTO_H
#define NODEPOINTERTO_H
#include "pandabase.h"
#include "nodePointerToBase.h"
////////////////////////////////////////////////////////////////////
// Class : NodePointerTo
// Description : This implements the special NodePointerTo template
// class, which works just like PointerTo except it
// manages the objects node_ref_count instead of the
// normal ref_count.
////////////////////////////////////////////////////////////////////
template <class T>
class NodePointerTo : public NodePointerToBase<T> {
public:
// By hiding this template from interrogate, we improve compile-time
// speed and memory utilization.
#ifndef CPPPARSER
typedef TYPENAME NodePointerToBase<T>::To To;
INLINE NodePointerTo(To *ptr = (To *)NULL);
INLINE NodePointerTo(const NodePointerTo<T> &copy);
INLINE ~NodePointerTo();
INLINE To &operator *() const;
INLINE To *operator -> () const;
// MSVC.NET 2005 insists that we use T *, and not To *, here.
INLINE operator T *() const;
INLINE To *p() const;
INLINE NodePointerTo<T> &operator = (To *ptr);
INLINE NodePointerTo<T> &operator = (const NodePointerTo<T> &copy);
#endif // CPPPARSER
};
////////////////////////////////////////////////////////////////////
// Class : NodeConstPointerTo
// Description : A NodeConstPointerTo is similar to a NodePointerTo,
// except it keeps a const pointer to the thing.
////////////////////////////////////////////////////////////////////
template <class T>
class NodeConstPointerTo : public NodePointerToBase<T> {
public:
// By hiding this template from interrogate, we improve compile-time
// speed and memory utilization.
#ifndef CPPPARSER
typedef TYPENAME NodePointerToBase<T>::To To;
INLINE NodeConstPointerTo(const To *ptr = (const To *)NULL);
INLINE NodeConstPointerTo(const NodePointerTo<T> &copy);
INLINE NodeConstPointerTo(const NodeConstPointerTo<T> &copy);
INLINE ~NodeConstPointerTo();
INLINE const To &operator *() const;
INLINE const To *operator -> () const;
INLINE operator const T *() const;
INLINE const To *p() const;
INLINE NodeConstPointerTo<T> &operator = (const To *ptr);
INLINE NodeConstPointerTo<T> &operator = (const NodePointerTo<T> &copy);
INLINE NodeConstPointerTo<T> &operator = (const NodeConstPointerTo<T> &copy);
#endif // CPPPARSER
};
#define NPT(type) NodePointerTo< type >
#define NCPT(type) NodeConstPointerTo< type >
#include "nodePointerTo.I"
#endif