1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef ModelAPI_Attribute_H_
22 #define ModelAPI_Attribute_H_
28 class ModelAPI_Object;
30 /**\class ModelAPI_Attribute
32 * \brief Generic attribute of the Object.
34 class ModelAPI_Attribute
36 ///< needed here to emit signal that feature changed on change of the attribute
37 std::shared_ptr<ModelAPI_Object> myObject;
38 std::string myID; ///< identifier of this attribute in Data class
40 // accessible from the attributes
41 bool myIsInitialized; ///< is some value assigned to this attribute
42 bool mySetInitializedBlocked; ///< is initialized blocked
43 bool myIsArgument; ///< is this attribute used as an argument for execution
44 bool myIsImmutable; ///< is this attribute can be changed programmatically (e.g. by constraint)
48 /// Returns the type of this class of attributes, not static method
49 MODELAPI_EXPORT virtual std::string attributeType() = 0;
51 /// To virtually destroy the fields of successors
52 MODELAPI_EXPORT virtual ~ModelAPI_Attribute();
54 /// Sets the owner of this attribute
55 MODELAPI_EXPORT virtual void setObject(const std::shared_ptr<ModelAPI_Object>& theObject);
57 /// Returns the owner of this attribute
58 MODELAPI_EXPORT const std::shared_ptr<ModelAPI_Object>& owner() const;
60 /// Returns true if attribute was initialized by some value
61 MODELAPI_EXPORT virtual bool isInitialized();
63 /// Makes attribute initialized
64 MODELAPI_EXPORT void setInitialized();
66 /// Blocks sending "attribute updated" if theBlock is true
67 /// \param theBlock a block value
68 /// \return the previous block value
69 MODELAPI_EXPORT bool blockSetInitialized(const bool theBlock);
71 /// Set this attribute is argument for result
72 /// (change of this attribute requires update of result).
73 /// By default it is true.
74 MODELAPI_EXPORT void setIsArgument(const bool theFlag);
76 /// Returns true if attribute causes the result change
77 MODELAPI_EXPORT bool isArgument();
79 /// Immutable argument can not be changed programmatically (e.g. by constraint)
80 /// By default it is false.
81 /// Returns the previous state of the attribute's immutability.
82 MODELAPI_EXPORT bool setImmutable(const bool theFlag);
84 /// Returns true if can not be changed programmatically
85 MODELAPI_EXPORT bool isImmutable();
87 /// ID of the attribute in Data
88 MODELAPI_EXPORT const std::string& id() const;
90 /// Resets attribute to deafult state.
91 MODELAPI_EXPORT virtual void reset();
94 /// Objects are created for features automatically
95 MODELAPI_EXPORT ModelAPI_Attribute();
97 /// Sets the ID of the attribute in Data (called from Data)
98 MODELAPI_EXPORT virtual void setID(const std::string theID);
100 /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
101 MODELAPI_EXPORT virtual void reinit();
103 friend class Model_Data;
104 friend class Model_Objects;
107 //! Pointer on attribute object
108 typedef std::shared_ptr<ModelAPI_Attribute> AttributePtr;