OMNeT++ Simulation Library  6.0.3
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 * 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
 
Getters for per-object configuration options
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
 
Other methods
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
 

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() [1/2]

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

Returns the value for the given key in the configuration. The key should not contain dots or wildcard characters. Returns nullptr if key is not found.

◆ getConfigEntry()

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

Returns the entry for the given key in the configuration. If the key is not found, a special KeyValue object is returned where both key and value are nullptr.

The 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() [1/2]

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

Returns the value for the key "<objectFullPath>.<keySuffix>" in the configuration. keySuffix should not contain dots or wildcard characters. Example keySuffix: "vector-recording-intervals". Returns nullptr if key is not found.

◆ getPerObjectConfigEntry()

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

Returns the entry for the key "<objectFullPath>.<keySuffix>" in the configuration. keySuffix should not contain dots or wildcard characters. Example keySuffix: "vector-recording-intervals". If the key is not found, a special KeyValue object is returned where both key and value are nullptr.

The 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!).

◆ getConfigValue() [2/2]

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

Returns the value of the configuration option in string form, independent of its type. fallbackValue is returned if the value is not specified in the configuration, and there is no default value.

◆ getAsCustom() [1/2]

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

Returns the value of the configuration option without any conversion. The option's type must be CFG_CUSTOM. 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 the value of the configuration option as bool. The option's type must be CFG_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 the value of the configuration option as long. The option's type must be CFG_INT. 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 the value of the configuration option as double. The option's type must be CFG_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 the value of the configuration option as string. The option's type must be CFG_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

Returns the value of the configuration option as a file path. The option's type must be CFG_FILENAME. If it is relative path, 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

Returns the value of the configuration option as a list of file paths (file or directory names, possibly containing wildcards), separated by spaces. The option's type must be CFG_FILENAMES. 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

Returns the value of the configuration option as a list of directory names, possibly containing wildcards, and separated by ";" (Windows), or ":" or ";" (other OSes). The option's type must be CFG_PATH. The relative names in the list will be converted to absolute, using the base directory (see getBaseDirectoryFor() method).

◆ getPerObjectConfigValue() [2/2]

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

Returns a per-object config value in string form, independent of its type. fallbackValue is returned if the value is not specified in the configuration, and there is no default value.

◆ 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. The option's type must be CFG_CUSTOM. 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. The option's type must be CFG_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. The option's type must be CFG_INT. 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. The option's type must be CFG_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. The option's type must be CFG_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

Returns the per-object config value as a file path. The option's type must be CFG_FILENAME. If the value 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

Returns the per-object config value as a list of file paths (file or directory names, possibly containing wildcards), separated by spaces. The option's type must be CFG_FILENAMES. 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

Returns the per-object config value as a list of directory names, possibly containing wildcards, and separated by ";" (Windows), or ":" or ";" (other OSes). The option's type must be CFG_PATH. 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: