OpenViBE Documentation 3.6.0
OpenViBE::Kernel::IConfigurationManager Class Referenceabstract

Manager for all kind of configuration. More...

#include <ovIConfigurationManager.h>

+ Inheritance diagram for OpenViBE::Kernel::IConfigurationManager:

Public Member Functions

virtual void clear ()=0
 Clears the content of this configuration manager. More...
 
virtual bool addConfigurationFromFile (const CString &filenameWildCard)=0
 Parses a configuration file and adds its content as token configuration. More...
 
virtual CIdentifier createConfigurationToken (const CString &name, const CString &value)=0
 Creates a new configuration token in this configuration manager. More...
 
virtual bool releaseConfigurationToken (const CIdentifier &id)=0
 Removes an existing configuration token. More...
 
virtual CIdentifier getNextConfigurationTokenIdentifier (const CIdentifier &prevConfigTokenID) const =0
 Iterates on the existing configuration tokens of this configuration manager. More...
 
virtual CString getConfigurationTokenName (const CIdentifier &id) const =0
 Gets a token's name from its id. More...
 
virtual CString getConfigurationTokenValue (const CIdentifier &id) const =0
 Gets a token's value from its id. More...
 
virtual bool setConfigurationTokenName (const CIdentifier &id, const CString &name)=0
 Changes the name of an exisiting token. More...
 
virtual bool setConfigurationTokenValue (const CIdentifier &id, const CString &value)=0
 Changes the value of an exisiting token. More...
 
virtual bool addOrReplaceConfigurationToken (const CString &name, const CString &value)=0
 Adds a token or replaces the value of a token. More...
 
virtual CIdentifier lookUpConfigurationTokenIdentifier (const CString &name, bool recursive=false) const =0
 Searches the identifier of a token with a given name. More...
 
virtual CString lookUpConfigurationTokenValue (const CString &name) const =0
 Searches the value of a token with a given name. More...
 
virtual bool registerKeywordParser (const CString &keyword, const IConfigurationKeywordExpandCallback &callback)=0
 Adds a new parser for special variables. More...
 
virtual bool unregisterKeywordParser (const CString &keyword)=0
 Removes the keyword parser for a given keyword. More...
 
virtual bool unregisterKeywordParser (const IConfigurationKeywordExpandCallback &callback)=0
 Removes the keyword parser for a given keyword. More...
 
virtual CString expand (const CString &expression) const =0
 Expands a string to an expanded string based on its use of configuration tokens. More...
 
 _IsDerivedFromClass_ (IKernelObject, OV_ClassId_Kernel_Config_ConfigManager) virtual CString expandOnlyKeyword(const CString &keyword
 
virtual double expandAsFloat (const CString &in, double fallbackValue=0) const =0
 Expands a string to a floating point value based on its use of configuration tokens. More...
 
virtual int64_t expandAsInteger (const CString &in, int64_t fallbackValue=0) const =0
 Expands a string to an integer value based on its use of configuration tokens. More...
 
virtual uint64_t expandAsUInteger (const CString &in, uint64_t fallbackValue=0) const =0
 Expands a string to an unsigned integer value based on its use of configuration tokens. More...
 
virtual bool expandAsBoolean (const CString &in, bool fallbackValue=true) const =0
 Expands a string to a boolean value based on its use of configuration tokens. More...
 
virtual uint64_t expandAsEnumerationEntryValue (const CString &in, const CIdentifier &enumerationTypeID, uint64_t fallbackValue=0) const =0
 Expands a string to an enumeration entry value based on its use of configuration tokens. More...
 
- Public Member Functions inherited from OpenViBE::IObject
virtual CIdentifier getClassIdentifier () const =0
 Returns the final class identifier of the concrete class. More...
 
virtual bool isDerivedFromClass (const CIdentifier &classId) const
 Checks if this object is compatible with a class identifier. More...
 
virtual bool acceptVisitor (IObjectVisitor &visitor)
 Requests this object to accept a visitor. More...
 

Public Attributes

const CStringexpression
 
const CString bool preserveBackslashes = false) const = 0
 

Additional Inherited Members

- Protected Member Functions inherited from OpenViBE::IObject
virtual ~IObject ()
 

Detailed Description

Manager for all kind of configuration.

Author
Yann Renard (INRIA/IRISA)
Date
2008-11-05

Member Function Documentation

◆ clear()

virtual void OpenViBE::Kernel::IConfigurationManager::clear ( )
pure virtual

Clears the content of this configuration manager.

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ addConfigurationFromFile()

virtual bool OpenViBE::Kernel::IConfigurationManager::addConfigurationFromFile ( const CString filenameWildCard)
pure virtual

Parses a configuration file and adds its content as token configuration.

Parameters
filenameWildCard[in] : a wildcard of the files to parse & add
Returns
true in case of success
false in case of error
Note
In case the wildcard matches several filenames, it is up to this configuration manager to choose the order it parses the files in.
See also
IConfigurationManager::createConfigurationToken

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ createConfigurationToken()

