SHAPER 9.16.0
ModelAPI_Data.h
1// Copyright (C) 2014-2026 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_Data_H_
21#define ModelAPI_Data_H_
22
23#ifdef _WINDOWS // to avoid too long decorated name warning
24#pragma warning( disable : 4503 )
25#endif
26
27#include "ModelAPI.h"
28#include <string>
29#include <vector>
30#include <list>
31#include <set>
32#include <memory>
33
54class ModelAPI_Object;
55class GeomAPI_Shape;
56
58enum ModelAPI_ExecState {
59 ModelAPI_StateDone,
60 ModelAPI_StateMustBeUpdated,
61 ModelAPI_StateExecFailed,
62 ModelAPI_StateInvalidArgument,
63 ModelAPI_StateNothing
64};
65
72class MODELAPI_EXPORT ModelAPI_Data
73{
74 public:
75
77 virtual std::wstring name() = 0;
79 virtual std::wstring name(std::shared_ptr<GeomAPI_Shape> theSubShape) = 0;
81 virtual void setName(const std::wstring& theName) = 0;
83 virtual bool hasUserDefinedName() const = 0;
84
86 virtual std::string version() = 0;
88 virtual void setVersion(const std::string& theVersion) = 0;
89
91 virtual std::shared_ptr<ModelAPI_AttributeDocRef> document(const std::string& theID) = 0;
93 virtual std::shared_ptr<ModelAPI_AttributeDouble> real(const std::string& theID) = 0;
95 virtual std::shared_ptr<ModelAPI_AttributeDoubleArray> realArray(const std::string& theID) = 0;
97 virtual std::shared_ptr<ModelAPI_AttributeInteger> integer(const std::string& theID) = 0;
99 virtual std::shared_ptr<ModelAPI_AttributeReference> reference(const std::string& theID) = 0;
101 virtual std::shared_ptr<ModelAPI_AttributeSelection> selection(const std::string& theID) = 0;
103 virtual std::shared_ptr<ModelAPI_AttributeSelectionList>
104 selectionList(const std::string& theID) = 0;
106 virtual std::shared_ptr<ModelAPI_AttributeRefAttr> refattr(const std::string& theID) = 0;
108 virtual std::shared_ptr<ModelAPI_AttributeRefList> reflist(const std::string& theID) = 0;
111 virtual std::shared_ptr<ModelAPI_AttributeRefAttrList> refattrlist(const std::string& theID) = 0;
113 virtual std::shared_ptr<ModelAPI_AttributeBoolean> boolean(const std::string& theID) = 0;
115 virtual std::shared_ptr<ModelAPI_AttributeString> string(const std::string& theID) = 0;
117 virtual std::shared_ptr<ModelAPI_AttributeIntArray> intArray(const std::string& theID) = 0;
119 virtual std::shared_ptr<ModelAPI_AttributeStringArray> stringArray(const std::string& theID) = 0;
121 virtual std::shared_ptr<ModelAPI_AttributeImage> image(const std::string& theID) = 0;
123 virtual std::shared_ptr<ModelAPI_AttributeTables> tables(const std::string& theID) = 0;
124
127 virtual std::shared_ptr<ModelAPI_Attribute> attribute(const std::string& theID) = 0;
130 virtual std::list<std::shared_ptr<ModelAPI_Attribute> >
131 attributes(const std::string& theType) = 0;
134 virtual std::list<std::string> attributesIDs(const std::string& theType) = 0;
137 virtual const std::string& id(const std::shared_ptr<ModelAPI_Attribute>& theAttr) = 0;
139 virtual bool isEqual(const std::shared_ptr<ModelAPI_Data>& theData) = 0;
141 virtual bool isValid() = 0;
142
150 virtual std::shared_ptr<ModelAPI_Attribute> addAttribute(
151 const std::string& theID, const std::string theAttrType, const int theIndex = -1) = 0;
152
157 virtual std::shared_ptr<ModelAPI_Attribute>
158 addFloatingAttribute(const std::string& theID, const std::string theAttrType,
159 const std::string& theGroup) = 0;
160
162 virtual void allGroups(std::list<std::string>& theGroups) = 0;
163
165 virtual void attributesOfGroup(const std::string& theGroup,
166 std::list<std::shared_ptr<ModelAPI_Attribute> >& theAttrs) = 0;
167
169 virtual void removeAttributes(const std::string& theGroup) = 0;
170
173 virtual void sendAttributeUpdated(ModelAPI_Attribute* theAttr) = 0;
179 const bool theBlock, const bool theSendMessage = true) = 0;
180
182 virtual void erase() = 0;
183
185 virtual ~ModelAPI_Data();
186
188 virtual void execState(const ModelAPI_ExecState theState) = 0;
189
191 virtual ModelAPI_ExecState execState() = 0;
192
194 virtual void setError(const std::string& theError, bool theSend = true) = 0;
195
197 virtual std::string error() const = 0;
198
200 virtual int featureId() const = 0;
201
203 virtual const std::set<std::shared_ptr<ModelAPI_Attribute> >& refsToMe() = 0;
204
209 std::list<std::pair<std::string, std::list<std::shared_ptr<ModelAPI_Object> > > >& theRefs) =0;
210
212 virtual void copyTo(std::shared_ptr<ModelAPI_Data> theTarget) = 0;
213
215 virtual std::shared_ptr<ModelAPI_Data> invalidPtr() = 0;
216
218 virtual int updateID() = 0;
219
222 virtual void setUpdateID(const int theID) = 0;
223
225 virtual std::shared_ptr<ModelAPI_Object> owner() = 0;
226
228 virtual bool isDeleted() = 0;
229
231 virtual void setIsDeleted(const bool theFlag) = 0;
232
234 virtual bool isPrecedingAttribute(const std::string& theAttribute1,
235 const std::string& theAttribute2) const = 0;
236
237 protected:
240
242 virtual bool isInHistory() = 0;
243
245 virtual void setIsInHistory(const bool theFlag) = 0;
246
250 virtual bool isDisplayed() = 0;
251
254 virtual void setDisplayed(const bool theDisplay) = 0;
255
256 friend class ModelAPI_Object;
257};
258
259typedef std::shared_ptr<ModelAPI_Data> DataPtr;
260
261#endif
Interface to the topological shape object.
Definition: GeomAPI_Shape.h:43
Attribute that contains boolean value.
Definition: ModelAPI_AttributeBoolean.h:31
Attribute that contains reference to another document.
Definition: ModelAPI_AttributeDocRef.h:32
API for the attribute that contains several double in the array inside.
Definition: ModelAPI_AttributeDoubleArray.h:32
Attribute that contains real value with double precision.
Definition: ModelAPI_AttributeDouble.h:34
API for the attribute that contains binary data.
Definition: ModelAPI_AttributeImage.h:37
API for the attribute that contains several integers in the array inside.
Definition: ModelAPI_AttributeIntArray.h:36
API for the attribute that contains integer (int).
Definition: ModelAPI_AttributeInteger.h:34
Attribute that contains list of references to features (located in the same document) or references t...
Definition: ModelAPI_AttributeRefAttrList.h:34
Attribute that contains reference to an attribute of a feature or reference to a feature (switchable)
Definition: ModelAPI_AttributeRefAttr.h:33
Attribute that contains list of references to features (located in the same document).
Definition: ModelAPI_AttributeRefList.h:33
Attribute that contains reference to feature (located in the same document).
Definition: ModelAPI_AttributeReference.h:32
Attribute that contains list of references to the sub-shapes with possibility to manage them.
Definition: ModelAPI_AttributeSelectionList.h:37
Attribute that contains reference to the sub-shape of some result, the selected shape.
Definition: ModelAPI_AttributeSelection.h:35
API for the attribute that contains several strings in the array inside.
Definition: ModelAPI_AttributeStringArray.h:32
API for the attribute that contains std (null terminated) string.
Definition: ModelAPI_AttributeString.h:33
API for the attribute that contains tables of some values type.
Definition: ModelAPI_AttributeTables.h:39
Generic attribute of the Object.
Definition: ModelAPI_Attribute.h:34
General object of the application that allows to get/set attributes from the document and compute res...
Definition: ModelAPI_Data.h:73
virtual void setError(const std::string &theError, bool theSend=true)=0
Registers error during the execution, causes the ExecutionFailed state.
virtual bool isDisplayed()=0
Returns true if object must be displayed in the viewer: flag is stored in the data model,...
virtual std::shared_ptr< ModelAPI_AttributeImage > image(const std::string &theID)=0
Returns the attribute that contains image.
virtual int featureId() const =0
Returns the identifier of feature-owner, unique in this document.
virtual bool isInHistory()=0
Returns true if "is in history" custom behaviors is defined for the feature.
virtual void sendAttributeUpdated(ModelAPI_Attribute *theAttr)=0
Useful method for "set" methods of the attributes: sends an UPDATE event and makes attribute initiali...
virtual std::shared_ptr< ModelAPI_AttributeSelection > selection(const std::string &theID)=0
Returns the attribute that contains selection to a shape.
virtual std::shared_ptr< ModelAPI_Attribute > addFloatingAttribute(const std::string &theID, const std::string theAttrType, const std::string &theGroup)=0
Adds a floating attribute (that may be added/removed during the data life)
virtual void setName(const std::wstring &theName)=0
Defines the name of the feature visible by the user in the object browser.
virtual std::shared_ptr< ModelAPI_AttributeReference > reference(const std::string &theID)=0
Returns the attribute that contains reference to a feature.
virtual std::string version()=0
Returns version of the feature (empty string if not applicable)
virtual int updateID()=0
Identifier of the transaction when object (feature or result) was updated last time.
virtual bool isDeleted()=0
Returns true if the object is deleted, but some data is still kept in memory.
virtual bool isEqual(const std::shared_ptr< ModelAPI_Data > &theData)=0
Returns true if data belongs to same features.
virtual std::string error() const =0
Returns error, arose during the execution.
virtual void setVersion(const std::string &theVersion)=0
Initialize the version of the feature.
virtual std::shared_ptr< ModelAPI_AttributeDouble > real(const std::string &theID)=0
Returns the attribute that contains real value with double precision.
virtual void removeAttributes(const std::string &theGroup)=0
Remove all attributes of the given group.
virtual bool isValid()=0
Returns true if it is correctly connected to the data model.
virtual std::shared_ptr< ModelAPI_AttributeBoolean > boolean(const std::string &theID)=0
Returns the attribute that contains boolean value.
virtual std::wstring name(std::shared_ptr< GeomAPI_Shape > theSubShape)=0
Returns the name of the shape.
virtual std::shared_ptr< ModelAPI_AttributeDocRef > document(const std::string &theID)=0
Returns the attribute that references to another document.
virtual bool isPrecedingAttribute(const std::string &theAttribute1, const std::string &theAttribute2) const =0
Returns true if theAttribute1 is going earlier than theAttribute2 in the data.
virtual void setUpdateID(const int theID)=0
Identifier of the transaction when object (feature or result) was updated last time.
virtual const std::string & id(const std::shared_ptr< ModelAPI_Attribute > &theAttr)=0
Identifier by the id (not fast, iteration by map)
virtual std::shared_ptr< ModelAPI_AttributeRefAttrList > refattrlist(const std::string &theID)=0
Returns the attribute that contains list of references to features or reference to an attribute of a ...
virtual std::shared_ptr< ModelAPI_AttributeIntArray > intArray(const std::string &theID)=0
Returns the attribute that contains integer values array.
virtual std::wstring name()=0
Returns the name of the feature visible by the user in the object browser.
virtual std::shared_ptr< ModelAPI_AttributeStringArray > stringArray(const std::string &theID)=0
Returns the attribute that contains string values array.
virtual void copyTo(std::shared_ptr< ModelAPI_Data > theTarget)=0
Copies all attributes content into theTarget data.
virtual std::shared_ptr< ModelAPI_Data > invalidPtr()=0
Returns the invalid data pointer (to avoid working with NULL shared pointers in swig)
virtual bool blockSendAttributeUpdated(const bool theBlock, const bool theSendMessage=true)=0
Blocks sending "attribute updated" if theBlock is true.
virtual std::shared_ptr< ModelAPI_Object > owner()=0
Returns the owner of this data.
virtual std::shared_ptr< ModelAPI_Attribute > addAttribute(const std::string &theID, const std::string theAttrType, const int theIndex=-1)=0
Initializes object by the attributes: must be called just after the object is created for each attrib...
virtual std::shared_ptr< ModelAPI_AttributeRefList > reflist(const std::string &theID)=0
Returns the attribute that contains list of references to features.
virtual void attributesOfGroup(const std::string &theGroup, std::list< std::shared_ptr< ModelAPI_Attribute > > &theAttrs)=0
Returns an ordered list of attributes that belong to the given group.
virtual std::list< std::string > attributesIDs(const std::string &theType)=0
Returns all attributes ids of the feature of the given type or all attributes if "theType" is empty.
virtual std::shared_ptr< ModelAPI_AttributeDoubleArray > realArray(const std::string &theID)=0
Returns the attribute that contains double values array.
virtual ModelAPI_ExecState execState()=0
Returns the state of the latest execution of the feature.
virtual std::list< std::shared_ptr< ModelAPI_Attribute > > attributes(const std::string &theType)=0
Returns all attributes of the feature of the given type or all attributes if "theType" is empty.
virtual std::shared_ptr< ModelAPI_Attribute > attribute(const std::string &theID)=0
Returns the generic attribute by identifier.
virtual std::shared_ptr< ModelAPI_AttributeString > string(const std::string &theID)=0
Returns the attribute that contains boolean value.
virtual void erase()=0
Erases all the data from the data model.
virtual void execState(const ModelAPI_ExecState theState)=0
Stores the state of the object to execute it later accordingly.
virtual std::shared_ptr< ModelAPI_AttributeInteger > integer(const std::string &theID)=0
Returns the attribute that contains integer value.
virtual void setDisplayed(const bool theDisplay)=0
Sets the displayed/hidden state of the object.
virtual std::shared_ptr< ModelAPI_AttributeTables > tables(const std::string &theID)=0
Returns the attribute that contains tables.
virtual void referencesToObjects(std::list< std::pair< std::string, std::list< std::shared_ptr< ModelAPI_Object > > > > &theRefs)=0
returns all references by attributes of this data
virtual void allGroups(std::list< std::string > &theGroups)=0
Returns all groups of this data (ordered).
virtual std::shared_ptr< ModelAPI_AttributeSelectionList > selectionList(const std::string &theID)=0
Returns the attribute that contains selection to a shape.
virtual void setIsDeleted(const bool theFlag)=0
Sets true if the object is deleted, but some data is still kept in memory.
virtual std::shared_ptr< ModelAPI_AttributeRefAttr > refattr(const std::string &theID)=0
Returns the attribute that contains reference to an attribute of a feature.
virtual void setIsInHistory(const bool theFlag)=0
Defines the custom "is in history" behavior.
virtual bool hasUserDefinedName() const =0
Return true if the object has been renamed by the user.
virtual const std::set< std::shared_ptr< ModelAPI_Attribute > > & refsToMe()=0
returns all objects referenced to this
Document for internal data structure of any object storage.
Definition: ModelAPI_Document.h:53
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:41
Represents any object in the data model and in the object browser.
Definition: ModelAPI_Object.h:45