1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModelAPI_AttributeRefList.h
5 // Author: Mikhail PONIKAROV
7 #ifndef ModelAPI_AttributeRefList_H_
8 #define ModelAPI_AttributeRefList_H_
10 #include "ModelAPI_Attribute.h"
11 #include "ModelAPI_Feature.h"
14 /**\class ModelAPI_AttributeRefList
16 * \brief Attribute that contains list of references to features (located in the same document).
19 class ModelAPI_AttributeRefList : public ModelAPI_Attribute
22 /// Returns the type of this class of attributes
23 MODELAPI_EXPORT static std::string typeId()
28 /// Returns the type of this class of attributes, not static method
29 MODELAPI_EXPORT virtual std::string attributeType();
31 /// Appends the feature to the end of a list
32 virtual void append(ObjectPtr theObject) = 0;
34 /// Erases the first meet of the feature in the list
35 virtual void remove(ObjectPtr theObject) = 0;
37 /// Removes all references from the list
38 virtual void clear() = 0;
40 /// Returns number of features in the list
41 ///\param theWithEmpty if it is false, returns the number of not-empty referenced objects
42 virtual int size(const bool theWithEmpty = true) const = 0;
44 /// Returns the list of features
45 virtual std::list<ObjectPtr> list() = 0;
47 /// Returns true if the object is in list
48 virtual bool isInList(const ObjectPtr& theObj) = 0;
50 /// Returns the referenced object by the zero-based index
51 ///\param theIndex zero-based index in the list
52 ///\param theWithEmpty if it is false, counts the not-empty referenced objects only
53 virtual ObjectPtr object(const int theIndex, const bool theWithEmpty = true) const = 0;
55 /// Substitutes the object by another one. Does nothing if such object is not found.
56 virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew) = 0;
58 /// Substitutes the object by another one and back. So, features wil become exchanged in the list
59 virtual void exchange(const ObjectPtr& theObject1, const ObjectPtr& theObject2) = 0;
61 /// Removes the last element in the list.
62 virtual void removeLast() = 0;
64 /// Removes the elements from the list.
65 /// \param theIndices a list of indices of elements to be removed
66 virtual void remove(const std::set<int>& theIndices) = 0;
68 MODELAPI_EXPORT virtual ~ModelAPI_AttributeRefList();
70 /// Objects are created for features automatically
71 MODELAPI_EXPORT ModelAPI_AttributeRefList();
75 typedef std::shared_ptr<ModelAPI_AttributeRefList> AttributeRefListPtr;