Salome HOME
Issue #1860: fix end lines with spaces
[modules/shaper.git] / src / ModelAPI / ModelAPI_Attribute.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        ModelAPI_Attribute.h
4 // Created:     2 Apr 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef ModelAPI_Attribute_H_
8 #define ModelAPI_Attribute_H_
9
10 #include "ModelAPI.h"
11 #include <string>
12 #include <memory>
13
14 class ModelAPI_Object;
15
16 /**\class ModelAPI_Attribute
17  * \ingroup DataModel
18  * \brief Generic attribute of the Object.
19  */
20 class ModelAPI_Attribute
21 {
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
25  protected:
26   // accessible from the attributes
27   bool myIsInitialized; ///< is some value assigned to this attribute
28   bool mySetInitializedBlocked; ///< is initialized blocked
29   bool myIsArgument;    ///< is this attribute used as an argument for execution
30   bool myIsImmutable;   ///< is this attribute can be changed programmatically (e.g. by constraint)
31
32  public:
33
34   /// Returns the type of this class of attributes, not static method
35   MODELAPI_EXPORT virtual std::string attributeType() = 0;
36
37   /// To virtually destroy the fields of successors
38   MODELAPI_EXPORT virtual ~ModelAPI_Attribute();
39
40   /// Sets the owner of this attribute
41   MODELAPI_EXPORT virtual void setObject(const std::shared_ptr<ModelAPI_Object>& theObject);
42
43   /// Returns the owner of this attribute
44   MODELAPI_EXPORT const std::shared_ptr<ModelAPI_Object>& owner() const;
45
46   /// Returns true if attribute was  initialized by some value
47   MODELAPI_EXPORT virtual bool isInitialized();
48
49   /// Makes attribute initialized
50   MODELAPI_EXPORT void setInitialized();
51
52   /// Blocks sending "attribute updated" if theBlock is true
53   /// \param theBlock a block value
54   /// \return the previous block value
55   MODELAPI_EXPORT bool blockSetInitialized(const bool theBlock);
56
57   /// Set this attribute is argument for result
58   /// (change of this attribute requires update of result).
59   /// By default it is true.
60   MODELAPI_EXPORT void setIsArgument(const bool theFlag);
61
62   /// Returns true if attribute causes the result change
63   MODELAPI_EXPORT bool isArgument();
64
65   /// Immutable argument can not be changed programmatically (e.g. by constraint)
66   /// By default it is false.
67   /// Returns the previous state of the attribute's immutability.
68   MODELAPI_EXPORT bool setImmutable(const bool theFlag);
69
70   /// Returns true if can not be changed programmatically
71   MODELAPI_EXPORT bool isImmutable();
72
73   /// ID of the attribute in Data
74   MODELAPI_EXPORT const std::string& id() const;
75
76  protected:
77   /// Objects are created for features automatically
78   MODELAPI_EXPORT ModelAPI_Attribute();
79
80   /// Sets the ID of the attribute in Data (called from Data)
81   MODELAPI_EXPORT virtual void setID(const std::string theID);
82
83   /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
84   MODELAPI_EXPORT virtual void reinit();
85
86   friend class Model_Data;
87   friend class Model_Objects;
88 };
89
90 //! Pointer on attribute object
91 typedef std::shared_ptr<ModelAPI_Attribute> AttributePtr;
92
93 #endif