EGSnrc C++ class library  Report PIRS-898 (2021)
Iwan Kawrakow, Ernesto Mainegra-Hing, Frederic Tessier, Reid Townson and Blake Walters
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
EGS_Object Class Reference

Base egspp object. More...

#include <egs_object_factory.h>

Inheritance diagram for EGS_Object:
EGS_AusgabObject EGS_BaseShape EGS_BaseSource BEAM_DoseScoring EGS_DoseScoring EGS_FluenceScoring EGS_PhspScoring EGS_RadiativeSplitting EGS_TrackScoring EGS_BoxShape EGS_ConicalShellStackShape EGS_CylinderShape EGS_ExtendedShape EGS_GaussianShape EGS_LineShape EGS_PointShape EGS_ShapeCollection EGS_SphereShape EGS_SphericalShellShape EGS_SurfaceShape EGS_VoxelizedShape EGS_AngularSpreadSource EGS_BaseSimpleSource EGS_BeamSource EGS_DynamicSource EGS_PhspSource EGS_RadionuclideSource EGS_SourceCollection EGS_TransformedSource IAEA_PhspSource

Public Member Functions

 EGS_Object (const string &Name="", EGS_ObjectFactory *f=0)
 Create an EGS_Object named Name belonging to the object factory f. More...
 
 EGS_Object (EGS_Input *inp, EGS_ObjectFactory *f=0)
 Create an EGS_Object from the information pointed to by inp that belongs to object factory f. More...
 
const string & getObjectName () const
 Get the object name.
 
void setObjectName (const string &Name)
 Set the object name to Name.
 
const string & getObjectType () const
 Get the object type.
 
virtual EGS_ObjectcreateObject (EGS_Input *inp)
 Create an object from the infromation pointed to by inp. More...
 
void setName (EGS_Input *inp)
 Set the name of the object from the information provided by inp. More...
 
int ref ()
 Increase the reference count to this object.
 
int deref ()
 Decrease the reference count to this object.
 
void setFactory (EGS_ObjectFactory *f)
 Set the factory to which the object belongs. More...
 

Static Public Member Functions

static string getUniqueName (const EGS_Object *o=0)
 Create and return a unique object name. More...
 
static void deleteObject (EGS_Object *o)
 Delete an object. More...
 

Protected Attributes

string name
 The object name.
 
string otype
 The object type.
 
int nref
 Number of references to the object.
 
EGS_ObjectFactoryfactory
 The factory this object belongs to.
 

Detailed Description

Base egspp object.

The purpose of the EGS_Object class, together with the EGS_ObjectFactory class, is to provide the main functionality related to dynamically producing objects based on user input by loading the specified shared library and calling the object creation function provided by the library. This functionality is needed by particle sources, shapes and geometries. Whereas particle sources and shapes are derived from the EGS_Object class, geometries are not. This is due to the fact that geometries were implemented first, before the plan emerged to develop a more complete class library for the EGSnrc system. This inconsistency may be removed in future versions of the egspp package.

EGS_Object objects have a name that can be obtained or set using getObjectName() or setObjectName() and a type that is obtained with getObjectType(). They can set their name from the information provided by an EGS_Input object and they also can create instances of their respective class based on such information with the createObject() function. EGS_Object instances can be safely shared between several objects by increasing and decreasing the reference count to the EGS_Object instance using ref() and deref(). Lists of EGS_Object objects are typically maintained by object factories .

Definition at line 81 of file egs_object_factory.h.

Constructor & Destructor Documentation

EGS_Object::EGS_Object ( const string &  Name = "",
EGS_ObjectFactory f = 0 
)

Create an EGS_Object named Name belonging to the object factory f.

The object type is set to "EGS_Object" and the reference count is initialized to zero. If Name is empty, the object name is det to a unique name obtained from getUniqueName().

Definition at line 47 of file egs_object_factory.cpp.

References getUniqueName(), and name.

EGS_Object::EGS_Object ( EGS_Input inp,
EGS_ObjectFactory f = 0 
)

Create an EGS_Object from the information pointed to by inp that belongs to object factory f.

The only difference to the previous constructor is that now the object name is set using setName().

Definition at line 56 of file egs_object_factory.cpp.

References setName().

Member Function Documentation

virtual EGS_Object* EGS_Object::createObject ( EGS_Input inp)
virtual

Create an object from the infromation pointed to by inp.

This virtual function must be re-implemented in derived classes to create an instance of the respective class from the information provided by inp, if this information is valid and sufficient, and to return a pointer to it. Otherwise the return value should be null (which is the default implementation)

Reimplemented in EGS_CylinderShape, EGS_SphereShape, EGS_BoxShape, and EGS_PointShape.

Definition at line 126 of file egs_object_factory.h.

string EGS_Object::getUniqueName ( const EGS_Object o = 0)
static

Create and return a unique object name.

If o is not null, the resulting name will be "%s_%d" where the s is filled with o->getObjectType() and d with the number of objects created so far. If o is null, the resulting name will be "object_%d", with d again filled with the number of objects created so far.

Definition at line 81 of file egs_object_factory.cpp.

References getObjectType().

Referenced by EGS_Object(), and setName().

void EGS_Object::setName ( EGS_Input inp)

Set the name of the object from the information provided by inp.

If inp has a name key, the name is set to the value of this key. Otherwise the name is set using getUniqueName().

Definition at line 93 of file egs_object_factory.cpp.

References EGS_Input::getInput(), getUniqueName(), and name.

Referenced by EGS_PointShape::createObject(), EGS_BoxShape::createObject(), EGS_SphereShape::createObject(), EGS_CylinderShape::createObject(), and EGS_Object().

void EGS_Object::setFactory ( EGS_ObjectFactory f)

Set the factory to which the object belongs.

If the object already belongs to a different factory, it is first removed from this factory and then added to f.

Definition at line 71 of file egs_object_factory.cpp.

References EGS_ObjectFactory::addObject(), factory, and EGS_ObjectFactory::removeObject().

Referenced by EGS_ObjectFactory::addObject().

static void EGS_Object::deleteObject ( EGS_Object o)
static

Delete an object.

This function decreases the reference count of the object and deletes it, if the reference count is zero.

Definition at line 168 of file egs_object_factory.h.

References deref().

Referenced by EGS_ObjectFactory::createSingleObject(), EGS_Application::~EGS_Application(), and EGS_ObjectFactory::~EGS_ObjectFactory().


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