netxsimdg
|
#include <Configured.hpp>
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 > | |
T | retrieveValue (const std::string &name) |
Retrieves a configured value of a single option. | |
A base class to provide configuration infrastructure to classes that can be configured.
Definition at line 36 of file Configured.hpp.
using Nextsim::Configured< C >::ConfigType = ConfigurationHelp::ConfigType |
Definition at line 39 of file Configured.hpp.
ConfigurationHelp::HelpMap Nextsim::Configured< C >::HelpMap |
Definition at line 38 of file Configured.hpp.
|
inlineprotected |
Adds an option to the per-class option map.
name | Name of the option to add. |
defaultValue | Default value to apply if the configuration is not found. |
Definition at line 149 of file Configured.hpp.
|
inlinestatic |
Clear the configuration map. Usually used only in test suites.
Definition at line 136 of file Configured.hpp.
|
pure virtual |
The configuration function.
Implements Nextsim::ConfiguredBase.
Implemented in Config2, Config3, Nextsim::ConfigOutput, Nextsim::Model, and Nextsim::PrognosticData.
|
inlinevirtual |
Returns the current configuration of the object.
Implements Nextsim::ConfiguredBase.
Definition at line 49 of file Configured.hpp.
|
inlinestatic |
Gets the value of the configuration with a given name from the default Configurator.
name | Name of the configuration option to fetch. |
defaultValue | Default value to apply if the configuration is not found. |
Definition at line 113 of file Configured.hpp.
|
static |
Gets the configuration help text for the current class as well as any classes used herein.
map | The map to fill with the new text. |
getAll | Get all options, or just the ones for configured modules? |
|
static |
Gets the text to be printed as the help text for this configuration.
map | The map to fill with the new text. |
getAll | Get all options, or just the ones for configured modules? |
const std::map< int, std::string > Nextsim::Configured< Model >::keyMap |
const std::map< int, std::string > Nextsim::Configured< ConfigOutput >::keyMap |
Definition at line 21 of file ConfigOutput.cpp.
const std::map< int, std::string > Nextsim::Configured< Config2 >::keyMap |
Definition at line 65 of file Configurator_test.cpp.
const std::map< int, std::string > Nextsim::Configured< Config3 >::keyMap |
Definition at line 106 of file Configurator_test.cpp.
|
inlineprotected |
Retrieves a configured value of a single option.
name | Name of the configuration option to fetch. |
Definition at line 159 of file Configured.hpp.
|
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.
ref | A reference to the class on which to attempt configuration. |
Definition at line 195 of file Configured.hpp.
|
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.
ptr | A pointer to the class on which to attempt configuration. |
Definition at line 214 of file Configured.hpp.
|
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.
ref | A reference to the class for which to attempt to retrieve the configuration. |
Definition at line 233 of file Configured.hpp.
|
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.
ptr | A pointer to the class for which to attempt to retrieve the configuration. |
Definition at line 254 of file Configured.hpp.
|
static |
A per-class static map to provide compile-time checking of configuration keys.
Definition at line 139 of file Configured.hpp.