1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModelAPI_Attribute.h
5 // Author: Mikhail PONIKAROV
7 #ifndef ModelAPI_Attribute_H_
8 #define ModelAPI_Attribute_H_
14 class ModelAPI_Object;
16 /**\class ModelAPI_Attribute
18 * \brief Generic attribute of the Object.
20 class ModelAPI_Attribute
22 ///< needed here to emit signal that feature changed on change of the attribute
23 std::shared_ptr<ModelAPI_Object> myObject;
24 std::string myID; ///< identifier of this attribute in Data class
26 // accessible from the attributes
27 bool myIsInitialized; ///< is some value assigned to this attribute
28 bool myIsArgument; ///< is this attribute used as an argument for execution
29 bool myIsImmutable; ///< is this attribute can be changed programmatically (e.g. by constraint)
33 /// Returns the type of this class of attributes, not static method
34 MODELAPI_EXPORT virtual std::string attributeType() = 0;
36 /// To virtually destroy the fields of successors
37 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);
42 /// Returns the owner of this attribute
43 MODELAPI_EXPORT const std::shared_ptr<ModelAPI_Object>& owner() const;
45 /// Returns true if attribute was initialized by some value
46 MODELAPI_EXPORT bool isInitialized();
48 /// Makes attribute initialized
49 MODELAPI_EXPORT void setInitialized();
51 /// Set this attribute is argument for result (change of this attribute requires update of result).
52 /// By default it is true.
53 MODELAPI_EXPORT void setIsArgument(const bool theFlag);
55 /// Returns true if attribute causes the result change
56 MODELAPI_EXPORT bool isArgument();
58 /// Immutable argument can not be changed programaticaly (e.g. by constraint)
59 /// By default it is false.
60 /// Returns the previous state of the attribute's immutability.
61 MODELAPI_EXPORT bool setImmutable(const bool theFlag);
63 /// Returns true if can not be changed programaticaly
64 MODELAPI_EXPORT bool isImmutable();
66 /// ID of the attribute in Data
67 MODELAPI_EXPORT const std::string& id() const;
70 /// Objects are created for features automatically
71 MODELAPI_EXPORT ModelAPI_Attribute();
73 /// Sets the ID of the attribute in Data (called from Data)
74 MODELAPI_EXPORT void setID(const std::string theID);
76 friend class Model_Data;
79 //! Pointer on attribute object
80 typedef std::shared_ptr<ModelAPI_Attribute> AttributePtr;