Goby3  3.1.4
2024.02.22
goby::middleware::ConfiguratorInterface< Config > Class Template Referenceabstract

Defines the interface to a "configurator", a class that can read command line parameters (argc, argv) and produce a configuration object. More...

#include <goby/middleware/application/configurator.h>

Inheritance diagram for goby::middleware::ConfiguratorInterface< Config >:
goby::middleware::ProtobufConfigurator< Config >

Public Member Functions

const Config & cfg () const
 The configuration object produced from the command line parameters. More...
 
virtual const protobuf::AppConfigapp_configuration () const
 Subset of the configuration used to configure the Application itself. More...
 
virtual void validate () const
 Override to validate the configuration. More...
 
virtual void handle_config_error (middleware::ConfigException &e) const
 Override to customize how ConfigException errors are handled. More...
 
virtual std::string str () const =0
 Override to output the configuration object as a string. More...
 

Protected Member Functions

Config & mutable_cfg ()
 Derived classes can modify the configuration as needed in their constructor. More...
 
virtual protobuf::AppConfigmutable_app_configuration ()
 Derived classes can modify the application configuration as needed in their constructor. More...
 

Detailed Description

template<typename Config>
class goby::middleware::ConfiguratorInterface< Config >

Defines the interface to a "configurator", a class that can read command line parameters (argc, argv) and produce a configuration object.

Configurators are used to read command line parameters (and subsequently possibly open one or more configuration files) to populate the values in a configuration object that is used by the code to be configured (SingleThreadApplication, MultiThreadApplication, SimpleThread, etc.).

Template Parameters
ConfigThe type of the configuration object produced by the configurator

Definition at line 38 of file configurator.h.

Member Function Documentation

◆ app_configuration()

template<typename Config >
virtual const protobuf::AppConfig& goby::middleware::ConfiguratorInterface< Config >::app_configuration ( ) const
inlinevirtual

Subset of the configuration used to configure the Application itself.

Todo:
Change AppConfig to a C++ struct (not a Protobuf message)

Reimplemented in goby::middleware::ProtobufConfigurator< Config >.

Definition at line 46 of file configurator.h.

◆ cfg()

template<typename Config >
const Config& goby::middleware::ConfiguratorInterface< Config >::cfg ( ) const
inline

The configuration object produced from the command line parameters.

Definition at line 42 of file configurator.h.

◆ handle_config_error()

template<typename Config >
virtual void goby::middleware::ConfiguratorInterface< Config >::handle_config_error ( middleware::ConfigException e) const
inlinevirtual

Override to customize how ConfigException errors are handled.

Definition at line 54 of file configurator.h.

◆ mutable_app_configuration()

template<typename Config >
virtual protobuf::AppConfig& goby::middleware::ConfiguratorInterface< Config >::mutable_app_configuration ( )
inlineprotectedvirtual

Derived classes can modify the application configuration as needed in their constructor.

Definition at line 67 of file configurator.h.

◆ mutable_cfg()

template<typename Config >
Config& goby::middleware::ConfiguratorInterface< Config >::mutable_cfg ( )
inlineprotected

Derived classes can modify the configuration as needed in their constructor.

Definition at line 64 of file configurator.h.

◆ str()

template<typename Config >
virtual std::string goby::middleware::ConfiguratorInterface< Config >::str ( ) const
pure virtual

Override to output the configuration object as a string.

◆ validate()

template<typename Config >
virtual void goby::middleware::ConfiguratorInterface< Config >::validate ( ) const
inlinevirtual

Override to validate the configuration.

Exceptions
ConfigExceptionif the configuration is not valid

Reimplemented in goby::middleware::ProtobufConfigurator< Config >.

Definition at line 51 of file configurator.h.


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