Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / ModelAPI / ModelAPI_Attribute.h
1 // File:        ModelAPI_Attribute.h
2 // Created:     2 Apr 2014
3 // Author:      Mikhail PONIKAROV
4
5 #ifndef ModelAPI_Attribute_HeaderFile
6 #define ModelAPI_Attribute_HeaderFile
7
8 #include "ModelAPI.h"
9 #include <string>
10 #include <boost/shared_ptr.hpp>
11
12 class ModelAPI_Feature;
13
14 /**\class ModelAPI_Attribute
15  * \ingroup DataModel
16  * \brief Generic attribute of the Object.
17  */
18 class ModelAPI_Attribute
19 {
20   ///< needed here to emit signal that feature changed on change of the attribute
21   boost::shared_ptr<ModelAPI_Feature> myFeature;
22 protected: // accessible from the attributes
23   bool myIsInitialized;
24 public:
25   
26   /// Returns the type of this class of attributes, not static method
27   MODELAPI_EXPORT virtual std::string attributeType() = 0;
28
29   /// To virtually destroy the fields of successors
30   MODELAPI_EXPORT virtual ~ModelAPI_Attribute() {}
31
32   /// Sets the owner of this attribute
33   MODELAPI_EXPORT void setFeature(const boost::shared_ptr<ModelAPI_Feature>& theFeature)
34     {myFeature = theFeature;}
35
36   /// Returns the owner of this attribute
37   MODELAPI_EXPORT const boost::shared_ptr<ModelAPI_Feature>& owner()
38   {return myFeature;}
39
40   /// Returns true if attribute was  initialized by some value
41   MODELAPI_EXPORT bool isInitialized() {return myIsInitialized;}
42
43   /// Makes attribute initialized
44   MODELAPI_EXPORT void setInitialized() {myIsInitialized = true;}
45
46 protected:
47   /// Objects are created for features automatically
48   ModelAPI_Attribute() {myIsInitialized = false;}
49
50 };
51
52 #endif