virtual CIdentifier OpenViBE::Kernel::IConfigurationManager::createConfigurationToken ( const CString name,
const CString value 
)
pure virtual

Creates a new configuration token in this configuration manager.

Parameters
name[in] : the name of the configuration token
value[in] the value of the configuration token
Returns
the identifier of the newly created token in case of success
CIdentifier::undefined() in case of error
See also
IConfigurationManager::releaseConfigurationToken
IConfigurationManager::createConfigurationToken

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ releaseConfigurationToken()

virtual bool OpenViBE::Kernel::IConfigurationManager::releaseConfigurationToken ( const CIdentifier id)
pure virtual

Removes an existing configuration token.

Parameters
id[in] : the identifier of the token to remove
Returns
true in case of success
false in case of error
See also
IConfigurationManager::addConfigurationFromFile
IConfigurationManager::createConfigurationToken

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ getNextConfigurationTokenIdentifier()

virtual CIdentifier OpenViBE::Kernel::IConfigurationManager::getNextConfigurationTokenIdentifier ( const CIdentifier prevConfigTokenID) const
pure virtual

Iterates on the existing configuration tokens of this configuration manager.

Parameters
prevConfigTokenID[in] : the identifier of the token to start the iteration from
Returns
the identifier of the next configuration token in case of success
CIdentifier::undefined() in case there is no more token to iterate on

Typicall use of this function is :

CIdentifier tokenID = CIdentifier::undefined(); // defaults to CIdentifier::undefined()
while((tokenID=configManager->getNextConfigurationTokenIdentifier(tokenID)) != CIdentifier::undefined())
{
// do some stuff with current token identified with tokenID
}
static CIdentifier undefined()
Undefined Identifier (the same as default constructor).
Definition: CIdentifier.hpp:77

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ getConfigurationTokenName()

virtual CString OpenViBE::Kernel::IConfigurationManager::getConfigurationTokenName ( const CIdentifier id) const
pure virtual

Gets a token's name from its id.

Parameters
id[in] : the token id which name should be returned
Returns
the name of the token in case of success
an empty string in case of error
See also
IConfigurationManager::getConfigurationTokenValue

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ getConfigurationTokenValue()

virtual CString OpenViBE::Kernel::IConfigurationManager::getConfigurationTokenValue ( const CIdentifier id) const
pure virtual

Gets a token's value from its id.

Parameters
id[in] : the token id which value should be returned
Returns
the value (unexapanded) of the token in case of success
an empty string in case of error
See also
IConfigurationManager::getConfigurationTokenName
IConfigurationManager::expand and others
Note
the returned value is not expanded by this configuration manager ; only the value that was passed at creation time is returned. If you want to expand things, please use IConfigurationManager::expand

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ setConfigurationTokenName()

virtual bool OpenViBE::Kernel::IConfigurationManager::setConfigurationTokenName ( const CIdentifier id,
const CString name 
)
pure virtual

Changes the name of an exisiting token.

Parameters
id[in] : the identifier of the token which name should be changed
name[in] : the new name of the configuration token
Returns
true in case of success
false in case of error
Note
it is not valid to add a token using this function
See also
IConfigurationManager::createConfigurationToken
IConfigurationManager::addConfigurationFromFile
IConfigurationManager::setConfigurationTokenValue

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ setConfigurationTokenValue()

virtual bool OpenViBE::Kernel::IConfigurationManager::setConfigurationTokenValue ( const CIdentifier id,
const CString value 
)
pure virtual

Changes the value of an exisiting token.

Parameters
id[in] : the identifier of the token which value should be changed
value[in] : the new value of the configuration token
Returns
true in case of success
false in case of error
Note
it is not valid to add a token using this function
See also
IConfigurationManager::createConfigurationToken
IConfigurationManager::addConfigurationFromFile
IConfigurationManager::setConfigurationTokenName

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ addOrReplaceConfigurationToken()

virtual bool OpenViBE::Kernel::IConfigurationManager::addOrReplaceConfigurationToken ( const CString name,
const CString value 
)
pure virtual

Adds a token or replaces the value of a token.

Parameters
name[in] : the name of the token which value should be changed
value[in] : the new value of the configuration token
Returns
true in case of success
false in case of error
Note
new tokens can be added with this function
this call is not recursive
See also
IConfigurationManager::createConfigurationToken
IConfigurationManager::addConfigurationFromFile
IConfigurationManager::setConfigurationTokenName

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ lookUpConfigurationTokenIdentifier()

virtual CIdentifier OpenViBE::Kernel::IConfigurationManager::lookUpConfigurationTokenIdentifier ( const CString name,
bool  recursive = false 
) const
pure virtual

Searches the identifier of a token with a given name.

Parameters
name[in] : the name of the token which identifier should be found
recursive[in] : when set to true, asks this configuration manager to propagate the request to parent configuration manager (if any).
Returns
the identifier of the token with the actual name in case of success
CIdentifier::undefined() in case of error
Note
if recursive is set to true then the returned identifier should not be considered as the identifier of an existing token in this configuration manager as it may have been returned from a parent configuration manager. Instead, one must consider the returned identifier as a kind of boolean value : such token actually exists or such token does not exist.

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ lookUpConfigurationTokenValue()

virtual CString OpenViBE::Kernel::IConfigurationManager::lookUpConfigurationTokenValue ( const CString name) const
pure virtual

Searches the value of a token with a given name.

Parameters
name[in] : the name of the token which value should be found
Returns
the value of the token with the actual name in case of success
Note
This function differs of getConfigurationTokenName in the sense that it recursively requests a token value to parent configuration managers until it finds one (if any). It also differs from the expand function in the sense that it takes a token name as input but does not expand its value when it finds it.

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ registerKeywordParser()

virtual bool OpenViBE::Kernel::IConfigurationManager::registerKeywordParser ( const CString keyword,
const IConfigurationKeywordExpandCallback callback 
)
pure virtual

Adds a new parser for special variables.

Parameters
keyword[in] : keyword to overload
callback[in] : handler for the keyword
Returns
true in case of success
Note
This parser provides a function that will handle expanding of tokens like $keyword{sometext}. "sometext" will be passed to the callback;

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ unregisterKeywordParser() [1/2]

virtual bool OpenViBE::Kernel::IConfigurationManager::unregisterKeywordParser ( const CString keyword)
pure virtual

Removes the keyword parser for a given keyword.

Parameters
keyword[in] : keyword of the parser to remove
Returns
true in case of success

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ unregisterKeywordParser() [2/2]

virtual bool OpenViBE::Kernel::IConfigurationManager::unregisterKeywordParser ( const IConfigurationKeywordExpandCallback callback)
pure virtual

Removes the keyword parser for a given keyword.

Parameters
callback[in] : handler for the keyword
Returns
true in case of success

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ expand()

virtual CString OpenViBE::Kernel::IConfigurationManager::expand ( const CString expression) const
pure virtual

Expands a string to an expanded string based on its use of configuration tokens.

Parameters
expression[in] : the string that you want to expan
Returns
the expanded string
See also
IConfigurationManager::expandAsFloat
IConfigurationManager::expandAsInteger
IConfigurationManager::expandAsUInteger
IConfigurationManager::expandAsBoolean
IConfigurationManager::expandAsEnumerationEntryValue

Typical use of this function is :

configManager->expand("${TokenName}")

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ expandAsFloat()

virtual double OpenViBE::Kernel::IConfigurationManager::expandAsFloat ( const CString in,
double  fallbackValue = 0 
) const
pure virtual

Expands a string to a floating point value based on its use of configuration tokens.

Parameters
in[in] : the string that you want to expand
fallbackValue[in] : a fall back value to return in case the expanded string can not be parsed as a floating point value
Returns
the expanded value
See also
IConfigurationManager::expand

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ expandAsInteger()

virtual int64_t OpenViBE::Kernel::IConfigurationManager::expandAsInteger ( const CString in,
int64_t  fallbackValue = 0 
) const
pure virtual

Expands a string to an integer value based on its use of configuration tokens.

Parameters
in[in] : the string that you want to expand
fallbackValue[in] : a fall back value to return in case the expanded string can not be parsed as an integer value
Returns
the expanded value
See also
IConfigurationManager::expand

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ expandAsUInteger()

virtual uint64_t OpenViBE::Kernel::IConfigurationManager::expandAsUInteger ( const CString in,
uint64_t  fallbackValue = 0 
) const
pure virtual

Expands a string to an unsigned integer value based on its use of configuration tokens.

Parameters
in[in] : the string that you want to expand
fallbackValue[in] : a fall back value to return in case the expanded string can not be parsed as an unsigned integer value
Returns
the expanded value
See also
IConfigurationManager::expand

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ expandAsBoolean()

virtual bool OpenViBE::Kernel::IConfigurationManager::expandAsBoolean ( const CString in,
bool  fallbackValue = true 
) const
pure virtual

Expands a string to a boolean value based on its use of configuration tokens.

Parameters
in[in] : the string that you want to expand
fallbackValue[in] : a fall back value to return in case the expanded string can not be parsed as a boolean value
Returns
the expanded value
See also
IConfigurationManager::expand

Implemented in OpenViBE::Kernel::CConfigurationManager.

◆ expandAsEnumerationEntryValue()

virtual uint64_t OpenViBE::Kernel::IConfigurationManager::expandAsEnumerationEntryValue ( const CString in,
const CIdentifier enumerationTypeID,
uint64_t  fallbackValue = 0 
) const
pure virtual

Expands a string to an enumeration entry value based on its use of configuration tokens.

Parameters
in[in] : the string that you want to expand
enumerationTypeID[in] : the enumeration type to use
fallbackValue[in] : a fall back value to return in case the expanded string can not be parsed as an enumeration entry value
Returns
the expanded value
See also
IConfigurationManager::expand
ITypeManager

Implemented in OpenViBE::Kernel::CConfigurationManager.