Salome HOME
updated copyright message
[modules/shaper.git] / src / ModelAPI / ModelAPI_AttributeRefAttrList.h
1 // Copyright (C) 2014-2023  CEA, EDF
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef ModelAPI_AttributeRefAttrList_H_
21 #define ModelAPI_AttributeRefAttrList_H_
22
23 #include "ModelAPI_Attribute.h"
24 #include "ModelAPI_Feature.h"
25 #include <list>
26
27 /**\class ModelAPI_AttributeRefAttrList
28  * \ingroup DataModel
29  * \brief Attribute that contains list of references to features (located in the same document)
30  * or references to attributes of the features (list of AttributeRefAttr)
31  */
32
33 class ModelAPI_AttributeRefAttrList : public ModelAPI_Attribute
34 {
35  public:
36   /// Returns the type of this class of attributes
37   MODELAPI_EXPORT static std::string typeId()
38   {
39     return "RefAttrList";
40   }
41
42   /// Returns the type of this class of attributes, not static method
43   MODELAPI_EXPORT virtual std::string attributeType();
44
45   /// Appends the feature to the end of a list
46   virtual void append(ObjectPtr theObject) = 0;
47   /// Appends the attribute to the end of a list
48   virtual void append(AttributePtr theAttr) = 0;
49
50   /// Erases the first meet of the feature in the list
51   virtual void remove(ObjectPtr theObject) = 0;
52   /// Erases the first meet of the attribute in the list
53   virtual void remove(AttributePtr theAttr) = 0;
54
55   /// Removes all references from the list
56   virtual void clear() = 0;
57
58   /// Returns number of features in the list
59   virtual int size() const = 0;
60
61   /// Returns the list of features and attributes (if it is reference to the attribute)
62   virtual std::list<std::pair<ObjectPtr, AttributePtr> > list() = 0;
63
64   /// Returns true if the object is in list
65   virtual bool isInList(const ObjectPtr& theObj) = 0;
66   /// Returns true if the attribute is in list
67   virtual bool isInList(const AttributePtr& theObj) = 0;
68
69   /// Returns true if this is reference to an attribute, not just object
70   virtual bool isAttribute(const int theIndex) const = 0;
71
72   /// Returns the referenced object by the zero-based index
73   ///\param theIndex zero-based index in the list
74   virtual ObjectPtr object(const int theIndex) const = 0;
75   /// Returns the referenced attribute by the zero-based index
76   ///\param theIndex zero-based index in the list
77   virtual AttributePtr attribute(const int theIndex) const = 0;
78
79   /// Removes the last element in the list.
80   virtual void removeLast() = 0;
81
82   /// Removes the elements from the list.
83   /// \param theIndices a list of indices of elements to be removed
84   virtual void remove(const std::set<int>& theIndices) = 0;
85
86   MODELAPI_EXPORT virtual ~ModelAPI_AttributeRefAttrList();
87  protected:
88   /// Objects are created for features automatically
89   MODELAPI_EXPORT ModelAPI_AttributeRefAttrList();
90
91 };
92
93 typedef std::shared_ptr<ModelAPI_AttributeRefAttrList> AttributeRefAttrListPtr;
94
95 #endif