SHAPER  9.12.0
ModelAPI_Attribute.h
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef ModelAPI_Attribute_H_
21 #define ModelAPI_Attribute_H_
22 
23 #include "ModelAPI.h"
24 #include <string>
25 #include <memory>
26 
27 class ModelAPI_Object;
28 
34 {
36  std::shared_ptr<ModelAPI_Object> myObject;
37  std::string myID;
38  protected:
39  // accessible from the attributes
42  bool myIsArgument;
44 
45  public:
46 
48  MODELAPI_EXPORT virtual std::string attributeType() = 0;
49 
51  MODELAPI_EXPORT virtual ~ModelAPI_Attribute();
52 
54  MODELAPI_EXPORT virtual void setObject(const std::shared_ptr<ModelAPI_Object>& theObject);
55 
57  MODELAPI_EXPORT const std::shared_ptr<ModelAPI_Object>& owner() const;
58 
60  MODELAPI_EXPORT virtual bool isInitialized();
61 
63  MODELAPI_EXPORT void setInitialized();
64 
68  MODELAPI_EXPORT bool blockSetInitialized(const bool theBlock);
69 
73  MODELAPI_EXPORT void setIsArgument(const bool theFlag);
74 
76  MODELAPI_EXPORT bool isArgument();
77 
81  MODELAPI_EXPORT bool setImmutable(const bool theFlag);
82 
84  MODELAPI_EXPORT bool isImmutable();
85 
87  MODELAPI_EXPORT const std::string& id() const;
88 
90  MODELAPI_EXPORT virtual void reset();
91 
92  protected:
94  MODELAPI_EXPORT ModelAPI_Attribute();
95 
97  MODELAPI_EXPORT virtual void setID(const std::string theID);
98 
100  MODELAPI_EXPORT virtual void reinit();
101 
102  friend class Model_Data;
103  friend class Model_Objects;
104 };
105 
107 typedef std::shared_ptr<ModelAPI_Attribute> AttributePtr;
108 
109 #endif
Generic attribute of the Object.
Definition: ModelAPI_Attribute.h:34
bool myIsArgument
is this attribute used as an argument for execution
Definition: ModelAPI_Attribute.h:42
virtual void setID(const std::string theID)
Sets the ID of the attribute in Data (called from Data)
Definition: ModelAPI_Attribute.cpp:95
virtual std::string attributeType()=0
Returns the type of this class of attributes, not static method.
ModelAPI_Attribute()
Objects are created for features automatically.
Definition: ModelAPI_Attribute.cpp:86
virtual void reset()
Resets attribute to deafult state.
Definition: ModelAPI_Attribute.cpp:102
bool myIsImmutable
is this attribute can be changed programmatically (e.g. by constraint)
Definition: ModelAPI_Attribute.h:43
virtual bool isInitialized()
Returns true if attribute was initialized by some value.
Definition: ModelAPI_Attribute.cpp:39
bool blockSetInitialized(const bool theBlock)
Blocks sending "attribute updated" if theBlock is true.
Definition: ModelAPI_Attribute.cpp:50
virtual void reinit()
Reinitializes the internal state of the attribute (may be needed on undo/redo, abort,...
Definition: ModelAPI_Attribute.cpp:100
bool isArgument()
Returns true if attribute causes the result change.
Definition: ModelAPI_Attribute.cpp:64
bool myIsInitialized
is some value assigned to this attribute
Definition: ModelAPI_Attribute.h:40
bool isImmutable()
Returns true if can not be changed programmatically.
Definition: ModelAPI_Attribute.cpp:76
bool mySetInitializedBlocked
is initialized blocked
Definition: ModelAPI_Attribute.h:41
const std::shared_ptr< ModelAPI_Object > & owner() const
Returns the owner of this attribute.
Definition: ModelAPI_Attribute.cpp:33
virtual void setObject(const std::shared_ptr< ModelAPI_Object > &theObject)
Sets the owner of this attribute.
Definition: ModelAPI_Attribute.cpp:27
const std::string & id() const
ID of the attribute in Data.
Definition: ModelAPI_Attribute.cpp:81
void setInitialized()
Makes attribute initialized.
Definition: ModelAPI_Attribute.cpp:44
bool setImmutable(const bool theFlag)
Immutable argument can not be changed programmatically (e.g.
Definition: ModelAPI_Attribute.cpp:69
virtual ~ModelAPI_Attribute()
To virtually destroy the fields of successors.
Definition: ModelAPI_Attribute.cpp:22
void setIsArgument(const bool theFlag)
Set this attribute is argument for result (change of this attribute requires update of result).
Definition: ModelAPI_Attribute.cpp:59
Represents any object in the data model and in the object browser.
Definition: ModelAPI_Object.h:45
General object of the application that allows to get/set attributes from the document and compute res...
Definition: Model_Data.h:61
Manager of objects of the document.
Definition: Model_Objects.h:46