1 // File: ModelAPI_Attribute.h
3 // Author: Mikhail PONIKAROV
5 #ifndef ModelAPI_Attribute_H_
6 #define ModelAPI_Attribute_H_
10 #include <boost/shared_ptr.hpp>
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 boost::shared_ptr<ModelAPI_Object> myObject;
23 // accessible from the attributes
30 /// Returns the type of this class of attributes, not static method
31 MODELAPI_EXPORT virtual std::string attributeType() = 0;
33 /// To virtually destroy the fields of successors
34 MODELAPI_EXPORT virtual ~ModelAPI_Attribute()
38 /// Sets the owner of this attribute
39 MODELAPI_EXPORT virtual void setObject(const boost::shared_ptr<ModelAPI_Object>& theObject)
44 /// Returns the owner of this attribute
45 MODELAPI_EXPORT const boost::shared_ptr<ModelAPI_Object>& owner() const
50 /// Returns true if attribute was initialized by some value
51 MODELAPI_EXPORT bool isInitialized()
53 return myIsInitialized;
56 /// Makes attribute initialized
57 MODELAPI_EXPORT void setInitialized()
59 myIsInitialized = true;
62 /// Set this attribute is argument for result (change of this attribute requires update of result).
63 /// By default it is true.
64 MODELAPI_EXPORT void setIsArgument(const bool theFlag)
66 myIsArgument = theFlag;
69 /// Returns true if attribute causes the result change
70 MODELAPI_EXPORT bool isArgument()
75 /// Immutable argument can not be changed programaticaly (e.g. by constraint)
76 /// By default it is false.
77 /// Returns the previous state of the attribute's immutability.
78 MODELAPI_EXPORT bool setImmutable(const bool theFlag)
80 bool aResult = myIsImmutable;
81 myIsImmutable = theFlag;
85 /// Returns true if can not be changed programaticaly
86 MODELAPI_EXPORT bool isImmutable()
92 /// Objects are created for features automatically
95 myIsInitialized = false;
97 myIsImmutable = false;
102 //! Pointer on attribute object
103 typedef boost::shared_ptr<ModelAPI_Attribute> AttributePtr;