ALib C++ Library
Library Version: 2312 R0
Documentation generated by doxygen
Inner Classes | Public Fields | Public Methods | Protected Fields | Protected Methods | List of all members
ConfigurationPlugin Class Referenceabstract

#include <plugins.hpp>

Inheritance diagram for ConfigurationPlugin:
[legend]
Collaboration diagram for ConfigurationPlugin:
[legend]

Class Description


Abstract class that represents a plug in for class Configuration to provide configuration data from specific configuration data source.

See documentation of namespace aworx::lib::config for more information on ALib external configuration variables.

The plug-in also may have the ability to write data. The default implementation for writing configuration data returns constant false, indicating that this plug-in never writes anything (e.g. command line parameter plug-in, environment variable plug-in).

Category and Variable names are character case insensitive for the plug-ins predefined with ALib. It is recommended to ignore character case in custom specializations of this class as well.

Definition at line 124 of file config/plugins.hpp.

Inner Classes

class  Iterator
 

Public Fields

XTernalizerStringConverter
 

Public Methods

virtual ~ConfigurationPlugin ()
 
virtual IteratorGetIterator (const String &sectionName)
 
virtual ALIB_API bool Load (Variable &variable, bool searchOnly=false)=0
 
virtual String Name () const =0
 
virtual bool Store (Variable &variable)
 
virtual bool Store (Variable &variable, const String &externalizedValue)
 

Protected Fields

XTernalizer defaultStringConverter
 

Protected Methods

 ConfigurationPlugin ()
 

Constructor & Destructor Documentation

◆ ConfigurationPlugin()

ConfigurationPlugin ( )
inlineprotected

Constructor which is protected, as this is an abstract class.

Definition at line 149 of file config/plugins.hpp.

◆ ~ConfigurationPlugin()

virtual ~ConfigurationPlugin ( )
inlinevirtual

Virtual Destructor.

Definition at line 158 of file config/plugins.hpp.

Member Function Documentation

◆ GetIterator()

virtual Iterator* GetIterator ( const String sectionName)
inlinevirtual

Creates an iterator object to return all variables within a section. The iterator object returned, needs to be deleted by the caller.

If a plug-in can not perform iteration, it will return nullptr. This is for example true for plug-in class Environment.

Note
Method Configuration::GetIterator returns an iterator that allows to iterate across all variables of a section found in all plug-ins
Parameters
sectionNameThe name of the section to iterate.
Returns
The iterator requested or nullptr if the plug-in does not support section iteration.

Reimplemented in InMemoryPlugin, and CLIArgs.

Definition at line 262 of file config/plugins.hpp.

◆ Load()

virtual ALIB_API bool Load ( Variable variable,
bool  searchOnly = false 
)
pure virtual

Abstract method that has to be overwritten by descendants. Searches and by default retrieves the value of a configuration variable. If searchOnly is true, then the variable value is not read.

Parameters
variableThe variable to retrieve.
searchOnlyIf true, the variable must not be set. Defaults to false.
Returns
true if variable was found within this configuration source, false if not.

Implemented in Environment, InMemoryPlugin, and CLIArgs.

◆ Name()

virtual String Name ( ) const
pure virtual

Abstract method to return a plug-in name. The name may be used in human readable output, e.g. log-files or exception messages to tell a user for example, which plug-in loaded a variable containing a syntax error.

Returns
The name of the plug-in.

Implemented in Environment, InMemoryPlugin, CLIArgs, and IniFile.

◆ Store() [1/2]

virtual bool Store ( Variable variable)
inlinevirtual

Writes a variable to the configuration. This default implementation just returns false. If this method is not overwritten in descendants, those descendants are not designed to write data.

Parameters
variableThe variable to store.
Returns
true if the variable was written, false if not which typically indicates that this plug-in is not able to write values.

Reimplemented in InMemoryPlugin, and IniFile.

Definition at line 195 of file config/plugins.hpp.

◆ Store() [2/2]

virtual bool Store ( Variable variable,
const String externalizedValue 
)
inlinevirtual

Convenience method that parses the values from the given string using field StringConverter and then invokes Store.

Parameters
variableThe variable to store.
externalizedValueThe value to parse into the variable before storing
Returns
true if the variable was written, false if not which typically indicates that this plug-in is not able to write values.

Definition at line 212 of file config/plugins.hpp.

Here is the call graph for this function:

Member Data Documentation

◆ defaultStringConverter

XTernalizer defaultStringConverter
protected

The default external string converter.

Definition at line 131 of file config/plugins.hpp.

◆ StringConverter

XTernalizer* StringConverter

The external string converter. By default this points to field defaultStringConverter.

Definition at line 140 of file config/plugins.hpp.


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