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