1 // File: ModelAPI_Attribute.h
3 // Author: Mikhail PONIKAROV
5 #ifndef ModelAPI_Attribute_H_
6 #define ModelAPI_Attribute_H_
12 class ModelAPI_Object;
14 /**\class ModelAPI_Attribute
16 * \brief Generic attribute of the Object.
18 class ModelAPI_Attribute
20 ///< needed here to emit signal that feature changed on change of the attribute
21 std::shared_ptr<ModelAPI_Object> myObject;
22 std::string myID; ///< identifier of this attribute in Data class
24 // accessible from the attributes
25 bool myIsInitialized; ///< is some value assigned to this attribute
26 bool myIsArgument; ///< is this attribute used as an argument for execution
27 bool myIsImmutable; ///< is this attribute can be changed programmatically (e.g. by constraint)
31 /// Returns the type of this class of attributes, not static method
32 MODELAPI_EXPORT virtual std::string attributeType() = 0;
34 /// To virtually destroy the fields of successors
35 MODELAPI_EXPORT virtual ~ModelAPI_Attribute()
39 /// Sets the owner of this attribute
40 MODELAPI_EXPORT virtual void setObject(const std::shared_ptr<ModelAPI_Object>& theObject)
45 /// Returns the owner of this attribute
46 MODELAPI_EXPORT const std::shared_ptr<ModelAPI_Object>& owner() const
51 /// Returns true if attribute was initialized by some value
52 MODELAPI_EXPORT bool isInitialized()
54 return myIsInitialized;
57 /// Makes attribute initialized
58 MODELAPI_EXPORT void setInitialized()
60 myIsInitialized = true;
63 /// Set this attribute is argument for result (change of this attribute requires update of result).
64 /// By default it is true.
65 MODELAPI_EXPORT void setIsArgument(const bool theFlag)
67 myIsArgument = theFlag;
70 /// Returns true if attribute causes the result change
71 MODELAPI_EXPORT bool isArgument()
76 /// Immutable argument can not be changed programaticaly (e.g. by constraint)
77 /// By default it is false.
78 /// Returns the previous state of the attribute's immutability.
79 MODELAPI_EXPORT bool setImmutable(const bool theFlag)
81 bool aResult = myIsImmutable;
82 myIsImmutable = theFlag;
86 /// Returns true if can not be changed programaticaly
87 MODELAPI_EXPORT bool isImmutable()
92 /// ID of the attribute in Data
93 MODELAPI_EXPORT const std::string& id() const
99 /// Objects are created for features automatically
102 myIsInitialized = false;
104 myIsImmutable = false;
107 /// Sets the ID of the attribute in Data (called from Data)
108 MODELAPI_EXPORT void setID(const std::string theID)
113 friend class Model_Data;
116 //! Pointer on attribute object
117 typedef std::shared_ptr<ModelAPI_Attribute> AttributePtr;