cproperties.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __CPROPERTIES_H
00017 #define __CPROPERTIES_H
00018
00019 #include "simkerneldefs.h"
00020 #include "globals.h"
00021 #include "cobject.h"
00022 #include <vector>
00023
00024 NAMESPACE_BEGIN
00025
00026 class cProperty;
00027
00028
00034 class SIM_API cProperties : public cObject
00035 {
00036 protected:
00037 bool islocked;
00038 int refcount;
00039 std::vector<cProperty *> propv;
00040
00041 private:
00042 void copy(const cProperties& other);
00043
00044 public:
00045
00046
00047
00048 virtual void lock();
00049
00050
00051 int addRef() {return ++refcount;}
00052 int removeRef() {return --refcount;}
00053
00054 public:
00060 explicit cProperties();
00061
00065 cProperties(const cProperties& other) : cObject(other) {refcount=0; islocked=false; copy(other);}
00066
00070 virtual ~cProperties();
00071
00075 cProperties& operator=(const cProperties& other);
00077
00083 virtual cProperties *dup() const {return new cProperties(*this);}
00084
00088 virtual const char *getName() const {return "properties";}
00089
00093 virtual std::string info() const;
00094
00098 virtual void parsimPack(cCommBuffer *buffer);
00099
00103 virtual void parsimUnpack(cCommBuffer *buffer);
00105
00111 virtual int getNumProperties() const {return propv.size();}
00112
00118 virtual const std::vector<const char *> getNames() const;
00119
00123 virtual cProperty *get(int k) const;
00124
00131 virtual cProperty *get(const char *name, const char *index=NULL) const;
00132
00149 virtual bool getAsBool(const char *name, const char *index=NULL) const;
00150
00157 virtual std::vector<const char *> getIndicesFor(const char *name) const;
00158
00162 virtual void add(cProperty *p);
00163
00167 virtual void remove(int k);
00169 };
00170
00171 NAMESPACE_END
00172
00173
00174 #endif
00175
00176