Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / ModelAPI / ModelAPI_AttributeRefAttrList.h
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #ifndef ModelAPI_AttributeRefAttrList_H_
22 #define ModelAPI_AttributeRefAttrList_H_
23
24 #include "ModelAPI_Attribute.h"
25 #include "ModelAPI_Feature.h"
26 #include <list>
27
28 /**\class ModelAPI_AttributeRefAttrList
29  * \ingroup DataModel
30  * \brief Attribute that contains list of references to features (located in the same document)
31  * or references to attributes of the features (list of AttributeRefAttr)
32  */
33
34 class ModelAPI_AttributeRefAttrList : public ModelAPI_Attribute
35 {
36  public:
37   /// Returns the type of this class of attributes
38   MODELAPI_EXPORT static std::string typeId()
39   {
40     return "RefAttrList";
41   }
42
43   /// Returns the type of this class of attributes, not static method
44   MODELAPI_EXPORT virtual std::string attributeType();
45
46   /// Appends the feature to the end of a list
47   virtual void append(ObjectPtr theObject) = 0;
48   /// Appends the attribute to the end of a list
49   virtual void append(AttributePtr theAttr) = 0;
50
51   /// Erases the first meet of the feature in the list
52   virtual void remove(ObjectPtr theObject) = 0;
53   /// Erases the first meet of the attribute in the list
54   virtual void remove(AttributePtr theAttr) = 0;
55
56   /// Removes all references from the list
57   virtual void clear() = 0;
58
59   /// Returns number of features in the list
60   virtual int size() const = 0;
61
62   /// Returns the list of features and attributes (if it is reference to the attribute)
63   virtual std::list<std::pair<ObjectPtr, AttributePtr> > list() = 0;
64
65   /// Returns true if the object is in list
66   virtual bool isInList(const ObjectPtr& theObj) = 0;
67   /// Returns true if the attribute is in list
68   virtual bool isInList(const AttributePtr& theObj) = 0;
69
70   /// Returns true if this is reference to an attribute, not just object
71   virtual bool isAttribute(const int theIndex) const = 0;
72
73   /// Returns the referenced object by the zero-based index
74   ///\param theIndex zero-based index in the list
75   virtual ObjectPtr object(const int theIndex) const = 0;
76   /// Returns the referenced attribute by the zero-based index
77   ///\param theIndex zero-based index in the list
78   virtual AttributePtr attribute(const int theIndex) const = 0;
79
80   /// Removes the last element in the list.
81   virtual void removeLast() = 0;
82
83   /// Removes the elements from the list.
84   /// \param theIndices a list of indices of elements to be removed
85   virtual void remove(const std::set<int>& theIndices) = 0;
86
87   MODELAPI_EXPORT virtual ~ModelAPI_AttributeRefAttrList();
88  protected:
89   /// Objects are created for features automatically
90   MODELAPI_EXPORT ModelAPI_AttributeRefAttrList();
91
92 };
93
94 typedef std::shared_ptr<ModelAPI_AttributeRefAttrList> AttributeRefAttrListPtr;
95
96 #endif