SHAPER  9.12.0
Model_AttributeRefList.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 Model_AttributeRefList_H_
21 #define Model_AttributeRefList_H_
22 
23 #include "Model.h"
24 #include "ModelAPI_AttributeRefList.h"
25 #include "ModelAPI_Feature.h"
26 #include "Model_Document.h"
27 
28 #include <TDataStd_ReferenceList.hxx>
29 #include <TDataStd_ExtStringList.hxx>
30 
37 {
38  TDF_Label myLab;
39 
40  Handle_TDataStd_ReferenceList myRef;
43  Handle_TDataStd_ExtStringList myExtDocRef;
44  bool myHashUsed;
45  std::set<ObjectPtr> myHashObjects;
46  std::map<int, ObjectPtr> myHashIndex;
47  std::map<int, ObjectPtr> myHashIndexNoEmpty;
48 public:
50  MODEL_EXPORT virtual void append(ObjectPtr theObject);
51 
53  MODEL_EXPORT virtual void remove(ObjectPtr theObject);
54 
57  MODEL_EXPORT virtual int size(const bool theWithEmpty = true) const;
58 
60  MODEL_EXPORT virtual void clear();
61 
63  MODEL_EXPORT virtual std::list<ObjectPtr> list();
64 
66  MODEL_EXPORT virtual bool isInList(const ObjectPtr& theObj);
67 
71  MODEL_EXPORT virtual ObjectPtr object(const int theIndex, const bool theWithEmpty = true);
72 
75  MODEL_EXPORT virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew);
76 
79  MODEL_EXPORT virtual void removeLast();
80 
84  MODEL_EXPORT virtual void remove(const std::set<int>& theIndices);
85 
87  MODEL_EXPORT virtual bool isInitialized();
88 
90  void eraseHash();
91 
92 protected:
94  MODEL_EXPORT Model_AttributeRefList(TDF_Label& theLabel);
96  virtual void reinit();
98  ObjectPtr iteratedObject(TDF_ListIteratorOfLabelList& theLIter,
99  TDataStd_ListIteratorOfListOfExtendedString& theExtIter,
100  std::shared_ptr<Model_Document> theDoc) const;
102  void createHash();
103 
104  friend class Model_Data;
105 };
106 
107 #endif
Attribute that contains list of references to features (located in the same document).
Definition: ModelAPI_AttributeRefList.h:33
Attribute that contains list of references to features, may be located in different documents.
Definition: Model_AttributeRefList.h:37
virtual bool isInList(const ObjectPtr &theObj)
Returns true if the object is in list.
Definition: Model_AttributeRefList.cpp:204
virtual void reinit()
Reinitializes the internal state of the attribute (may be needed on undo/redo, abort,...
Definition: Model_AttributeRefList.cpp:305
virtual int size(const bool theWithEmpty=true) const
Returns number of features in the list.
Definition: Model_AttributeRefList.cpp:139
virtual void substitute(const ObjectPtr &theCurrent, const ObjectPtr &theNew)
Substitutes the feature by another one.
Definition: Model_AttributeRefList.cpp:229
ObjectPtr iteratedObject(TDF_ListIteratorOfLabelList &theLIter, TDataStd_ListIteratorOfListOfExtendedString &theExtIter, std::shared_ptr< Model_Document > theDoc) const
Returns the object by iterators (theExtIter is iterated if necessary)
Definition: Model_AttributeRefList.cpp:164
void createHash()
Creates the hash-objects containers (does nothing if hash is already correct)
Definition: Model_AttributeRefList.cpp:317
Model_AttributeRefList(TDF_Label &theLabel)
Objects are created for features automatically.
Definition: Model_AttributeRefList.cpp:299
void eraseHash()
Erases the hashed objects caused by complicated modifications in the list.
Definition: Model_AttributeRefList.cpp:340
virtual void clear()
Removes all references from the list.
Definition: Model_AttributeRefList.cpp:126
virtual void removeLast()
Removes the last element in the list.
Definition: Model_AttributeRefList.cpp:257
virtual bool isInitialized()
Returns true if attribute was initialized by some value.
Definition: Model_AttributeRefList.cpp:155
virtual std::list< ObjectPtr > list()
Returns the list of features.
Definition: Model_AttributeRefList.cpp:193
virtual void remove(ObjectPtr theObject)
Erases the first meet of the feature in the list.
Definition: Model_AttributeRefList.cpp:58
virtual void append(ObjectPtr theObject)
Appends the feature to the end of a list.
Definition: Model_AttributeRefList.cpp:29
virtual ObjectPtr object(const int theIndex, const bool theWithEmpty=true)
Returns the list of features.
Definition: Model_AttributeRefList.cpp:213
General object of the application that allows to get/set attributes from the document and compute res...
Definition: Model_Data.h:61