netxsimdg
Loading...
Searching...
No Matches
Nextsim::Configured< C > Class Template Referenceabstract

#include <Configured.hpp>

Inheritance diagram for Nextsim::Configured< C >:
Inheritance graph
Collaboration diagram for Nextsim::Configured< C >:
Collaboration graph

Public Types

typedef ConfigurationHelp::HelpMap HelpMap
 
using ConfigType = ConfigurationHelp::ConfigType
 

Public Member Functions

virtual void configure ()=0
 The configuration function.
 
virtual ConfigMap getConfiguration () const
 Returns the current configuration of the object.
 
const std::map< int, std::string > keyMap
 
const std::map< int, std::string > keyMap
 
const std::map< int, std::string > keyMap
 
const std::map< int, std::string > keyMap
 
- Public Member Functions inherited from Nextsim::ConfiguredBase

Static Public Member Functions

template<typename T >
static void tryConfigure (T &ref)
 Template function for conditionally configuring references.
 
template<typename T >
static void tryConfigure (T *ptr)
 Template function for conditionally configuring classes via a pointer.
 
template<typename T >
static ConfigMap tryGetConfiguration (T &ref)
 Template function for conditionally retrieving class configuration via a reference.
 
template<typename T >
static ConfigMap tryGetConfiguration (T *ptr)
 Template function for conditionally retrieving class configuration via a pointer.
 
template<typename T >
static T getConfiguration (const std::string &name, const T &defaultValue)
 Gets the value of the configuration with a given name from the default Configurator.
 
static HelpMap & getHelpText (HelpMap &map, bool getAll)
 Gets the text to be printed as the help text for this configuration.
 
static HelpMap & getHelpRecursive (HelpMap &map, bool getAll)
 Gets the configuration help text for the current class as well as any classes used herein.
 
static void clearConfigurationMap ()
 Clear the configuration map. Usually used only in test suites.
 

Static Public Attributes

static const std::map< int, std::string > keyMap
 A per-class static map to provide compile-time checking of configuration keys.
 

Protected Member Functions

template<typename T >
void addOption (const std::string &name, const T &defaultValue)
 Adds an option to the per-class option map.
 
template<typename T >
retrieveValue (const std::string &name)
 Retrieves a configured value of a single option.
 

Detailed Description

template<typename C>
class Nextsim::Configured< C >

A base class to provide configuration infrastructure to classes that can be configured.

Definition at line 36 of file Configured.hpp.

Member Typedef Documentation

◆ ConfigType

template<typename C >
using Nextsim::Configured< C >::ConfigType = ConfigurationHelp::ConfigType

Definition at line 39 of file Configured.hpp.

◆ HelpMap

template<typename C >
ConfigurationHelp::HelpMap Nextsim::Configured< C >::HelpMap

Definition at line 38 of file Configured.hpp.

Member Function Documentation

◆ addOption()

template<typename C >
template<typename T >
void Nextsim::Configured< C >::addOption ( const std::string & name,
const T & defaultValue )
inlineprotected

Adds an option to the per-class option map.

Parameters
nameName of the option to add.
defaultValueDefault value to apply if the configuration is not found.

Definition at line 149 of file Configured.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clearConfigurationMap()

template<typename C >
static void Nextsim::Configured< C >::clearConfigurationMap ( )
inlinestatic

Clear the configuration map. Usually used only in test suites.

Definition at line 136 of file Configured.hpp.

◆ configure()

template<typename C >
virtual void Nextsim::Configured< C >::configure ( )
pure virtual

The configuration function.

Implements Nextsim::ConfiguredBase.

Implemented in Config2, Config3, Nextsim::ConfigOutput, Nextsim::Model, and Nextsim::PrognosticData.

◆ getConfiguration() [1/2]

template<typename C >
virtual ConfigMap Nextsim::Configured< C >::getConfiguration ( ) const
inlinevirtual

Returns the current configuration of the object.

Implements Nextsim::ConfiguredBase.

Definition at line 49 of file Configured.hpp.

Here is the caller graph for this function:

◆ getConfiguration() [2/2]

template<typename C >
template<typename T >
static T Nextsim::Configured< C >::getConfiguration ( const std::string & name,
const T & defaultValue )
inlinestatic

