cconfiguration.h

00001 //==========================================================================
00002 //  CCONFIGURATION.H - part of
00003 //
00004 //                     OMNeT++/OMNEST
00005 //            Discrete System Simulation in C++
00006 //
00007 //
00008 //  Declaration of the following classes:
00009 //    cConfiguration
00010 //
00011 //==========================================================================
00012 
00013 /*--------------------------------------------------------------*
00014   Copyright (C) 1992-2008 Andras Varga
00015   Copyright (C) 2006-2008 OpenSim Ltd.
00016 
00017   This file is distributed WITHOUT ANY WARRANTY. See the file
00018   `license' for details on this and other legal matters.
00019 *--------------------------------------------------------------*/
00020 
00021 #ifndef __CCONFIGURATION_H
00022 #define __CCONFIGURATION_H
00023 
00024 #include <vector>
00025 #include "simkerneldefs.h"
00026 #include "cobject.h"
00027 
00028 NAMESPACE_BEGIN
00029 
00030 class cConfigOption;
00031 
00035 #define CFGNAME_GENERAL "General"
00036 
00042 #define CFGVAR_RUNID            "runid"
00043 #define CFGVAR_INIFILE          "inifile"
00044 #define CFGVAR_CONFIGNAME       "configname"
00045 #define CFGVAR_RUNNUMBER        "runnumber"
00046 #define CFGVAR_NETWORK          "network"
00047 #define CFGVAR_EXPERIMENT       "experiment"
00048 #define CFGVAR_MEASUREMENT      "measurement"
00049 #define CFGVAR_REPLICATION      "replication"
00050 #define CFGVAR_PROCESSID        "processid"
00051 #define CFGVAR_DATETIME         "datetime"
00052 #define CFGVAR_RESULTDIR        "resultdir"
00053 #define CFGVAR_REPETITION       "repetition"
00054 #define CFGVAR_SEEDSET          "seedset"
00055 #define CFGVAR_ITERATIONVARS    "iterationvars"   // without $repetition
00056 #define CFGVAR_ITERATIONVARS2   "iterationvars2"  // with $repetition
00057 
00058 
00076 class SIM_API cConfiguration : public cObject
00077 {
00078   public:
00082     class KeyValue {
00083       public:
00084         virtual ~KeyValue() {}
00085         virtual const char *getKey() const = 0;
00086         virtual const char *getValue() const = 0;
00087         virtual const char *getBaseDirectory() const = 0;
00088     };
00089 
00090   public:
00097     virtual const char *getConfigValue(const char *key) const = 0;
00098 
00109     virtual const KeyValue& getConfigEntry(const char *key) const = 0;
00110 
00116     virtual const char *getPerObjectConfigValue(const char *objectFullPath, const char *keySuffix) const = 0;
00117 
00128     virtual const KeyValue& getPerObjectConfigEntry(const char *objectFullPath, const char *keySuffix) const = 0;
00130 
00133     static bool parseBool(const char *s, const char *defaultValue, bool fallbackValue=false);
00134     static long parseLong(const char *s, const char *defaultValue, long fallbackValue=0);
00135     static double parseDouble(const char *s, const char *unit, const char *defaultValue, double fallbackValue=0);
00136     static std::string parseString(const char *s, const char *defaultValue, const char *fallbackValue="");
00137     static std::string parseFilename(const char *s, const char *baseDir, const char *defaultValue);
00138     static std::vector<std::string> parseFilenames(const char *s, const char *baseDir, const char *defaultValue);
00139     static std::string adjustPath(const char *s, const char *baseDir, const char *defaultValue);
00141 
00148     virtual const char *getAsCustom(cConfigOption *option, const char *fallbackValue=NULL);
00149 
00154     virtual bool getAsBool(cConfigOption *option, bool fallbackValue=false);
00155 
00160     virtual long getAsInt(cConfigOption *option, long fallbackValue=0);
00161 
00166     virtual double getAsDouble(cConfigOption *option, double fallbackValue=0);
00167 
00172     virtual std::string getAsString(cConfigOption *option, const char *fallbackValue="");
00173 
00179     virtual std::string getAsFilename(cConfigOption *option);
00180 
00187     virtual std::vector<std::string> getAsFilenames(cConfigOption *option);
00188 
00195     virtual std::string getAsPath(cConfigOption *option);
00197 
00204     virtual const char *getAsCustom(const char *objectFullPath, cConfigOption *option, const char *fallbackValue=NULL);
00205 
00210     virtual bool getAsBool(const char *objectFullPath, cConfigOption *option, bool fallbackValue=false);
00211 
00216     virtual long getAsInt(const char *objectFullPath, cConfigOption *option, long fallbackValue=0);
00217 
00222     virtual double getAsDouble(const char *objectFullPath, cConfigOption *option, double fallbackValue=0);
00223 
00228     virtual std::string getAsString(const char *objectFullPath, cConfigOption *option, const char *fallbackValue="");
00229 
00235     virtual std::string getAsFilename(const char *objectFullPath, cConfigOption *option);
00236 
00243     virtual std::vector<std::string> getAsFilenames(const char *objectFullPath, cConfigOption *option);
00244 
00251     virtual std::string getAsPath(const char *objectFullPath, cConfigOption *option);
00253 
00260     virtual const char *substituteVariables(const char *value) = 0;
00262 };
00263 
00264 
00280 class SIM_API cConfigurationEx : public cConfiguration
00281 {
00282   public:
00289     virtual void initializeFrom(cConfiguration *bootConfig) = 0;
00290 
00295     virtual const char *getFileName() const = 0;
00296 
00309     virtual void validate(const char *ignorableConfigKeys=NULL) const = 0;
00310 
00316     virtual std::vector<std::string> getConfigNames() = 0;
00317 
00323     virtual void activateConfig(const char *configName, int runNumber=0) = 0;
00324 
00328     virtual std::string getConfigDescription(const char *configName) const = 0;
00329 
00337     virtual std::vector<std::string> getBaseConfigs(const char *configName) const = 0;
00338 
00344     virtual std::vector<std::string> getConfigChain(const char * configName) const = 0;
00345 
00351     virtual int getNumRunsInConfig(const char *configName) const = 0;
00352 
00360     virtual std::vector<std::string> unrollConfig(const char *configName, bool detailed=true) const = 0;
00361 
00365     virtual const char *getActiveConfigName() const = 0;
00366 
00371     virtual int getActiveRunNumber() const = 0;
00372 
00384     virtual const char *getVariable(const char *varname) const = 0;
00385 
00389     virtual std::vector<const char *> getIterationVariableNames() const = 0;
00390 
00395     virtual std::vector<const char *> getPredefinedVariableNames() const = 0;
00396 
00401     virtual const char *getVariableDescription(const char *varname) const = 0;
00402 
00406     virtual void dump() const = 0;
00408 
00411 
00416     virtual std::vector<const char *> getMatchingConfigKeys(const char *pattern) const = 0;
00417 
00424     virtual const char *getParameterValue(const char *moduleFullPath, const char *paramName, bool hasDefaultValue) const = 0;
00425 
00436     virtual const KeyValue& getParameterEntry(const char *moduleFullPath, const char *paramName, bool hasDefaultValue) const = 0;
00437 
00445     virtual std::vector<const char *> getParameterKeyValuePairs() const = 0;
00446 
00454     virtual std::vector<const char *> getMatchingPerObjectConfigKeys(const char *objectFullPath, const char *keySuffixPattern) const = 0;
00455 
00461     virtual std::vector<const char *> getMatchingPerObjectConfigKeySuffixes(const char *objectFullPath, const char *keySuffixPattern) const = 0;
00463 };
00464 
00465 NAMESPACE_END
00466 
00467 #endif
00468 
00469 
Generated on Tue Dec 2 11:16:27 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3