00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include <string>
00029 #include <map>
00030 #include <vector>
00031 #include <iostream>
00032 #include <iomanip>
00033 #include <list>
00034 #include <exception>
00035
00036 using namespace std;
00037
00038 #ifndef ___PARAMETER_H___
00039 #define ___PARAMETER_H___
00040
00041
00089
00097 #define READ_OK 0
00098 #define OPEN_FAIL 1
00099 #define UNEXPECTED_EOF 2
00100 #define UNKNOWN_PARAM 4
00101
00102 #define MAX_LINE_LENGTH 256
00103
00104
00106
00107 class ParamManagerException : public exception
00108 {
00109 string Msg;
00110 public:
00111 ParamManagerException(const string &aMsg)
00112 : Msg(aMsg)
00113 {};
00114 virtual ~ParamManagerException() throw(){};
00115
00116 virtual const char* what() const throw()
00117 {
00118 return (string(exception::what()) + Msg).c_str();
00119 };
00120 };
00121
00123
00124 class ParameterData
00125 {
00126 protected:
00127 string Value;
00128 string Class;
00129 string Instance;
00130
00131 public:
00132 ParameterData();
00133 ParameterData(string aValue, string aClass, string aInstance);
00134
00135 void getValue(const string &aClass, const string &aInstance, unsigned int &MatchLevel, string &aValue);
00136
00137 bool operator==(const ParameterData& A);
00138
00139 friend ostream& operator<< ( ostream& os, const ParameterData& par );
00140 };
00141
00143
00144
00146 class GenericParameter
00147 {
00148 protected:
00149 string Name;
00150 string Comment;
00151 string Default;
00152 string Values;
00153
00154 list<ParameterData> Data;
00155
00156 string getValue(const string &aClass, const string &aInstance);
00157
00158 GenericParameter()
00159 {};
00160
00161 public:
00162 GenericParameter(string aName, string aComment, string aDefault, string aValues);
00163
00164 void setDefault(string aDefault);
00165
00166 void addValue(string aValue, string aClass, string aInstance) throw(ParamManagerException);
00167
00168 string getName();
00169
00170 virtual ~GenericParameter();
00171
00172 virtual void printTemplate(ostream& os, string Class, string Instance,
00173 bool Comments = true, bool CommentedOut = false);
00174 };
00175
00177
00178
00180
00191 class IntParameter : public GenericParameter
00192 {
00193 public:
00195
00201 IntParameter(string aName, string aComment, string aDefault, string aValues)
00202 : GenericParameter(aName, aComment, aDefault, aValues)
00203 {};
00204
00206
00210 int get(string aClass, string aInstance);
00211 };
00212
00214
00215
00217
00228 class DoubleParameter : public GenericParameter
00229 {
00230 public:
00232
00238 DoubleParameter(string aName, string aComment, string aDefault, string aValues)
00239 : GenericParameter(aName, aComment, aDefault, aValues)
00240 {};
00241
00243
00247 double get(string aClass, string aInstance);
00248 };
00249
00251
00252
00254
00265 class StringParameter : public GenericParameter
00266 {
00267 public:
00269
00275 StringParameter(string aName, string aComment, string aDefault, string aValues)
00276 : GenericParameter(aName, aComment, aDefault, aValues)
00277 {};
00278
00280
00284 string get(string aClass, string aInstance);
00285 };
00286
00287
00289
00290
00292
00306 class EnumParameter : public GenericParameter
00307 {
00308 protected:
00309 map<string, int> NameToValue;
00310 map<int, string> ValueToName;
00311
00312 public:
00314
00320 EnumParameter(string aName,
00321 string aComment,
00322 string aDefault,
00323 string aValues
00324 );
00325
00327
00331 int get(string aClass, string aInstance);
00332 };
00333
00335
00336
00338
00358 class BitmaskParameter : public GenericParameter
00359 {
00360 protected:
00361 map<string, int> NameToValue;
00362 map<int, string> ValueToName;
00363
00364 public:
00366
00374 BitmaskParameter(string aName, string aComment, string aDefault, string aValues);
00375
00377
00381 int get(string aClass, string aInstance);
00382 };
00383
00385
00386 #endif
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410