Salome HOME
correction of Model_Data for AttributeRefAttrList
[modules/shaper.git] / src / Model / Model_AttributeRefAttrList.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        Model_AttributeRefAttrList.h
4 // Created:     20 Jan 2016
5 // Author:      Mikhail PONIKAROV
6
7 #ifndef Model_AttributeRefAttrList_H_
8 #define Model_AttributeRefAttrList_H_
9
10 #include "Model.h"
11 #include "ModelAPI_AttributeRefAttrList.h"
12 #include "ModelAPI_Feature.h"
13
14 #include <TDataStd_ReferenceList.hxx>
15 #include <TDataStd_ExtStringList.hxx>
16
17 /**\class Model_AttributeRefAttrList
18  * \ingroup DataModel
19  * \brief Attribute that contains list of references to features (located in the same document)
20  * or references to attributes of the features (list of AttributeRefAttr)
21  */
22
23 class Model_AttributeRefAttrList : public ModelAPI_AttributeRefAttrList
24 {
25   Handle_TDataStd_ReferenceList myRef;  ///< references to the features labels
26   Handle_TDataStd_ExtStringList myIDs;  ///< the referenced attributes IDs (empty for just object)
27  public:
28   /// Appends the feature to the end of a list
29   MODEL_EXPORT virtual void append(ObjectPtr theObject);
30   /// Appends the attribute to the end of a list
31   MODEL_EXPORT virtual void append(AttributePtr theAttr);
32
33   /// Erases the first meet of the feature in the list
34   MODEL_EXPORT virtual void remove(ObjectPtr theObject);
35   /// Erases the first meet of the attribute in the list
36   MODEL_EXPORT virtual void remove(AttributePtr theAttr);
37
38   /// Removes all references from the list
39   MODEL_EXPORT virtual void clear();
40
41   /// Returns number of features in the list
42   MODEL_EXPORT virtual int size() const;
43
44   /// Returns the list of features and attributes (if it is reference to the attribute)
45   MODEL_EXPORT virtual std::list<std::pair<ObjectPtr, AttributePtr> > list();
46
47   /// Returns true if the object is in list
48   MODEL_EXPORT virtual bool isInList(const ObjectPtr& theObj);
49   /// Returns true if the attribute is in list
50   MODEL_EXPORT virtual bool isInList(const AttributePtr& theObj);
51
52   /// Returns true if this is reference to an attribute, not just object
53   MODEL_EXPORT virtual bool isAttribute(const int theIndex) const;
54
55   /// Returns the referenced object by the zero-based index
56   ///\param theIndex zero-based index in the list
57   MODEL_EXPORT virtual ObjectPtr object(const int theIndex) const;
58   /// Returns the referenced attribute by the zero-based index
59   ///\param theIndex zero-based index in the list
60   MODEL_EXPORT virtual AttributePtr attribute(const int theIndex) const;
61
62   /// Removes the last element in the list.
63   MODEL_EXPORT virtual void removeLast();
64
65   /// Removes the elements from the list.
66   /// \param theIndices a list of indices of elements to be removed
67   MODEL_EXPORT virtual void remove(const std::set<int>& theIndices);
68
69   /// Returns true if attribute was initialized by some value
70   MODEL_EXPORT virtual bool isInitialized();
71  protected:
72   /// Objects are created for features automatically
73   MODEL_EXPORT Model_AttributeRefAttrList(TDF_Label& theLabel);
74
75   friend class Model_Data;
76 };
77
78 #endif