16 #ifndef __OMNETPP_CCONFIGURATION_H
17 #define __OMNETPP_CCONFIGURATION_H
22 #include "simkerneldefs.h"
33 #define CFGNAME_GENERAL "General"
43 #define CFGVAR_RUNID "runid"
44 #define CFGVAR_INIFILE "inifile"
45 #define CFGVAR_CONFIGNAME "configname"
46 #define CFGVAR_RUNNUMBER "runnumber"
47 #define CFGVAR_NETWORK "network"
48 #define CFGVAR_EXPERIMENT "experiment"
49 #define CFGVAR_MEASUREMENT "measurement"
50 #define CFGVAR_REPLICATION "replication"
51 #define CFGVAR_PROCESSID "processid"
52 #define CFGVAR_DATETIME "datetime"
53 #define CFGVAR_DATETIMEF "datetimef"
54 #define CFGVAR_RESULTDIR "resultdir"
55 #define CFGVAR_REPETITION "repetition"
56 #define CFGVAR_SEEDSET "seedset"
57 #define CFGVAR_ITERATIONVARS "iterationvars"
58 #define CFGVAR_ITERATIONVARSF "iterationvarsf"
59 #define CFGVAR_ITERATIONVARSD "iterationvarsd"
76 class SIM_API cConfiguration : public cObject
85 virtual const char *getKey()
const = 0;
86 virtual const char *getValue()
const = 0;
87 virtual const char *getBaseDirectory()
const = 0;
88 virtual FileLine getSourceLocation()
const;
96 std::map<std::string,std::string> runAttrs;
97 std::string configBrief;
108 virtual const char *getConfigValue(
const char *key)
const = 0;
119 virtual const KeyValue& getConfigEntry(
const char *key)
const = 0;
127 virtual const char *getPerObjectConfigValue(
const char *objectFullPath,
const char *keySuffix)
const = 0;
140 virtual const KeyValue& getPerObjectConfigEntry(
const char *objectFullPath,
const char *keySuffix)
const = 0;
145 static bool parseBool(
const char *s,
const char *defaultValue,
bool fallbackValue=
false);
146 static long parseLong(
const char *s,
const char *defaultValue,
long fallbackValue=0);
147 static double parseDouble(
const char *s,
const char *unit,
const char *defaultValue,
double fallbackValue=0);
148 static std::string parseString(
const char *s,
const char *defaultValue,
const char *fallbackValue=
"");
149 static std::string parseFilename(
const char *s,
const char *baseDir,
const char *defaultValue);
150 static std::vector<std::string> parseFilenames(
const char *s,
const char *baseDir,
const char *defaultValue);
151 static std::string adjustPath(
const char *s,
const char *baseDir,
const char *defaultValue);
160 virtual const char *getConfigValue(
cConfigOption *option,
const char *fallbackValue=
nullptr)
const;
166 virtual const char *getAsCustom(
cConfigOption *option,
const char *fallbackValue=
nullptr)
const;
172 virtual bool getAsBool(
cConfigOption *option,
bool fallbackValue=
false)
const;
178 virtual long getAsInt(
cConfigOption *option,
long fallbackValue=0)
const;
184 virtual double getAsDouble(
cConfigOption *option,
double fallbackValue=0)
const;
190 virtual std::string getAsString(
cConfigOption *option,
const char *fallbackValue=
"")
const;
197 virtual std::string getAsFilename(
cConfigOption *option)
const;
205 virtual std::vector<std::string> getAsFilenames(
cConfigOption *option)
const;
223 virtual const char *getPerObjectConfigValue(
const char *objectFullPath,
cConfigOption *option,
const char *fallbackValue=
nullptr)
const;
229 virtual const char *getAsCustom(
const char *objectFullPath,
cConfigOption *option,
const char *fallbackValue=
nullptr)
const;
235 virtual bool getAsBool(
const char *objectFullPath,
cConfigOption *option,
bool fallbackValue=
false)
const;
241 virtual long getAsInt(
const char *objectFullPath,
cConfigOption *option,
long fallbackValue=0)
const;
247 virtual double getAsDouble(
const char *objectFullPath,
cConfigOption *option,
double fallbackValue=0)
const;
253 virtual std::string getAsString(
const char *objectFullPath,
cConfigOption *option,
const char *fallbackValue=
"")
const;
260 virtual std::string getAsFilename(
const char *objectFullPath,
cConfigOption *option)
const;
268 virtual std::vector<std::string> getAsFilenames(
const char *objectFullPath,
cConfigOption *option)
const;
277 virtual std::string getAsPath(
const char *objectFullPath,
cConfigOption *option)
const;
286 virtual const char *substituteVariables(
const char *value)
const = 0;
311 FILT_ESSENTIAL_CONFIG = 1 << 0,
312 FILT_GLOBAL_CONFIG = 1 << 1 | FILT_ESSENTIAL_CONFIG,
313 FILT_PER_OBJECT_CONFIG = 1 << 2,
314 FILT_CONFIG = FILT_GLOBAL_CONFIG | FILT_PER_OBJECT_CONFIG,
316 FILT_ALL = FILT_CONFIG | FILT_PARAM
334 virtual const char *getFileName()
const = 0;
348 virtual void validate(
const char *ignorableConfigKeys=
nullptr)
const = 0;
355 virtual std::vector<std::string> getConfigNames() = 0;
362 virtual void activateConfig(
const char *configName,
int runNumber=0) = 0;
367 virtual std::string getConfigDescription(
const char *configName)
const = 0;
376 virtual std::vector<std::string> getBaseConfigs(
const char *configName)
const = 0;
383 virtual std::vector<std::string> getConfigChain(
const char * configName)
const = 0;
390 virtual int getNumRunsInConfig(
const char *configName)
const = 0;
401 virtual std::vector<RunInfo> unrollConfig(
const char *configName)
const = 0;
406 virtual const char *getActiveConfigName()
const = 0;
412 virtual int getActiveRunNumber()
const = 0;
425 virtual const char *getVariable(
const char *varname)
const = 0;
430 virtual std::vector<const char *> getIterationVariableNames()
const = 0;
436 virtual std::vector<const char *> getPredefinedVariableNames()
const = 0;
442 virtual const char *getVariableDescription(
const char *varname)
const = 0;
447 virtual void dump()
const = 0;
457 virtual std::vector<const char *> getMatchingConfigKeys(
const char *pattern)
const = 0;
465 virtual const char *getParameterValue(
const char *moduleFullPath,
const char *paramName,
bool hasDefaultValue)
const = 0;
477 virtual const KeyValue& getParameterEntry(
const char *moduleFullPath,
const char *paramName,
bool hasDefaultValue)
const = 0;
487 virtual std::vector<const char *> getKeyValuePairs(
int flags=FILT_ALL)
const = 0;
497 virtual std::vector<const char *> getMatchingPerObjectConfigKeySuffixes(
const char *objectFullPath,
const char *keySuffixPattern)
const = 0;