GammaLib  2.1.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAModelSpatialRegistry Class Reference

Interface definition for the spatial model registry class. More...

#include <GCTAModelSpatialRegistry.hpp>

Inheritance diagram for GCTAModelSpatialRegistry:
GRegistry

Public Member Functions

 GCTAModelSpatialRegistry (void)
 Void constructor. More...
 
 GCTAModelSpatialRegistry (const GCTAModelSpatial *model)
 Model constructor. More...
 
 GCTAModelSpatialRegistry (const GCTAModelSpatialRegistry &registry)
 Copy constructor. More...
 
virtual ~GCTAModelSpatialRegistry (void)
 Destructor. More...
 
GCTAModelSpatialRegistryoperator= (const GCTAModelSpatialRegistry &registry)
 Assignment operator. More...
 
std::string classname (void) const
 Return class name. More...
 
int size (void) const
 Return number of registered models. More...
 
GCTAModelSpatialalloc (const GXmlElement &xml) const
 Allocate spatial model that is found in XML element. More...
 
std::string name (const int &index) const
 Returns model name. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print registry information. More...
 
- Public Member Functions inherited from GRegistry
virtual ~GRegistry (void)
 Destructor. More...
 
std::string content (void) const
 Return list of names in registry. More...
 

Protected Member Functions

void init_members (void)
 Initialise class members. More...
 
void copy_members (const GCTAModelSpatialRegistry &registry)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 

Static Private Member Functions

static int & number ()
 
static GRegistryPointer< const
GCTAModelSpatial * > & 
models ()
 

Detailed Description

Interface definition for the spatial model registry class.

The registry class allows the registration of spatial models that are not necessarily compiled into the GammaLib. It uses the static members m_number and m_models which are allocated globally to keep track of spatial models that are available throughout all linked libraries. To register a spatial model it is sufficient to add

const GCTAModelSpatialXXX      g_spatial_XXX_seed;
const GCTAModelSpatialRegistry g_spatial_XXX_registry(&g_spatial_XXX_seed);

at the top of the .cpp file of the spatial model. Here, XXX is a unique name that describes the model.

Definition at line 56 of file GCTAModelSpatialRegistry.hpp.

Constructor & Destructor Documentation

GCTAModelSpatialRegistry::GCTAModelSpatialRegistry ( void  )

Void constructor.

Definition at line 58 of file GCTAModelSpatialRegistry.cpp.

References init_members(), models(), and size().

GCTAModelSpatialRegistry::GCTAModelSpatialRegistry ( const GCTAModelSpatial model)

Model constructor.

Parameters
[in]modelModel.

Construct registry by adding a model to the registry. This is the standard constructor that is used to register a new model to GammaLib.

Definition at line 85 of file GCTAModelSpatialRegistry.cpp.

References init_members(), models(), number(), size(), and GCTAModelSpatial::type().

GCTAModelSpatialRegistry::GCTAModelSpatialRegistry ( const GCTAModelSpatialRegistry registry)

Copy constructor.

Parameters
[in]registryRegistry.

Definition at line 132 of file GCTAModelSpatialRegistry.cpp.

References copy_members(), and init_members().

GCTAModelSpatialRegistry::~GCTAModelSpatialRegistry ( void  )
virtual

Destructor.

Definition at line 148 of file GCTAModelSpatialRegistry.cpp.

References free_members().

Member Function Documentation

GCTAModelSpatial * GCTAModelSpatialRegistry::alloc ( const GXmlElement xml) const

Allocate spatial model that is found in XML element.

Parameters
[in]xmlXML element.
Returns
Pointer to spatial model.
Exceptions
GException::invalid_valueNo appropriate spatial model found in XML element.

Returns a pointer to a spatial model instance that corresponds to the type found in an XML element. If no appropriate model is found the method will throw an exception.

Definition at line 210 of file GCTAModelSpatialRegistry.cpp.

References GXmlElement::attribute(), G_ALLOC, models(), GCTAModelSpatial::read(), and size().

Referenced by GCTAModelSpatialMultiplicative::read(), and GCTAModelBackground::xml_spatial().

std::string GCTAModelSpatialRegistry::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GCTAModelSpatialRegistry").

Implements GRegistry.

Definition at line 105 of file GCTAModelSpatialRegistry.hpp.

void GCTAModelSpatialRegistry::copy_members ( const GCTAModelSpatialRegistry registry)
protected

Copy class members.

Parameters
[in]registryRegistry.

Definition at line 330 of file GCTAModelSpatialRegistry.cpp.

Referenced by GCTAModelSpatialRegistry(), and operator=().

void GCTAModelSpatialRegistry::free_members ( void  )
protected

Delete class members.

Definition at line 340 of file GCTAModelSpatialRegistry.cpp.

Referenced by operator=(), and ~GCTAModelSpatialRegistry().

void GCTAModelSpatialRegistry::init_members ( void  )
protected

Initialise class members.

Definition at line 318 of file GCTAModelSpatialRegistry.cpp.

Referenced by GCTAModelSpatialRegistry(), and operator=().

static GRegistryPointer<const GCTAModelSpatial*>& GCTAModelSpatialRegistry::models ( void  )
inlinestaticprivate

Definition at line 92 of file GCTAModelSpatialRegistry.hpp.

Referenced by alloc(), GCTAModelSpatialRegistry(), name(), and print().

std::string GCTAModelSpatialRegistry::name ( const int &  index) const
virtual

Returns model name.

Parameters
[in]indexModel index [0,...,size()-1].
Returns
Model name.
Exceptions
GException::out_of_rangeModel index is out of range.

Implements GRegistry.

Definition at line 252 of file GCTAModelSpatialRegistry.cpp.

References G_NAME, models(), and size().

Referenced by print().

static int& GCTAModelSpatialRegistry::number ( void  )
inlinestaticprivate

Definition at line 87 of file GCTAModelSpatialRegistry.hpp.

Referenced by GCTAModelSpatialRegistry(), and size().

GCTAModelSpatialRegistry & GCTAModelSpatialRegistry::operator= ( const GCTAModelSpatialRegistry registry)

Assignment operator.

Parameters
[in]registryRegistry.
Returns
Reference to registry.

Definition at line 170 of file GCTAModelSpatialRegistry.cpp.

References copy_members(), free_members(), and init_members().

std::string GCTAModelSpatialRegistry::print ( const GChatter chatter = NORMAL) const
virtual

Print registry information.

Parameters
[in]chatterChattiness (defaults to NORMAL).
Returns
Registry content.

Implements GRegistry.

Definition at line 273 of file GCTAModelSpatialRegistry.cpp.

References models(), name(), NORMAL, gammalib::parformat(), SILENT, size(), and gammalib::str().

int GCTAModelSpatialRegistry::size ( void  ) const
inlinevirtual

Return number of registered models.

Returns
Number of registered models.

Returns the number of registered model.

Implements GRegistry.

Definition at line 119 of file GCTAModelSpatialRegistry.hpp.

References number().

Referenced by alloc(), GCTAModelSpatialRegistry(), name(), and print().


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