cconfigoption.h

00001 //==========================================================================
00002 //  CCONFIGOPTION.H - part of
00003 //                     OMNeT++/OMNEST
00004 //            Discrete System Simulation in C++
00005 //
00006 //==========================================================================
00007 
00008 /*--------------------------------------------------------------*
00009   Copyright (C) 1992-2008 Andras Varga
00010   Copyright (C) 2006-2008 OpenSim Ltd.
00011 
00012   This file is distributed WITHOUT ANY WARRANTY. See the file
00013   `license' for details on this and other legal matters.
00014 *--------------------------------------------------------------*/
00015 
00016 #ifndef __CCONFIGOPTION_H
00017 #define __CCONFIGOPTION_H
00018 
00019 #include <string>
00020 #include "cownedobject.h"
00021 
00022 NAMESPACE_BEGIN
00023 
00024 
00034 class SIM_API cConfigOption : public cNoncopyableOwnedObject
00035 {
00036   public:
00038     enum Type {
00039       CFG_BOOL,
00040       CFG_INT,
00041       CFG_DOUBLE,
00042       CFG_STRING,
00043       CFG_FILENAME,
00044       CFG_FILENAMES,
00045       CFG_PATH,
00046       CFG_CUSTOM
00047     };
00048 
00050     enum ObjectKind {
00051         KIND_NONE,
00052         KIND_MODULE,
00053         KIND_SIMPLE_MODULE,
00054         KIND_UNSPECIFIED_TYPE, // for 'typename' option (object is submodule/channel declared with 'like')
00055         KIND_PARAMETER,
00056         KIND_STATISTIC,
00057         KIND_SCALAR,
00058         KIND_VECTOR,
00059         KIND_OTHER
00060     };
00061 
00062     // note: option name (e.g. "sim-time-limit") is stored in object's name field
00063     bool isPerObject_;         // if true, entries must be in <object-full-path>.config-name format
00064     bool isGlobal_;            // if true, entries may only occur in the [General] section
00065     ObjectKind objectKind_;    // kind of the object if isPerObject is true, KIND_NONE otherwise
00066     Type type_;                // option data type
00067     std::string unit_;         // if numeric, its unit ("s") or empty string
00068     std::string defaultValue_; // the default value in string form
00069     std::string description_;  // help text
00070 
00071   public:
00077     cConfigOption(const char *name, bool isGlobal, Type type, const char *unit,
00078                const char *defaultValue, const char *description);
00079 
00083     cConfigOption(const char *name, ObjectKind kind, Type type, const char *unit,
00084                const char *defaultValue, const char *description);
00086 
00089     virtual std::string info() const;
00091 
00100     bool isPerObject() const {return isPerObject_;}
00101 
00106     bool isGlobal() const  {return isGlobal_;}
00107 
00112     ObjectKind getObjectKind() const {return objectKind_;}
00113 
00117     static const char *getObjectKindName(ObjectKind kind);
00118 
00122     Type getType() const  {return type_;}
00123 
00127     static const char *getTypeName(Type type);
00128 
00133     const char *getUnit() const  {return unit_.empty() ? NULL : unit_.c_str();}
00134 
00138     const char *getDefaultValue() const  {return defaultValue_.empty() ? NULL : defaultValue_.c_str();}
00139 
00144     const char *getDescription() const  {return description_.c_str();}
00146 };
00147 
00148 NAMESPACE_END
00149 
00150 
00151 #endif
00152 
00153 
Generated on Tue Dec 2 11:16:27 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3