DynamicProperty.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (c) 2009 Werner Mayer <wmayer[at]users.sourceforge.net>     *
00003  *                                                                         *
00004  *   This file is part of the FreeCAD CAx development system.              *
00005  *                                                                         *
00006  *   This library is free software; you can redistribute it and/or         *
00007  *   modify it under the terms of the GNU Library General Public           *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2 of the License, or (at your option) any later version.      *
00010  *                                                                         *
00011  *   This library  is distributed in the hope that it will be useful,      *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Library General Public License for more details.                  *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Library General Public     *
00017  *   License along with this library; see the file COPYING.LIB. If not,    *
00018  *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
00019  *   Suite 330, Boston, MA  02111-1307, USA                                *
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 } // namespace App
00121 
00122 #endif // APP_DYNAMICPROPERTY_H

Generated on Wed Nov 23 19:00:10 2011 for FreeCAD by  doxygen 1.6.1