Salome HOME
Implementation of the issue #1307. Also make connected parameters from different...
[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
14 #include <TDataStd_ReferenceList.hxx>
15 #include <TDataStd_ExtStringList.hxx>
16
17 /**\class Model_AttributeRefList
18  * \ingroup DataModel
19  * \brief Attribute that contains list of references to features, may be located in different documents.
20  */
21
22 class Model_AttributeRefList : public ModelAPI_AttributeRefList
23 {
24   Handle_TDataStd_ReferenceList myRef;  ///< references to the features labels
25   /// pairs of doc ID and entries if reference is to external object, appends some in this list if
26   /// something in myRef is empty
27   Handle_TDataStd_ExtStringList myExtDocRef;
28  public:
29   /// Appends the feature to the end of a list
30   MODEL_EXPORT virtual void append(ObjectPtr theObject);
31
32   /// Erases the first meet of the feature in the list
33   MODEL_EXPORT virtual void remove(ObjectPtr theObject);
34
35   /// Returns number of features in the list
36   ///\param theWithEmpty if it is false, returns the number of not-empty referenced objects
37   MODEL_EXPORT virtual int size(const bool theWithEmpty = true) const;
38
39   /// Removes all references from the list
40   MODEL_EXPORT virtual void clear();
41
42   /// Returns the list of features
43   MODEL_EXPORT virtual std::list<ObjectPtr> list();
44
45   /// Returns true if the object is in list
46   MODEL_EXPORT virtual bool isInList(const ObjectPtr& theObj);
47
48   /// Returns the list of features
49   ///\param theIndex zero-based index in the list
50   ///\param theWithEmpty if it is false, counts the not-empty referenced objects only
51   MODEL_EXPORT virtual ObjectPtr object(const int theIndex, const bool theWithEmpty = true) const;
52
53   /// Substitutes the feature by another one. Does nothing if such object is not found.
54   /// Does not support the external documents objects yet.
55   MODEL_EXPORT virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew);
56
57   /// Substitutes the object by another one and back. So, features will become exchanged in the list
58   /// Does not support the external documents objects yet.
59   MODEL_EXPORT virtual void exchange(const ObjectPtr& theObject1, const ObjectPtr& theObject2);
60
61   /// Removes the last element in the list.
62   /// Does not support the external documents objects yet.
63   MODEL_EXPORT virtual void removeLast();
64
65   /// Removes the elements from the list.
66   /// Does not support the external documents objects yet.
67   /// \param theIndices a list of indices of elements to be removed
68   MODEL_EXPORT virtual void remove(const std::set<int>& theIndices);
69
70   /// Returns true if attribute was  initialized by some value
71   MODEL_EXPORT virtual bool isInitialized();
72  protected:
73   /// Objects are created for features automatically
74   MODEL_EXPORT Model_AttributeRefList(TDF_Label& theLabel);
75   /// Returns the object by iterators (theExtIter is iterated if necessary)
76   ObjectPtr iteratedObject(TDF_ListIteratorOfLabelList& theLIter,
77     TDataStd_ListIteratorOfListOfExtendedString& theExtIter,
78     std::shared_ptr<Model_Document> theDoc) const;
79
80   friend class Model_Data;
81 };
82
83 #endif