Salome HOME
Issue #1764: The result of partition is not stored in a folder
[modules/shaper.git] / src / Model / Model_AttributeRefList.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_AttributeRefList.h
4 // Created:     8 May 2014
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef Model_AttributeRefList_H_
8 #define Model_AttributeRefList_H_
9
10 #include "Model.h"
11 #include "ModelAPI_AttributeRefList.h"
12 #include "ModelAPI_Feature.h"
13 #include "Model_Document.h"
14
15 #include <TDataStd_ReferenceList.hxx>
16 #include <TDataStd_ExtStringList.hxx>
17
18 /**\class Model_AttributeRefList
19  * \ingroup DataModel
20  * \brief Attribute that contains list of references to features, may be located in different documents.
21  */
22
23 class Model_AttributeRefList : public ModelAPI_AttributeRefList
24 {
25   TDF_Label myLab; ///< the main label of this attribute
26   Handle_TDataStd_ReferenceList myRef;  ///< references to the features labels
27   /// pairs of doc ID and entries if reference is to external object, appends some in this list if
28   /// something in myRef is empty
29   Handle_TDataStd_ExtStringList myExtDocRef;
30  public:
31   /// Appends the feature to the end of a list
32   MODEL_EXPORT virtual void append(ObjectPtr theObject);
33
34   /// Erases the first meet of the feature in the list
35   MODEL_EXPORT virtual void remove(ObjectPtr theObject);
36
37   /// Returns number of features in the list
38   ///\param theWithEmpty if it is false, returns the number of not-empty referenced objects
39   MODEL_EXPORT virtual int size(const bool theWithEmpty = true) const;
40
41   /// Removes all references from the list
42   MODEL_EXPORT virtual void clear();
43
44   /// Returns the list of features
45   MODEL_EXPORT virtual std::list<ObjectPtr> list();
46
47   /// Returns true if the object is in list
48   MODEL_EXPORT virtual bool isInList(const ObjectPtr& theObj);
49
50   /// Returns the list of features
51   ///\param theIndex zero-based index in the list
52   ///\param theWithEmpty if it is false, counts the not-empty referenced objects only
53   MODEL_EXPORT virtual ObjectPtr object(const int theIndex, const bool theWithEmpty = true) const;
54
55   /// Substitutes the feature by another one. Does nothing if such object is not found.
56   /// Does not support the external documents objects yet.
57   MODEL_EXPORT virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew);
58
59   /// Substitutes the object by another one and back. So, features will become exchanged in the list
60   /// Does not support the external documents objects yet.
61   MODEL_EXPORT virtual void exchange(const ObjectPtr& theObject1, const ObjectPtr& theObject2);
62
63   /// Removes the last element in the list.
64   /// Does not support the external documents objects yet.
65   MODEL_EXPORT virtual void removeLast();
66
67   /// Removes the elements from the list.
68   /// Does not support the external documents objects yet.
69   /// \param theIndices a list of indices of elements to be removed
70   MODEL_EXPORT virtual void remove(const std::set<int>& theIndices);
71
72   /// Returns true if attribute was  initialized by some value
73   MODEL_EXPORT virtual bool isInitialized();
74  protected:
75   /// Objects are created for features automatically
76   MODEL_EXPORT Model_AttributeRefList(TDF_Label& theLabel);
77   /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
78   virtual void reinit();
79   /// Returns the object by iterators (theExtIter is iterated if necessary)
80   ObjectPtr iteratedObject(TDF_ListIteratorOfLabelList& theLIter,
81     TDataStd_ListIteratorOfListOfExtendedString& theExtIter,
82     std::shared_ptr<Model_Document> theDoc) const;
83
84   friend class Model_Data;
85 };
86
87 #endif