cproperty.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __CPROPERTY_H
00017 #define __CPROPERTY_H
00018
00019 #include <map>
00020 #include <vector>
00021 #include "simkerneldefs.h"
00022 #include "globals.h"
00023 #include "cobject.h"
00024 #include "cstringpool.h"
00025 #include "cproperties.h"
00026
00027 NAMESPACE_BEGIN
00028
00029
00036 class SIM_API cProperty : public cNamedObject
00037 {
00038 public:
00039 static const char *DEFAULTKEY;
00040
00041 private:
00042 enum {
00043 FL_ISLOCKED = 4,
00044 FL_ISIMPLICIT = 8,
00045 };
00046
00047 protected:
00048
00049 static cStringPool stringPool;
00050
00051 cProperties *ownerp;
00052
00053 const char *propindex;
00054 mutable const char *propfullname;
00055
00056 typedef std::vector<const char *> CharPtrVector;
00057 CharPtrVector keyv;
00058 std::vector<CharPtrVector> valuesv;
00059
00060 private:
00061 void copy(const cProperty& other);
00062
00063 protected:
00064 static void releaseValues(CharPtrVector& vals);
00065 int findKey(const char *key) const;
00066 CharPtrVector& getValuesVector(const char *key) const;
00067
00068 public:
00069
00070
00071
00072 virtual void lock() {setFlag(FL_ISLOCKED, true);}
00073
00074
00075 virtual bool isLocked() const {return flags&FL_ISLOCKED;}
00076
00077
00078 virtual void setOwner(cProperties *p) {ownerp = p;}
00079
00080 public:
00083
00087 explicit cProperty(const char *name=NULL, const char *index=NULL);
00088
00092 cProperty(const cProperty& other) : cNamedObject(other) {setFlag(FL_ISLOCKED,false); propindex=propfullname=NULL; copy(other);}
00093
00097 virtual ~cProperty();
00098
00102 cProperty& operator=(const cProperty& other);
00104
00111 virtual void setName(const char *name);
00112
00116 virtual const char *getFullName() const;
00117
00121 virtual cProperty *dup() const {return new cProperty(*this);}
00122
00126 virtual std::string info() const;
00127
00131 virtual void parsimPack(cCommBuffer *buffer);
00132
00136 virtual void parsimUnpack(cCommBuffer *buffer);
00138
00145 virtual void setIndex(const char *index);
00146
00153 virtual const char *getIndex() const;
00154
00158 virtual void setIsImplicit(bool b);
00159
00165 virtual bool isImplicit() const;
00166
00171 virtual const std::vector<const char *>& getKeys() const;
00172
00177 virtual bool containsKey(const char *key) const;
00178
00183 virtual void addKey(const char *key);
00184
00191 virtual int getNumValues(const char *key) const;
00192
00201 virtual void setNumValues(const char *key, int size);
00202
00208 virtual const char *getValue(const char *key, int index=0) const;
00209
00219 virtual void setValue(const char *key, int index, const char *value);
00220
00224 virtual void erase(const char *key);
00226 };
00227
00228 NAMESPACE_END
00229
00230
00231 #endif
00232
00233