Gets the value of the configuration with a given name from the default Configurator.

Parameters
nameName of the configuration option to fetch.
defaultValueDefault value to apply if the configuration is not found.

Definition at line 113 of file Configured.hpp.

Here is the call graph for this function:

◆ getHelpRecursive()

template<typename C >
static HelpMap & Nextsim::Configured< C >::getHelpRecursive ( HelpMap & map,
bool getAll )
static

Gets the configuration help text for the current class as well as any classes used herein.

Parameters
mapThe map to fill with the new text.
getAllGet all options, or just the ones for configured modules?

◆ getHelpText()

template<typename C >
static HelpMap & Nextsim::Configured< C >::getHelpText ( HelpMap & map,
bool getAll )
static

Gets the text to be printed as the help text for this configuration.

Parameters
mapThe map to fill with the new text.
getAllGet all options, or just the ones for configured modules?

◆ keyMap() [1/4]

const std::map< int, std::string > Nextsim::Configured< Model >::keyMap

Definition at line 28 of file Model.cpp.

◆ keyMap() [2/4]

const std::map< int, std::string > Nextsim::Configured< ConfigOutput >::keyMap

Definition at line 21 of file ConfigOutput.cpp.

◆ keyMap() [3/4]

const std::map< int, std::string > Nextsim::Configured< Config2 >::keyMap

Definition at line 65 of file Configurator_test.cpp.

◆ keyMap() [4/4]

const std::map< int, std::string > Nextsim::Configured< Config3 >::keyMap

Definition at line 106 of file Configurator_test.cpp.

◆ retrieveValue()

template<typename C >
template<typename T >
T Nextsim::Configured< C >::retrieveValue ( const std::string & name)
inlineprotected

Retrieves a configured value of a single option.

Parameters
nameName of the configuration option to fetch.

Definition at line 159 of file Configured.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tryConfigure() [1/2]

template<typename C >
template<typename T >
void Nextsim::Configured< C >::tryConfigure ( T & ref)
static

Template function for conditionally configuring references.

Pass any class to this function (or its pointer equivalent). If it is a derived class of Configured, the overridden configure() function will be called. If it is not, the function will do nothing, gracefully.

Parameters
refA reference to the class on which to attempt configuration.

Definition at line 195 of file Configured.hpp.

Here is the caller graph for this function:

◆ tryConfigure() [2/2]

template<typename C >
template<typename T >
void Nextsim::Configured< C >::tryConfigure ( T * ptr)
static

Template function for conditionally configuring classes via a pointer.

Pass any class to this function (or its reference equivalent). If it is a derived class of Configured, the overridden configure() function will be called. If it is not, the function will do nothing, gracefully.

Parameters
ptrA pointer to the class on which to attempt configuration.

Definition at line 214 of file Configured.hpp.

Here is the call graph for this function:

◆ tryGetConfiguration() [1/2]

template<typename C >
template<typename T >
ConfigMap Nextsim::Configured< C >::tryGetConfiguration ( T & ref)
static

Template function for conditionally retrieving class configuration via a reference.

Pass any class to this function (or its pointer equivalent). If it is a derived class of Configured, the overridden getConfiguration() function will be called. If it is not, the function will do nothing, gracefully, and return an empty ConfigMap.

Parameters
refA reference to the class for which to attempt to retrieve the configuration.

Definition at line 233 of file Configured.hpp.

◆ tryGetConfiguration() [2/2]

template<typename C >
template<typename T >
ConfigMap Nextsim::Configured< C >::tryGetConfiguration ( T * ptr)
static

Template function for conditionally retrieving class configuration via a pointer.

Pass any class pointer to this function (or its reference equivalent). If it is a derived class of Configured, the overridden getConfiguration() function will be called. If it is not, the function will do nothing, gracefully and return an empty ConfigMap.

Parameters
ptrA pointer to the class for which to attempt to retrieve the configuration.

Definition at line 254 of file Configured.hpp.

Here is the call graph for this function:

Member Data Documentation

◆ keyMap

template<typename C >
const std::map<int, std::string> Nextsim::Configured< C >::keyMap
static

A per-class static map to provide compile-time checking of configuration keys.

Definition at line 139 of file Configured.hpp.


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