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_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: // accessible from the attributes
23   bool myIsInitialized;
24   bool myIsArgument;
25 public:
26   
27   /// Returns the type of this class of attributes, not static method
28   MODELAPI_EXPORT virtual std::string attributeType() = 0;
29
30   /// To virtually destroy the fields of successors
31   MODELAPI_EXPORT virtual ~ModelAPI_Attribute() {}
32
33   /// Sets the owner of this attribute
34   MODELAPI_EXPORT void setObject(const boost::shared_ptr<ModelAPI_Object>& theObject)
35     {myObject = theObject;}
36
37   /// Returns the owner of this attribute
38   MODELAPI_EXPORT const boost::shared_ptr<ModelAPI_Object>& owner()
39   {return myObject;}
40
41   /// Returns true if attribute was  initialized by some value
42   MODELAPI_EXPORT bool isInitialized() {return myIsInitialized;}
43
44   /// Makes attribute initialized
45   MODELAPI_EXPORT void setInitialized() {myIsInitialized = true;}
46
47   /// Set this attribute is argument for result (change of this attribute requires update of result).
48   /// By default it is true.
49   MODELAPI_EXPORT void setIsArgument(const bool theFlag) {myIsArgument = theFlag;}
50
51   /// Returns true if attribute causes the result change
52   MODELAPI_EXPORT bool isArgument() {return myIsArgument;}
53
54 protected:
55   /// Objects are created for features automatically
56   ModelAPI_Attribute() {myIsInitialized = false; myIsArgument = true;}
57
58 };
59
60 #endif