Salome HOME
eaa1d92067a7fd8d384f1e09781290e694fdc67e
[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
16 /**\class Model_AttributeRefList
17  * \ingroup DataModel
18  * \brief Attribute that contains list of references to features (located in the same document).
19  * For the current moment it does not support references to objects in other documents.
20  */
21
22 class Model_AttributeRefList : public ModelAPI_AttributeRefList
23 {
24   Handle_TDataStd_ReferenceList myRef;  ///< references to the features labels
25  public:
26   /// Appends the feature to the end of a list
27   MODEL_EXPORT virtual void append(ObjectPtr theObject);
28
29   /// Erases the first meet of the feature in the list
30   MODEL_EXPORT virtual void remove(ObjectPtr theObject);
31
32   /// Returns number of features in the list
33   ///\param theWithEmpty if it is false, returns the number of not-empty referenced objects
34   MODEL_EXPORT virtual int size(const bool theWithEmpty = true) const;
35
36   /// Removes all references from the list
37   MODEL_EXPORT virtual void clear();
38
39   /// Returns the list of features
40   MODEL_EXPORT virtual std::list<ObjectPtr> list();
41
42   /// Returns true if the object is in list
43   MODEL_EXPORT virtual bool isInList(const ObjectPtr& theObj);
44
45   /// Returns the list of features
46   ///\param theIndex zero-based index in the list
47   ///\param theWithEmpty if it is false, counts the not-empty referenced objects only
48   MODEL_EXPORT virtual ObjectPtr object(const int theIndex, const bool theWithEmpty = true) const;
49
50   /// Substitutes the feature by another one. Does nothing if such object is not found.
51   MODEL_EXPORT virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew);
52
53   /// Substitutes the object by another one and back. So, features will become exchanged in the list
54   MODEL_EXPORT virtual void exchange(const ObjectPtr& theObject1, const ObjectPtr& theObject2);
55
56   /// Removes the last element in the list.
57   MODEL_EXPORT virtual void removeLast();
58
59   /// Removes the elements from the list.
60   /// \param theIndices a list of indices of elements to be removed
61   MODEL_EXPORT virtual void remove(const std::set<int>& theIndices);
62
63   /// Returns true if attribute was  initialized by some value
64   MODEL_EXPORT virtual bool isInitialized();
65  protected:
66   /// Objects are created for features automatically
67   MODEL_EXPORT Model_AttributeRefList(TDF_Label& theLabel);
68
69   friend class Model_Data;
70 };
71
72 #endif