OMNeT++ Simulation Library  5.6.1
cConfiguration Class Referenceabstract

#include <cconfiguration.h>

Description

Represents the configuration, as accessed by the simulation kernel.

This class provides access to configuration data for components such as scheduler classes, parallel simulation algorithms, etc. Model code (simple modules) should not directly read the configuration, they are expected to rely on module parameters for input.

This class logically belongs to the cEnvir facade, and the configuration instance can be accessed with getEnvir()->getConfig().

See also
cConfigurationEx, cEnvir::getConfig()
Inheritance diagram for cConfiguration:
cObject cConfigurationEx

Classes

class  KeyValue
 Describes a configuration entry. More...
 
struct  RunInfo
 Struct used by unrollConfig() to return information. More...
 

Public Member Functions

String-based getters for configuration options
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
 
Getters for configuration options
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
 
Getters for per-object configuration options
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
 
Other methods
virtual const char * substituteVariables (const char *value) const =0
 
- Public Member Functions inherited from cObject
 cObject ()
 
 cObject (const cObject &other)
 
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
 
const cObjectgetThisPtr () const
 
virtual std::string str () const
 
virtual _OPPDEPRECATED std::string info () const
 
virtual _OPPDEPRECATED std::string detailedInfo () const
 
virtual cObjectdup () const
 
virtual void parsimPack (cCommBuffer *buffer) const
 
virtual void parsimUnpack (cCommBuffer *buffer)
 
virtual cObjectgetOwner () const
 
virtual bool isOwnedObject () const
 
virtual void forEachChild (cVisitor *v)
 
cObjectfindObject (const char *name, bool deep=true)
 
void copyNotSupported () const
 

Static Public Member Functions

Utility functions for parsing config entries
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)
 

Additional Inherited Members

- Protected Member Functions inherited from cObject
virtual void take (cOwnedObject *obj)
 
virtual void drop (cOwnedObject *obj)
 
void dropAndDelete (cOwnedObject *obj)
 

Member Function Documentation

◆ getConfigValue()

virtual const char* getConfigValue ( const char *  key) const
pure virtual

Returns a configuration value. Valid keys do not contain dots or wildcard characters. Returns nullptr if key is not found.

◆ getConfigEntry()

virtual const KeyValue& getConfigEntry ( const char *  key) const
pure virtual

Like getConfigValue(), 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!).

◆ getPerObjectConfigValue()

virtual const char* getPerObjectConfigValue ( const char *  objectFullPath,
const char *  keySuffix 
) const
pure virtual

Returns a per-object configuration value. Valid keysuffixes do not contain dots or wildcard characters. Returns nullptr if key is not found. keySuffix is something like "vector-recording-intervals", "ev-output", etc.

◆ getPerObjectConfigEntry()

virtual const KeyValue& getPerObjectConfigEntry ( const char *  objectFullPath,
const char *  keySuffix 
) const
pure virtual

Like getPerObjectConfigValue(), 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!).

◆ getAsCustom() [1/2]

virtual const char* getAsCustom ( cConfigOption option,
const char *  fallbackValue = nullptr 
) const
virtual

Returns a config value without any conversion. fallbackValue is returned if the value is not specified in the configuration, and there is no default value.

◆ getAsBool() [1/2]

virtual bool getAsBool ( cConfigOption option,
bool  fallbackValue = false 
) const
virtual

Returns a config value as bool. fallbackValue is returned if the value is not specified in the configuration, and there is no default value.

◆ getAsInt() [1/2]

virtual long getAsInt ( cConfigOption option,
long  fallbackValue = 0 
) const
virtual

Returns a config value as long. fallbackValue is returned if the value is not specified in the configuration, and there is no default value.

◆ getAsDouble() [1/2]

virtual double getAsDouble ( cConfigOption option,
double  fallbackValue = 0 
) const
virtual

Returns a config value as double. fallbackValue is returned if the value is not specified in the configuration, and there is no default value.

◆ getAsString() [1/2]

virtual std::string getAsString ( cConfigOption option,
const char *  fallbackValue = "" 
) const
virtual

Returns a config value as string. fallbackValue is returned if the value is not specified in the configuration, and there is no default value.

◆ getAsFilename() [1/2]

virtual std::string getAsFilename ( cConfigOption option) const
virtual

Interprets the config value as a path. If it is relative, then it will be converted to an absolute path, using the base directory (see the getBaseDirectoryFor() method).

◆ getAsFilenames() [1/2]

virtual std::vector<std::string> getAsFilenames ( cConfigOption option) const
virtual

Interprets the config value as a list of paths (file or directory names, possibly containing wildcards), separated by spaces. The relative paths in the list will be converted to absolute, using the base directory (see getBaseDirectoryFor() method).

◆ getAsPath() [1/2]

virtual std::string getAsPath ( cConfigOption option) const
virtual

Interprets the config value as a list of directory names, possibly containing wildcards, and separated by ";" (Windows), or ":" or ";" (other OSes). The relative names in the list will be converted to absolute, using the base directory (see getBaseDirectoryFor() method).

◆ getAsCustom() [2/2]

virtual const char* getAsCustom ( const char *  objectFullPath,
cConfigOption option,
const char *  fallbackValue = nullptr 
) const
virtual

Returns a per-object config value without any conversion. fallbackValue is returned if the value is not specified in the configuration, and there is no default value.

◆ getAsBool() [2/2]

virtual bool getAsBool ( const char *  objectFullPath,
cConfigOption option,
bool  fallbackValue = false 
) const
virtual

Returns a per-object config value as bool. fallbackValue is returned if the value is not specified in the configuration, and there is no default value.

◆ getAsInt() [2/2]

virtual long getAsInt ( const char *  objectFullPath,
cConfigOption option,
long  fallbackValue = 0 
) const
virtual

Returns a per-object config value as long. fallbackValue is returned if the value is not specified in the configuration, and there is no default value.

◆ getAsDouble() [2/2]

virtual double getAsDouble ( const char *  objectFullPath,
cConfigOption option,
double  fallbackValue = 0 
) const
virtual

Returns a per-object config value as double. fallbackValue is returned if the value is not specified in the configuration, and there is no default value.

◆ getAsString() [2/2]

virtual std::string getAsString ( const char *  objectFullPath,
cConfigOption option,
const char *  fallbackValue = "" 
) const
virtual

Returns a per-object config value as string. fallbackValue is returned if the value is not specified in the configuration, and there is no default value.

◆ getAsFilename() [2/2]

virtual std::string getAsFilename ( const char *  objectFullPath,
cConfigOption option 
) const
virtual

Interprets the per-object config value as a path. If it is relative, then it will be converted to an absolute path, using the base directory (see KeyValue::getBaseDirectory()).

◆ getAsFilenames() [2/2]

virtual std::vector<std::string> getAsFilenames ( const char *  objectFullPath,
cConfigOption option 
) const
virtual

Interprets the per-object config value as a list of paths (file or directory names, possibly containing wildcards), separated by spaces. The relative paths in the list will be converted to absolute, using the base directory (see KeyValue::getBaseDirectory()).

◆ getAsPath() [2/2]

virtual std::string getAsPath ( const char *  objectFullPath,
cConfigOption option 
) const
virtual

Interprets the per-object config value as a list of directory names, possibly containing wildcards, and separated by ";" (Windows), or ":" or ";" (other OSes). The relative names in the list will be converted to absolute, using the base directory (see getBaseDirectoryFor() method).

◆ substituteVariables()

virtual const char* substituteVariables ( const char *  value) const
pure virtual

Substitutes ${} variables into the given string. The resulting string is stored inside the configuration object.


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