Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[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_H_
6 #define ModelAPI_Attribute_H_
7
8 #include "ModelAPI.h"
9 #include <string>
10 #include <boost/shared_ptr.hpp>
11
12 class ModelAPI_Object;
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_Object> myObject;
22  protected:
23   // accessible from the attributes
24   bool myIsInitialized;
25   bool myIsArgument;
26  public:
27
28   /// Returns the type of this class of attributes, not static method
29   MODELAPI_EXPORT virtual std::string attributeType() = 0;
30
31   /// To virtually destroy the fields of successors
32   MODELAPI_EXPORT virtual ~ModelAPI_Attribute()
33   {
34   }
35
36   /// Sets the owner of this attribute
37   MODELAPI_EXPORT void setObject(const boost::shared_ptr<ModelAPI_Object>& theObject)
38   {
39     myObject = theObject;
40   }
41
42   /// Returns the owner of this attribute
43   MODELAPI_EXPORT const boost::shared_ptr<ModelAPI_Object>& owner()
44   {
45     return myObject;
46   }
47
48   /// Returns true if attribute was  initialized by some value
49   MODELAPI_EXPORT bool isInitialized()
50   {
51     return myIsInitialized;
52   }
53
54   /// Makes attribute initialized
55   MODELAPI_EXPORT void setInitialized()
56   {
57     myIsInitialized = true;
58   }
59
60   /// Set this attribute is argument for result (change of this attribute requires update of result).
61   /// By default it is true.
62   MODELAPI_EXPORT void setIsArgument(const bool theFlag)
63   {
64     myIsArgument = theFlag;
65   }
66
67   /// Returns true if attribute causes the result change
68   MODELAPI_EXPORT bool isArgument()
69   {
70     return myIsArgument;
71   }
72
73  protected:
74   /// Objects are created for features automatically
75   ModelAPI_Attribute()
76   {
77     myIsInitialized = false;
78     myIsArgument = true;
79   }
80
81 };
82
83 //! Pointer on attribute object
84 typedef boost::shared_ptr<ModelAPI_Attribute> AttributePtr;
85
86 #endif