00001 00006 /*----------------------------------------------------------------------------*/ 00007 /* C Tool Box: Designed and implemented by: */ 00008 /* Walter F.J. Mueller Gesellschaft fuer Schwerionenforschung (GSI) */ 00009 /* Planckstrasse 1, D-64291 Darmstadt, Germany */ 00010 /* Email: W.F.J.Mueller@gsi.de */ 00011 /* WWW: http://www-kp3.gsi.de/www/kp3/people/mueller.html */ 00012 /*------------------------------------------+---------------------------------*/ 00043 //------------------------------------------+----------------------------------- 00045 00046 template <class T> 00047 inline CTBownedObjPtr<T>::CTBownedObjPtr() 00048 : mp(0) 00049 {} 00050 00051 //------------------------------------------+----------------------------------- 00053 00058 template <class T> 00059 inline CTBownedObjPtr<T>::CTBownedObjPtr(CTBownedObjPtr<T>& rhs) 00060 : mp(rhs.mp) 00061 { 00062 rhs.mp = 0; 00063 } 00064 00065 //------------------------------------------+----------------------------------- 00067 00071 template <class T> 00072 inline CTBownedObjPtr<T>::CTBownedObjPtr(T* p) 00073 : mp(p) 00074 {} 00075 00076 //------------------------------------------+----------------------------------- 00078 00082 template <class T> 00083 inline CTBownedObjPtr<T>::~CTBownedObjPtr() 00084 { 00085 delete mp; 00086 } 00087 00088 //------------------------------------------+----------------------------------- 00090 00095 template <class T> 00096 inline T* CTBownedObjPtr<T>::Release() 00097 { 00098 T* p = mp; 00099 mp = 0; 00100 return p; 00101 } 00102 00103 //------------------------------------------+----------------------------------- 00105 00106 template <class T> 00107 inline bool CTBownedObjPtr<T>::Equal(const CTBownedObjPtr<T>& rhs) const 00108 { 00109 return mp == rhs.mp; 00110 } 00111 00112 //------------------------------------------+----------------------------------- 00114 00115 template <class T> 00116 inline void CTBownedObjPtr<T>::ToStream(ostream& os) const 00117 { 00118 os << (void*) mp; 00119 return; 00120 } 00121 00122 //------------------------------------------+----------------------------------- 00124 00129 template <class T> 00130 inline CTBownedObjPtr<T>& CTBownedObjPtr<T>::operator=(CTBownedObjPtr<T>& rhs) 00131 { 00132 if (&rhs != this) { 00133 delete mp; 00134 mp = rhs.mp; 00135 rhs.mp = 0; 00136 } 00137 return *this; 00138 } 00139 00140 //------------------------------------------+----------------------------------- 00142 00143 template <class T> 00144 inline CTBownedObjPtr<T>& CTBownedObjPtr<T>::operator=(T* rhs) 00145 { 00146 delete mp; 00147 mp = p; 00148 return *this; 00149 } 00150 00151 //------------------------------------------+----------------------------------- 00153 00154 template <class T> 00155 inline T& CTBownedObjPtr<T>::operator*() const 00156 { 00157 return *mp; 00158 } 00159 00160 //------------------------------------------+----------------------------------- 00162 00163 template <class T> 00164 inline T* CTBownedObjPtr<T>::operator->() const 00165 { 00166 return mp; 00167 } 00168 //------------------------------------------+----------------------------------- 00170 00171 template <class T> 00172 inline bool CTBownedObjPtr<T>::operator!() const 00173 { 00174 return !mp; 00175 } 00176 00177 //------------------------------------------+----------------------------------- 00179 00180 template <class T> 00181 inline CTBownedObjPtr<T>::operator void* () const 00182 { 00183 return (void*) mp; 00184 } 00185 00186 //------------------------------------------+----------------------------------- 00197 template <class T> 00198 inline bool operator==(const CTBownedObjPtr<T>& lhs, 00199 const CTBownedObjPtr<T>& rhs) 00200 { 00201 return lhs.Equal(rhs); 00202 } 00203 00204 //------------------------------------------+----------------------------------- 00210 template <class T> 00211 inline ostream& operator<<(ostream& os, const CTBownedObjPtr<T>& obj) 00212 { 00213 obj.ToStream(os); 00214 return os; 00215 } 00216