CMS 3D CMS Logo

Ptr< T > Class Template Reference

#include <DetectorDescription/Base/interface/Ptr.h>

List of all members.

Public Member Functions

void make_unique ()
T & operator * () const
 operator bool () const
T * operator-> () const
bool operator< (const Ptr< T > P) const
Ptroperator= (const Ptr &)
bool operator== (const Ptr< T > P) const
 Ptr (const Ptr &h)
 Ptr (T *t)
 Ptr ()
 ~Ptr ()

Private Attributes

T * p
std::size_t * refptr


Detailed Description

template<class T>
class Ptr< T >

Definition at line 9 of file Ptr.h.


Constructor & Destructor Documentation

template<class T>
Ptr< T >::Ptr (  )  [inline]

Definition at line 21 of file Ptr.h.

00021 : p(0), refptr(new size_t(1))  { }

template<class T>
Ptr< T >::Ptr ( T *  t  )  [inline]

Definition at line 22 of file Ptr.h.

00022 : p(t), refptr(new size_t(1)) { }

template<class T>
Ptr< T >::Ptr ( const Ptr< T > &  h  )  [inline]

Definition at line 23 of file Ptr.h.

00023 : p(h.p), refptr(h.refptr)  { ++*refptr; }

template<class T>
Ptr< T >::~Ptr (  )  [inline]

Definition at line 72 of file Ptr.h.

References Ptr< T >::refptr.

00073 {
00074         if (--*refptr == 0) {
00075                 delete refptr;
00076 /*
00077                 if (p)
00078                   std::cout << "DC:\t\tPtr deleted: " << std::endl;
00079                 else
00080                   std::cout << "DC: \t\tPtr deleted: dangling" << std::endl;  
00081                 delete p;
00082 */              
00083         }
00084 }


Member Function Documentation

template<class T>
void Ptr< T >::make_unique (  )  [inline]

Definition at line 12 of file Ptr.h.

00012                            {
00013                 if (*refptr != 1) {
00014                         --*refptr;
00015                         refptr = new size_t(1);
00016                         p = p? clone(p): 0;
00017                 }
00018         }

template<class T>
T & Ptr< T >::operator * ( void   )  const [inline]

Definition at line 50 of file Ptr.h.

References Ptr< T >::p.

00050 { if (p) return *p; throw std::runtime_error("unbound Ptr"); }

template<class T>
Ptr< T >::operator bool (  )  const [inline]

Definition at line 27 of file Ptr.h.

00027 { return p; }

template<class T>
T * Ptr< T >::operator-> (  )  const [inline]

Definition at line 53 of file Ptr.h.

References Ptr< T >::p.

00053 { if (p) return p; throw std::runtime_error("unbound Ptr"); }

template<class T>
bool Ptr< T >::operator< ( const Ptr< T >  P  )  const [inline]

Definition at line 35 of file Ptr.h.

00035 { return p<P.p; }

template<class T>
Ptr< T > & Ptr< T >::operator= ( const Ptr< T > &  rhs  )  [inline]

Definition at line 57 of file Ptr.h.

References Ptr< T >::p, and Ptr< T >::refptr.

00058 {
00059         ++*rhs.refptr;
00060         // free the lhs, destroying pointers if appropriate
00061         if (--*refptr == 0) {
00062                 delete refptr;
00063                 delete p;
00064         }
00065 
00066         // copy in values from the right-hand side
00067         refptr = rhs.refptr;
00068         p = rhs.p;
00069         return *this;
00070 }

template<class T>
bool Ptr< T >::operator== ( const Ptr< T >  P  )  const [inline]

Definition at line 32 of file Ptr.h.

00032 { return p==P.p; }


Member Data Documentation

template<class T>
T* Ptr< T >::p [private]

Definition at line 38 of file Ptr.h.

Referenced by Ptr< DDCompactViewImpl >::make_unique(), Ptr< T >::operator *(), Ptr< DDCompactViewImpl >::operator bool(), Ptr< T >::operator->(), Ptr< DDCompactViewImpl >::operator<(), Ptr< T >::operator=(), and Ptr< DDCompactViewImpl >::operator==().

template<class T>
std::size_t* Ptr< T >::refptr [private]

Definition at line 39 of file Ptr.h.

Referenced by Ptr< DDCompactViewImpl >::make_unique(), Ptr< T >::operator=(), Ptr< DDCompactViewImpl >::Ptr(), and Ptr< T >::~Ptr().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:30:23 2009 for CMSSW by  doxygen 1.5.4