1 // Copyright (C) 2014-2023 CEA, EDF
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef ModelAPI_Attribute_H_
21 #define ModelAPI_Attribute_H_
27 class ModelAPI_Object;
29 /**\class ModelAPI_Attribute
31 * \brief Generic attribute of the Object.
33 class ModelAPI_Attribute
35 ///< needed here to emit signal that feature changed on change of the attribute
36 std::shared_ptr<ModelAPI_Object> myObject;
37 std::string myID; ///< identifier of this attribute in Data class
39 // accessible from the attributes
40 bool myIsInitialized; ///< is some value assigned to this attribute
41 bool mySetInitializedBlocked; ///< is initialized blocked
42 bool myIsArgument; ///< is this attribute used as an argument for execution
43 bool myIsImmutable; ///< is this attribute can be changed programmatically (e.g. by constraint)
47 /// Returns the type of this class of attributes, not static method
48 MODELAPI_EXPORT virtual std::string attributeType() = 0;
50 /// To virtually destroy the fields of successors
51 MODELAPI_EXPORT virtual ~ModelAPI_Attribute();
53 /// Sets the owner of this attribute
54 MODELAPI_EXPORT virtual void setObject(const std::shared_ptr<ModelAPI_Object>& theObject);
56 /// Returns the owner of this attribute
57 MODELAPI_EXPORT const std::shared_ptr<ModelAPI_Object>& owner() const;
59 /// Returns true if attribute was initialized by some value
60 MODELAPI_EXPORT virtual bool isInitialized();
62 /// Makes attribute initialized
63 MODELAPI_EXPORT void setInitialized();
65 /// Blocks sending "attribute updated" if theBlock is true
66 /// \param theBlock a block value
67 /// \return the previous block value
68 MODELAPI_EXPORT bool blockSetInitialized(const bool theBlock);
70 /// Set this attribute is argument for result
71 /// (change of this attribute requires update of result).
72 /// By default it is true.
73 MODELAPI_EXPORT void setIsArgument(const bool theFlag);
75 /// Returns true if attribute causes the result change
76 MODELAPI_EXPORT bool isArgument();
78 /// Immutable argument can not be changed programmatically (e.g. by constraint)
79 /// By default it is false.
80 /// Returns the previous state of the attribute's immutability.
81 MODELAPI_EXPORT bool setImmutable(const bool theFlag);
83 /// Returns true if can not be changed programmatically
84 MODELAPI_EXPORT bool isImmutable();
86 /// ID of the attribute in Data
87 MODELAPI_EXPORT const std::string& id() const;
89 /// Resets attribute to deafult state.
90 MODELAPI_EXPORT virtual void reset();
93 /// Objects are created for features automatically
94 MODELAPI_EXPORT ModelAPI_Attribute();
96 /// Sets the ID of the attribute in Data (called from Data)
97 MODELAPI_EXPORT virtual void setID(const std::string theID);
99 /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
100 MODELAPI_EXPORT virtual void reinit();
102 friend class Model_Data;
103 friend class Model_Objects;
106 //! Pointer on attribute object
107 typedef std::shared_ptr<ModelAPI_Attribute> AttributePtr;