DynamicProperty.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef APP_DYNAMICPROPERTY_H
00025 #define APP_DYNAMICPROPERTY_H
00026
00027 #include <Base/Persistence.h>
00028 #include <map>
00029 #include <vector>
00030 #include <string>
00031
00032 namespace Base {
00033 class Writer;
00034 class XMLWriter;
00035 }
00036
00037 namespace App
00038 {
00039 class Property;
00040 class PropertyContainer;
00041
00046 class AppExport DynamicProperty : public Base::Persistence
00047 {
00048 public:
00049 struct PropData {
00050 Property* property;
00051 std::string group;
00052 std::string doc;
00053 short attr;
00054 bool readonly;
00055 bool hidden;
00056 };
00057
00058 DynamicProperty(PropertyContainer* pc);
00059 virtual ~DynamicProperty();
00060
00063
00064 void getPropertyList(std::vector<Property*> &List) const;
00066 void getPropertyMap(std::map<std::string,Property*> &Map) const;
00068 Property *getPropertyByName(const char* name) const;
00070 Property *getDynamicPropertyByName(const char* name) const;
00071 Property* addDynamicProperty(const char* type, const char* name=0, const char* group=0,
00072 const char* doc=0, short attr=0, bool ro=false, bool hidden=false);
00073 std::vector<std::string> getDynamicPropertyNames() const;
00074 void addDynamicProperties(const PropertyContainer*);
00076 const char* getName(const Property* prop) const;
00078
00081
00082 short getPropertyType(const Property* prop) const;
00084 short getPropertyType(const char *name) const;
00086 const char* getPropertyGroup(const Property* prop) const;
00088 const char* getPropertyGroup(const char *name) const;
00090 const char* getPropertyDocumentation(const Property* prop) const;
00092 const char* getPropertyDocumentation(const char *name) const;
00094 bool isReadOnly(const Property* prop) const;
00096 bool isReadOnly(const char *name) const;
00098 bool isHidden(const Property* prop) const;
00100 bool isHidden(const char *name) const;
00102
00105 void Save (Base::Writer &writer) const;
00106 void Restore(Base::XMLReader &reader);
00107 unsigned int getMemSize (void) const;
00109
00110 private:
00112 std::string encodeAttribute(const std::string&) const;
00113 std::string getUniquePropertyName(const char *Name) const;
00114
00115 private:
00116 PropertyContainer* pc;
00117 std::map<std::string,PropData> props;
00118 };
00119
00120 }
00121
00122 #endif // APP_DYNAMICPROPERTY_H