GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GModelSpectralRegistry Class Reference

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

#include <GModelSpectralRegistry.hpp>

Inheritance diagram for GModelSpectralRegistry:
GRegistry

Public Member Functions

 GModelSpectralRegistry (void)
 Void constructor. More...
 
 GModelSpectralRegistry (const GModelSpectral *model)
 Model constructor. More...
 
 GModelSpectralRegistry (const GModelSpectralRegistry &registry)
 Copy constructor. More...
 
virtual ~GModelSpectralRegistry (void)
 Destructor. More...
 
GModelSpectralRegistryoperator= (const GModelSpectralRegistry &registry)
 Assignment operator. More...
 
std::string classname (void) const
 Return class name. More...
 
int size (void) const
 Return number of registered models. More...
 
GModelSpectralalloc (const GXmlElement &xml) const
 Allocate spectral 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 GModelSpectralRegistry &registry)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 

Static Private Member Functions

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

Detailed Description

Interface definition for the spectral model registry class.

The registry class allows the registration of spectral 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 spectral models that are available throughout all linked libraries. To register a spectral model it is sufficient to add

const GModelSpectralXXX      g_spectral_XXX_seed;
const GModelSpectralRegistry g_spectral_XXX_registry(&g_spectral_XXX_seed);

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

Definition at line 56 of file GModelSpectralRegistry.hpp.

Constructor & Destructor Documentation

GModelSpectralRegistry::GModelSpectralRegistry ( void  )

Void constructor.

Definition at line 58 of file GModelSpectralRegistry.cpp.

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

GModelSpectralRegistry::GModelSpectralRegistry ( const GModelSpectral 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 GModelSpectralRegistry.cpp.

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

GModelSpectralRegistry::GModelSpectralRegistry ( const GModelSpectralRegistry registry)

Copy constructor.

Parameters
[in]registryRegistry.

Definition at line 132 of file GModelSpectralRegistry.cpp.

References copy_members(), and init_members().

GModelSpectralRegistry::~GModelSpectralRegistry ( void  )
virtual

Destructor.

Definition at line 148 of file GModelSpectralRegistry.cpp.

References free_members().

Member Function Documentation

GModelSpectral * GModelSpectralRegistry::alloc ( const GXmlElement xml) const

Allocate spectral model that is found in XML element.

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

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

Definition at line 210 of file GModelSpectralRegistry.cpp.

References GXmlElement::attribute(), G_ALLOC, models(), name(), GModelSpectral::read(), size(), and gammalib::xml_has_par().

Referenced by GCTAModelSpatialGaussSpectrum::read(), GModelSpectralComposite::read(), GModelSpectralMultiplicative::read(), GModelSpectralExponential::read(), GCTAModelIrfBackground::xml_spectral(), GCTAModelAeffBackground::xml_spectral(), GCTAModelCubeBackground::xml_spectral(), GCTAModelRadialAcceptance::xml_spectral(), GCTAModelBackground::xml_spectral(), GCTAModelSkyCube::xml_spectral(), and GModelSky::xml_spectral().

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

Return class name.

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

Implements GRegistry.

Definition at line 105 of file GModelSpectralRegistry.hpp.

void GModelSpectralRegistry::copy_members ( const GModelSpectralRegistry registry)
protected

Copy class members.

Parameters
[in]registryRegistry.

Definition at line 375 of file GModelSpectralRegistry.cpp.

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

void GModelSpectralRegistry::free_members ( void  )
protected

Delete class members.

Definition at line 385 of file GModelSpectralRegistry.cpp.

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

void GModelSpectralRegistry::init_members ( void  )
protected

Initialise class members.

Definition at line 363 of file GModelSpectralRegistry.cpp.

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

static GRegistryPointer<const GModelSpectral*>& GModelSpectralRegistry::models ( )
inlinestaticprivate

Definition at line 92 of file GModelSpectralRegistry.hpp.

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

std::string GModelSpectralRegistry::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 298 of file GModelSpectralRegistry.cpp.

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

Referenced by alloc(), and print().

static int& GModelSpectralRegistry::number ( void  )
inlinestaticprivate

Definition at line 87 of file GModelSpectralRegistry.hpp.

Referenced by GModelSpectralRegistry(), and size().

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

Assignment operator.

Parameters
[in]registryRegistry.
Returns
Reference to registry.

Definition at line 170 of file GModelSpectralRegistry.cpp.

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

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

Print registry information.

Parameters
[in]chatterChattiness.
Returns
Registry content.

Implements GRegistry.

Definition at line 319 of file GModelSpectralRegistry.cpp.

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

int GModelSpectralRegistry::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 GModelSpectralRegistry.hpp.

References number().

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


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