Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Euclid::Configuration::Configuration Class Reference

Superclass of all configuration classes. More...

#include <Configuration.h>

Inheritance diagram for Euclid::Configuration::Configuration:
Inheritance graph
[legend]
Collaboration diagram for Euclid::Configuration::Configuration:
Collaboration graph
[legend]

Public Types

enum class  State { CONSTRUCTED , PRE_INITIALIZED , INITIALIZED , FINAL }
 Defines the different states the configuration object can be in. More...
 
using OptionDescriptionList = std::vector< boost::program_options::option_description >
 
using UserValues = std::map< std::string, boost::program_options::variable_value >
 

Public Member Functions

 Configuration (long manager_id)
 Constructs a new Configuration instance.
 
virtual ~Configuration ()=default
 Destructor.
 
virtual std::map< std::string, OptionDescriptionListgetProgramOptions ()
 Returns the program options defined by a specific configuration.
 
virtual void preInitialize (const UserValues &args)
 Method which is called before the initialization phase.
 
virtual void initialize (const UserValues &args)
 Method which is called during the initialization phase.
 
virtual void postInitialize (const UserValues &args)
 Method which is called after the initialization phase.
 
const std::set< std::type_index > & getDependencies ()
 Returns the dependencies of the configuration.
 
StategetCurrentState ()
 Returns the current state of the configuration.
 
State getCurrentState () const
 Returns the current state of the configuration.
 

Protected Member Functions

template<typename T >
void declareDependency ()
 Declares a Configuration as dependency.
 
template<typename T >
T & getDependency ()
 Returns a dependency.
 
template<typename T >
const T & getDependency () const
 

Private Attributes

long m_manager_id
 
std::set< std::type_indexm_dependencies
 
State m_state = State::CONSTRUCTED
 

Detailed Description

Superclass of all configuration classes.

For details of how to implement specific configuration implementations see the documentation of the virtual methods.

Definition at line 48 of file Configuration.h.

Member Typedef Documentation

◆ OptionDescriptionList

using Euclid::Configuration::Configuration::OptionDescriptionList = std::vector<boost::program_options::option_description>

Definition at line 63 of file Configuration.h.

◆ UserValues

using Euclid::Configuration::Configuration::UserValues = std::map<std::string, boost::program_options::variable_value>

Definition at line 64 of file Configuration.h.

Member Enumeration Documentation

◆ State

Defines the different states the configuration object can be in.

Enumerator
CONSTRUCTED 

The object has just been constructed.

PRE_INITIALIZED 

The preInitialize() method has been called and waits for initialization.

INITIALIZED 

The initialize() method has been called.

FINAL 

The postInitialize() method has been called.

Definition at line 52 of file Configuration.h.

Constructor & Destructor Documentation

◆ Configuration()

Euclid::Configuration::Configuration::Configuration ( long  manager_id)
explicit

Constructs a new Configuration instance.

Definition at line 27 of file Configuration.cpp.

◆ ~Configuration()

virtual Euclid::Configuration::Configuration::~Configuration ( )
virtualdefault

Destructor.

Member Function Documentation

◆ declareDependency()

template<typename T >
void Euclid::Configuration::Configuration::declareDependency ( )
protected

Declares a Configuration as dependency.

Configuration implementations can use this method in their constructor to declare their dependencies.

◆ getCurrentState() [1/2]

Configuration::State & Euclid::Configuration::Configuration::getCurrentState ( )

◆ getCurrentState() [2/2]

Configuration::State Euclid::Configuration::Configuration::getCurrentState ( ) const

Returns the current state of the configuration.

Definition at line 47 of file Configuration.cpp.

References m_state.

◆ getDependencies()

const std::set< std::type_index > & Euclid::Configuration::Configuration::getDependencies ( )

Returns the dependencies of the configuration.

Definition at line 39 of file Configuration.cpp.

References m_dependencies.

◆ getDependency() [1/2]

template<typename T >
T & Euclid::Configuration::Configuration::getDependency ( )
protected

Returns a dependency.

Configuration implementations can use this method to get their dependencies during the initialization phase.

Returns
A reference to the dependency

◆ getDependency() [2/2]

template<typename T >
const T & Euclid::Configuration::Configuration::getDependency ( ) const
protected

◆ getProgramOptions()

std::map< std::string, Configuration::OptionDescriptionList > Euclid::Configuration::Configuration::getProgramOptions ( )
virtual

Returns the program options defined by a specific configuration.

Configuration implementations should implement this method to return the boost program option descriptions they require. The keys of the map will be used as the group message in the final options grouping, so they can be used for grouping options from different Configuration implementations.

The default implementation returns an empty map.

Reimplemented in Euclid::Configuration::CatalogConfig, Euclid::Configuration::PhotometricBandMappingConfig, Euclid::Configuration::PhotometryCatalogConfig, and Euclid::Configuration::SpecZCatalogConfig.

Definition at line 29 of file Configuration.cpp.

◆ initialize()

void Euclid::Configuration::Configuration::initialize ( const UserValues args)
virtual

Method which is called during the initialization phase.

The Configuration implementations should override this method to implement their logic. When this method is called, all the configurations which are defined as dependencies by using the declareDependency() method are guaranteed to already be initialized.

Parameters
argsThe user parameters

Reimplemented in Euclid::Configuration::PdfCatalogConfig< T >, Euclid::Configuration::CatalogConfig, Euclid::Configuration::PhotometricBandMappingConfig, Euclid::Configuration::PhotometryCatalogConfig, and Euclid::Configuration::SpecZCatalogConfig.

Definition at line 35 of file Configuration.cpp.

◆ postInitialize()

void Euclid::Configuration::Configuration::postInitialize ( const UserValues args)
virtual

Method which is called after the initialization phase.

This method is called after all configurations have been initialized. It can be overridden by Configurations which want to perform an action with the guarantee that all other Configurations are initialized. There is no guarantee on the order this method is called between the dependent configurations.

Parameters
argsThe user parameters

Definition at line 37 of file Configuration.cpp.

◆ preInitialize()

void Euclid::Configuration::Configuration::preInitialize ( const UserValues args)
virtual

Method which is called before the initialization phase.

The Configuration implementations can override this method to implement actions which are fast and do not require their dependencies (like textual validation of the inputs). There is no guarantee on the order this method is called between the dependent configurations.

Parameters
argsThe user parameters

Reimplemented in Euclid::Configuration::CatalogConfig, and Euclid::Configuration::SpecZCatalogConfig.

Definition at line 33 of file Configuration.cpp.

Member Data Documentation

◆ m_dependencies

std::set<std::type_index> Euclid::Configuration::Configuration::m_dependencies
private

Definition at line 174 of file Configuration.h.

Referenced by getDependencies().

◆ m_manager_id

long Euclid::Configuration::Configuration::m_manager_id
private

Definition at line 173 of file Configuration.h.

◆ m_state

State Euclid::Configuration::Configuration::m_state = State::CONSTRUCTED
private

Definition at line 175 of file Configuration.h.

Referenced by getCurrentState(), and getCurrentState().


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