1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef ModelAPI_AttributeRefList_H_
22 #define ModelAPI_AttributeRefList_H_
24 #include "ModelAPI_Attribute.h"
25 #include "ModelAPI_Feature.h"
28 /**\class ModelAPI_AttributeRefList
30 * \brief Attribute that contains list of references to features (located in the same document).
33 class ModelAPI_AttributeRefList : public ModelAPI_Attribute
36 /// Returns the type of this class of attributes
37 MODELAPI_EXPORT static std::string typeId()
42 /// Returns the type of this class of attributes, not static method
43 MODELAPI_EXPORT virtual std::string attributeType();
45 /// Appends the feature to the end of a list
46 virtual void append(ObjectPtr theObject) = 0;
48 /// Erases the first meet of the feature in the list
49 virtual void remove(ObjectPtr theObject) = 0;
51 /// Removes all references from the list
52 virtual void clear() = 0;
54 /// Returns number of features in the list
55 ///\param theWithEmpty if it is false, returns the number of not-empty referenced objects
56 virtual int size(const bool theWithEmpty = true) const = 0;
58 /// Returns the list of features
59 virtual std::list<ObjectPtr> list() = 0;
61 /// Returns true if the object is in list
62 virtual bool isInList(const ObjectPtr& theObj) = 0;
64 /// Returns the referenced object by the zero-based index
65 ///\param theIndex zero-based index in the list
66 ///\param theWithEmpty if it is false, counts the not-empty referenced objects only
67 virtual ObjectPtr object(const int theIndex, const bool theWithEmpty = true) = 0;
69 /// Substitutes the object by another one. Does nothing if such object is not found.
70 virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew) = 0;
72 /// Substitutes the object by another one and back. So, features wil become exchanged in the list
73 virtual void exchange(const ObjectPtr& theObject1, const ObjectPtr& theObject2) = 0;
75 /// Removes the last element in the list.
76 virtual void removeLast() = 0;
78 /// Removes the elements from the list.
79 /// \param theIndices a list of indices of elements to be removed
80 virtual void remove(const std::set<int>& theIndices) = 0;
82 MODELAPI_EXPORT virtual ~ModelAPI_AttributeRefList();
84 /// Objects are created for features automatically
85 MODELAPI_EXPORT ModelAPI_AttributeRefList();
89 typedef std::shared_ptr<ModelAPI_AttributeRefList> AttributeRefListPtr;