Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ReferenceCountedHandle< X > Class Template Reference

#include <G4ReferenceCountedHandle.hh>

Public Member Functions

 G4ReferenceCountedHandle (X *rep=nullptr)
 
 G4ReferenceCountedHandle (const G4ReferenceCountedHandle< X > &right)
 
 ~G4ReferenceCountedHandle ()
 
G4ReferenceCountedHandle< X > & operator= (const G4ReferenceCountedHandle< X > &right)
 
G4ReferenceCountedHandle< X > & operator= (X *objPtr)
 
unsigned int Count () const
 
X * operator-> () const
 
G4bool operator! () const
 
 operator bool () const
 
X * operator() () const
 
void * operator new (std::size_t)
 
void operator delete (void *pObj)
 

Detailed Description

template<class X>
class G4ReferenceCountedHandle< X >

Definition at line 59 of file G4ReferenceCountedHandle.hh.

Constructor & Destructor Documentation

◆ G4ReferenceCountedHandle() [1/2]

template<class X >
G4ReferenceCountedHandle< X >::G4ReferenceCountedHandle ( X *  rep = nullptr)
inline

Definition at line 197 of file G4ReferenceCountedHandle.hh.

198{
199 if(rep != nullptr)
200 fObj = new G4CountedObject<X>(rep);
201}

◆ G4ReferenceCountedHandle() [2/2]

template<class X >
G4ReferenceCountedHandle< X >::G4ReferenceCountedHandle ( const G4ReferenceCountedHandle< X > &  right)
inline

Definition at line 204 of file G4ReferenceCountedHandle.hh.

206 : fObj(right.fObj)
207{
208 fObj->AddRef();
209}

◆ ~G4ReferenceCountedHandle()

template<class X >
G4ReferenceCountedHandle< X >::~G4ReferenceCountedHandle
inline

Definition at line 212 of file G4ReferenceCountedHandle.hh.

213{
214 if(fObj != nullptr)
215 fObj->Release();
216}

Member Function Documentation

◆ Count()

template<class X >
unsigned int G4ReferenceCountedHandle< X >::Count
inline

Definition at line 242 of file G4ReferenceCountedHandle.hh.

243{
244 return ((fObj != nullptr) ? fObj->fCount : 0);
245}

◆ operator bool()

template<class X >
G4ReferenceCountedHandle< X >::operator bool
inline

Definition at line 260 of file G4ReferenceCountedHandle.hh.

261{
262 return ((fObj != nullptr) ? true : false);
263}

◆ operator delete()

template<class X >
void G4ReferenceCountedHandle< X >::operator delete ( void *  pObj)
inline

Definition at line 280 of file G4ReferenceCountedHandle.hh.

281{
282 aRCHAllocator()->FreeSingle((G4ReferenceCountedHandle<void>*) pObj);
283}
G4GLOB_DLL G4Allocator< G4ReferenceCountedHandle< void > > *& aRCHAllocator()

◆ operator new()

template<class X >
void * G4ReferenceCountedHandle< X >::operator new ( std::size_t  )
inline

Definition at line 272 of file G4ReferenceCountedHandle.hh.

273{
274 if(aRCHAllocator() == nullptr)
276 return ((void*) aRCHAllocator()->MallocSingle());
277}

◆ operator!()

template<class X >
G4bool G4ReferenceCountedHandle< X >::operator!
inline

Definition at line 254 of file G4ReferenceCountedHandle.hh.

255{
256 return ((fObj == nullptr) ? true : false);
257}

◆ operator()()

template<class X >
X * G4ReferenceCountedHandle< X >::operator()
inline

Definition at line 266 of file G4ReferenceCountedHandle.hh.

267{
268 return ((fObj != nullptr) ? fObj->fRep : nullptr);
269}

◆ operator->()

template<class X >
X * G4ReferenceCountedHandle< X >::operator->
inline

Definition at line 248 of file G4ReferenceCountedHandle.hh.

249{
250 return ((fObj != nullptr) ? fObj->fRep : 0);
251}

◆ operator=() [1/2]

template<class X >
G4ReferenceCountedHandle< X > & G4ReferenceCountedHandle< X >::operator= ( const G4ReferenceCountedHandle< X > &  right)
inline

Definition at line 219 of file G4ReferenceCountedHandle.hh.

221{
222 if(fObj != right.fObj)
223 {
224 if(fObj != nullptr)
225 fObj->Release();
226 this->fObj = right.fObj;
227 fObj->AddRef();
228 }
229 return *this;
230}

◆ operator=() [2/2]

template<class X >
G4ReferenceCountedHandle< X > & G4ReferenceCountedHandle< X >::operator= ( X *  objPtr)
inline

Definition at line 233 of file G4ReferenceCountedHandle.hh.

234{
235 if(fObj != nullptr)
236 fObj->Release();
237 this->fObj = new G4CountedObject<X>(objPtr);
238 return *this;
239}

The documentation for this class was generated from the following file: