OMNeT++ API 6.1
Discrete Event Simulation Library
cConfigurationEx Class Referenceabstract

Description

Represents a configuration suitable for use with the Envir library.

This class extends cConfiguration with the following functionality:

  • Methods for reading module parameters; cEnvir's readParameter() method delegates to them by default.
  • Support for multiple configurations (enumeration, activation, etc.)
  • Parameter Study support: run numbers, iteration variables, unrolling, etc.
  • Other utility functions like dump()
See also
cEnvir::getConfigEx()
Inheritance diagram for cConfigurationEx:
[legend]

Public Types

enum  FilterFlags
 

Public Member Functions

virtual void initializeFrom (cConfiguration *bootConfig)=0
 
virtual const char * getFileName () const =0
 
virtual void validate (const char *ignorableConfigKeys=nullptr) const =0
 
Activating a configuration
virtual std::vector< std::string > getConfigNames ()=0
 
virtual void activateConfig (const char *configName, int runNumber=0)=0
 
virtual std::string getConfigDescription (const char *configName) const =0
 
virtual bool isAbstractConfig (const char *configName) const =0
 
virtual std::vector< std::string > getBaseConfigs (const char *configName) const =0
 
virtual std::vector< std::string > getConfigChain (const char *configName) const =0
 
virtual int getNumRunsInConfig (const char *configName) const =0
 
virtual std::vector< RunInfounrollConfig (const char *configName) const =0
 
virtual const char * getActiveConfigName () const =0
 
virtual int getActiveRunNumber () const =0
 
virtual const char * getVariable (const char *varname) const =0
 
virtual std::vector< const char * > getIterationVariableNames () const =0
 
virtual std::vector< const char * > getPredefinedVariableNames () const =0
 
virtual const char * getVariableDescription (const char *varname) const =0
 
virtual void dump () const =0
 
Getting values from the currently active configuration
virtual std::vector< const char * > getMatchingConfigKeys (const char *pattern) const =0
 
virtual const char * getParameterValue (const char *moduleFullPath, const char *paramName, bool hasDefaultValue) const =0
 
virtual const KeyValuegetParameterEntry (const char *moduleFullPath, const char *paramName, bool hasDefaultValue) const =0
 
virtual std::vector< const char * > getKeyValuePairs (int flags=FILT_ALL) const =0
 
virtual std::vector< const char * > getMatchingPerObjectConfigKeySuffixes (const char *objectFullPath, const char *keySuffixPattern) const =0
 
- Public Member Functions inherited from cConfiguration
virtual const char * getConfigValue (const char *key) const =0
 
virtual const KeyValuegetConfigEntry (const char *key) const =0
 
virtual const char * getPerObjectConfigValue (const char *objectFullPath, const char *keySuffix) const =0
 
virtual const KeyValuegetPerObjectConfigEntry (const char *objectFullPath, const char *keySuffix) const =0
 
virtual const char * getConfigValue (cConfigOption *option, const char *fallbackValue=nullptr) const
 
virtual const char * getAsCustom (cConfigOption *option, const char *fallbackValue=nullptr) const
 
virtual bool getAsBool (cConfigOption *option, bool fallbackValue=false) const
 
virtual long getAsInt (cConfigOption *option, long fallbackValue=0) const
 
virtual double getAsDouble (cConfigOption *option, double fallbackValue=0) const
 
virtual std::string getAsString (cConfigOption *option, const char *fallbackValue="") const
 
virtual std::string getAsFilename (cConfigOption *option) const
 
virtual std::vector< std::string > getAsFilenames (cConfigOption *option) const
 
virtual std::string getAsPath (cConfigOption *option) const
 
virtual const char * getPerObjectConfigValue (const char *objectFullPath, cConfigOption *option, const char *fallbackValue=nullptr) const
 
virtual const char * getAsCustom (const char *objectFullPath, cConfigOption *option, const char *fallbackValue=nullptr) const
 
virtual bool getAsBool (const char *objectFullPath, cConfigOption *option, bool fallbackValue=false) const
 
virtual long getAsInt (const char *objectFullPath, cConfigOption *option, long fallbackValue=0) const
 
virtual double getAsDouble (const char *objectFullPath, cConfigOption *option, double fallbackValue=0) const
 
virtual std::string getAsString (const char *objectFullPath, cConfigOption *option, const char *fallbackValue="") const
 
virtual std::string getAsFilename (const char *objectFullPath, cConfigOption *option) const
 
virtual std::vector< std::string > getAsFilenames (const char *objectFullPath, cConfigOption *option) const
 
virtual std::string getAsPath (const char *objectFullPath, cConfigOption *option) const
 
virtual const char * substituteVariables (const char *value) const =0
 
- Public Member Functions inherited from cObject
 cObject ()
 
 cObject (const cObject &other)=default
 
virtual ~cObject ()
 
virtual const char * getClassName () const
 
virtual const char * getName () const
 
bool isName (const char *s) const
 
virtual const char * getFullName () const
 
virtual std::string getFullPath () const
 
virtual std::string getClassAndFullName () const
 
virtual std::string getClassAndFullPath () const
 
const cObjectgetThisPtr () const
 
virtual std::string str () const
 
virtual std::ostream & printOn (std::ostream &os) const
 
virtual cObjectdup () const
 
virtual void parsimPack (cCommBuffer *buffer) const
 
virtual void parsimUnpack (cCommBuffer *buffer)
 
virtual cObjectgetOwner () const
 
virtual bool isOwnedObject () const
 
virtual bool isSoftOwner () const
 
virtual void forEachChild (cVisitor *v)
 
cObjectfindObject (const char *name, bool deep=true)
 
virtual cClassDescriptorgetDescriptor () const
 
void copyNotSupported () const
 

Additional Inherited Members

- Static Public Member Functions inherited from cConfiguration
static bool parseBool (const char *s, const char *defaultValue, bool fallbackValue=false)
 
static long parseLong (const char *s, const char *defaultValue, long fallbackValue=0)
 
static double parseDouble (const char *s, const char *unit, const char *defaultValue, double fallbackValue=0)
 
static std::string parseString (const char *s, const char *defaultValue, const char *fallbackValue="")
 
static std::string parseFilename (const char *s, const char *baseDir, const char *defaultValue)
 
static std::vector< std::string > parseFilenames (const char *s, const char *baseDir, const char *defaultValue)
 
static std::string adjustPath (const char *s, const char *baseDir, const char *defaultValue)
 
- Protected Member Functions inherited from cObject
virtual void take (cOwnedObject *obj)
 
virtual void drop (cOwnedObject *obj)
 
void dropAndDelete (cOwnedObject *obj)
 

Member Enumeration Documentation

◆ FilterFlags

Flags for the 'flags' argument of the getKeyValuePairs() method.

Member Function Documentation

◆ initializeFrom()

virtual void initializeFrom ( cConfiguration bootConfig)
pure virtual

Initializes configuration object from "boot-time" configuration (omnetpp.ini). For example, if a particular cConfiguration subclass uses a database as data source, it may take the connection parameters from the "boot-time" configuration. This method makes global config immediately available, i.e. there is no need for an additional activateConfig() call.

◆ getFileName()

virtual const char* getFileName ( ) const
pure virtual

Returns the name of the configuration file. Returns nullptr if this object is not using a configuration file.

◆ validate()

virtual void validate ( const char *  ignorableConfigKeys = nullptr) const
pure virtual

Validates the configuration: reports obsolete config keys, cycles in the section fallback chain, unrecognized keys, etc as exceptions.

ignorableConfigKeys is the list of config keys whose presence in the configuration should not be reported as errors even if they are not declared using cConfigOptions. The list is space-separated, and items may contain wildcards. Typically, this list will contain "cmdenv-*" when Cmdenv is unavailable (not linked in), "qtenv-*" when Qtenv is unavailable, etc, so that validate() does not report those keys in omnetpp.ini as errors.

◆ getConfigNames()

virtual std::vector<std::string> getConfigNames ( )
pure virtual

Returns the names of the available configurations.

◆ activateConfig()

virtual void activateConfig ( const char *  configName,
int  runNumber = 0 
)
pure virtual

Activates the [Config <name>] section. If it does not exist, an error is thrown. [General] is treated as short for [Config General]. The runNumber must be between 0 and getNumRunsInConfig(name)-1.

◆ getConfigDescription()

virtual std::string getConfigDescription ( const char *  configName) const
pure virtual

Returns the description of the given configuration.

◆ isAbstractConfig()

virtual bool isAbstractConfig ( const char *  configName) const
pure virtual

Returns true if the given configuration is abstract, i.e. it only serves as a base for other configuration.

◆ getBaseConfigs()

virtual std::vector<std::string> getBaseConfigs ( const char *  configName) const
pure virtual

Returns the names of the configurations the given configuration extends directly. Only names of existing configurations are returned (that is, if "extends" is bogus and refers to a nonexistent configuration, this method omits that configuration name; also, "General" is only returned if such configuration actually exists.)

◆ getConfigChain()

virtual std::vector<std::string> getConfigChain ( const char *  configName) const
pure virtual

Returns the names of the configurations the given configuration extends transitively. This is the search order of parameter lookups from the given configuration. Only names of existing configurations are returned.

◆ getNumRunsInConfig()

virtual int getNumRunsInConfig ( const char *  configName) const
pure virtual

Generates Cartesian product of all iterations within the given config, and counts them. If the config does not exist, an error is thrown. [General] is treated as short for [Config General].

◆ unrollConfig()

virtual std::vector<RunInfo> unrollConfig ( const char *  configName) const
pure virtual

Generates all runs in the given configuration, and returns a string for each. When detailed==false, each run will generate a one-line string with the iteration variables; with detailed==true, each run generates a multi-line string containing the config entries that contain iterations or iteration variable references. This method is primarily for debugging purposes.

TODO update description

◆ getActiveConfigName()

virtual const char* getActiveConfigName ( ) const
pure virtual

Returns the name of the currently active configuration.

◆ getActiveRunNumber()

virtual int getActiveRunNumber ( ) const
pure virtual

Returns currently active run number. This is the number passed to activateConfig(), or 0 if activateConfig() has not been called.

◆ getVariable()

virtual const char* getVariable ( const char *  varname) const
pure virtual

After activating a configuration, this method can be used to query iteration variables and predefined variables. These are the variables that can be referred to using the "${...}" syntax in the configuration. If the variable does not exist, nullptr is returned.

Some of the predefined variables are: "configname", "runnumber", "network", "processid", "datetime", "runid", "repetition", "iterationvars"; these names are also available as symbolic constants, see CFGVAR_CONFIGNAME and other CFGVAR_xxx names.

◆ getIterationVariableNames()

virtual std::vector<const char *> getIterationVariableNames ( ) const
pure virtual

Returns the names of all iteration variables in the activated configuration.

◆ getPredefinedVariableNames()

virtual std::vector<const char *> getPredefinedVariableNames ( ) const
pure virtual

Returns the names of all predefined variables in the activated configuration. See getVariable().

◆ getVariableDescription()

virtual const char* getVariableDescription ( const char *  varname) const
pure virtual

Returns the description of the given variable in the activated configuration. Returns nullptr if the variable does not exist or no description is available.

◆ dump()

virtual void dump ( ) const
pure virtual

For debugging.

◆ getMatchingConfigKeys()

virtual std::vector<const char *> getMatchingConfigKeys ( const char *  pattern) const
pure virtual

Returns the list of config keys that match the given wildcard pattern. The returned keys can be passed to getConfigValue().

◆ getParameterValue()

virtual const char* getParameterValue ( const char *  moduleFullPath,
const char *  paramName,
bool  hasDefaultValue 
) const
pure virtual

Looks up the value of the given parameter in the inifile. The argument hasDefaultValue controls whether "=default" entries need to be considered. Return value is nullptr if the parameter is not specified in the inifile, otherwise returns the string after the equal sign.

◆ getParameterEntry()

virtual const KeyValue& getParameterEntry ( const char *  moduleFullPath,
const char *  paramName,
bool  hasDefaultValue 
) const
pure virtual

Like getParameterValue(), but this one returns information about the whole inifile entry, not just the value string. If the key is not found, a special KeyValue object is returned where both key and value are nullptr.

Lifetime of the returned object might be limited, so clients should not store references to it. Copying the object is not allowed either, because KeyValue is a polymorphic type (object slicing!).

◆ getKeyValuePairs()

virtual std::vector<const char *> getKeyValuePairs ( int  flags = FILT_ALL) const
pure virtual

This method returns an array of the following form: (key1, value1, key2, value2,...), where keys and values correspond to (a subset of) the entries in the active configuration.

The 'flags' parameter should take its value from the FilterFlags enum, or the binary OR of several such flags: FILT_PARAM, FILT_CONFIG, etc.

◆ getMatchingPerObjectConfigKeySuffixes()

virtual std::vector<const char *> getMatchingPerObjectConfigKeySuffixes ( const char *  objectFullPath,
const char *  keySuffixPattern 
) const
pure virtual

Returns the list of suffixes from keys that match the wildcard pattern objectFullPath + dot + keySuffixPattern. objectFullPath may either be a concrete string without wildcards, or "**" to match anything. The returned keys may be used with getPerObjectConfigValue() to obtain the corresponding values. The returned suffixes may be used with getPerObjectConfigValue() to obtain the corresponding values.


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