cparimpl.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __CPARIMPL_H
00019 #define __CPARIMPL_H
00020
00021 #include "cpar.h"
00022 #include "cexpression.h"
00023 #include "cstringpool.h"
00024 #include "cexception.h"
00025
00026 NAMESPACE_BEGIN
00027
00028 class cExpression;
00029 class cXMLElement;
00030 class cProperties;
00031 class cComponent;
00032
00033
00045 class SIM_API cParImpl : public cNamedObject
00046 {
00047 protected:
00048
00049 enum {
00050 FL_ISVOLATILE = 4,
00051 FL_ISEXPR = 8,
00052 FL_ISSHARED = 16,
00053 FL_CONTAINSVALUE = 32,
00054 FL_ISSET = 64
00055 };
00056
00057 private:
00058
00059 const char *unitp;
00060
00061
00062 static long total_parimpl_objs;
00063 static long live_parimpl_objs;
00064 static cStringPool unitStringPool;
00065
00066 private:
00067 void copy(const cParImpl& other);
00068
00069 public:
00070 typedef cPar::Type Type;
00071
00072 protected:
00073 cNEDValue evaluate(cExpression *expr, cComponent *context) const;
00074
00075 public:
00078
00082 explicit cParImpl();
00083
00087 cParImpl(const cParImpl& other) : cNamedObject(other) {unitp = NULL; copy(other);}
00088
00092 virtual ~cParImpl();
00093
00097 cParImpl& operator=(const cParImpl& otherpar);
00099
00106 virtual std::string info() const;
00107
00111 virtual std::string detailedInfo() const;
00112
00116 virtual cParImpl *dup() const;
00117
00121 virtual void parsimPack(cCommBuffer *buffer);
00122
00126 virtual void parsimUnpack(cCommBuffer *buffer);
00128
00134 virtual Type getType() const = 0;
00135
00139 virtual bool isNumeric() const = 0;
00140
00144 virtual bool isVolatile() const {return flags & FL_ISVOLATILE;}
00145
00151 virtual bool isExpression() const {return flags & FL_ISEXPR;}
00152
00156 virtual bool isShared() const {return flags & FL_ISSHARED;}
00157
00162 virtual bool containsValue() const {return flags & FL_CONTAINSVALUE;}
00163
00169 virtual bool isSet() const {return flags & FL_ISSET;}
00170
00175 virtual void setIsVolatile(bool f) {setFlag(FL_ISVOLATILE,f);}
00176
00180 virtual void setIsShared(bool f) {setFlag(FL_ISSHARED,f);}
00181
00185 virtual void setIsSet(bool f) {setFlag(FL_ISSET,f);}
00186
00192 virtual const char *getUnit() const;
00193
00197 virtual void setUnit(const char *s);
00199
00202
00206 virtual void setBoolValue(bool b) = 0;
00207
00211 virtual void setLongValue(long l) = 0;
00212
00216 virtual void setDoubleValue(double d) = 0;
00217
00223 virtual void setStringValue(const char *s) = 0;
00224
00228 virtual void setStringValue(const std::string& s) {setStringValue(s.c_str());}
00229
00233 virtual void setXMLValue(cXMLElement *node) = 0;
00234
00243 virtual void setExpression(cExpression *e) = 0;
00245
00248
00252 virtual bool boolValue(cComponent *context) const = 0;
00253
00257 virtual long longValue(cComponent *context) const = 0;
00258
00262 virtual double doubleValue(cComponent *context) const = 0;
00263
00272 virtual const char *stringValue(cComponent *context) const = 0;
00273
00277 virtual std::string stdstringValue(cComponent *context) const = 0;
00278
00282 virtual cXMLElement *xmlValue(cComponent *context) const = 0;
00283
00287 virtual cExpression *getExpression() const = 0;
00289
00292
00297 virtual void convertToConst(cComponent *context) = 0;
00298
00302 virtual bool containsConstSubexpressions() const;
00303
00308 virtual void evaluateConstSubexpressions(cComponent *context);
00309
00313 virtual std::string str() const = 0;
00314
00320 virtual void parse(const char *text) = 0;
00321
00325 static cParImpl *createWithType(Type type);
00327
00330
00335 virtual int compare(const cParImpl *other) const;
00337
00347 static long getTotalParImplObjectCount() {return total_parimpl_objs;}
00348
00355 static long getLiveParImplObjectCount() {return live_parimpl_objs;}
00356
00361 static void resetParImplObjectCounters() {total_parimpl_objs=live_parimpl_objs=0L;}
00363 };
00364
00365 NAMESPACE_END
00366
00367
00368 #endif
00369
00370