1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModelAPI_AttributeRefAttrList.h
4 // Created: 20 Jan 2016
5 // Author: Mikhail PONIKAROV
7 #ifndef ModelAPI_AttributeRefAttrList_H_
8 #define ModelAPI_AttributeRefAttrList_H_
10 #include "ModelAPI_Attribute.h"
11 #include "ModelAPI_Feature.h"
14 /**\class ModelAPI_AttributeRefAttrList
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)
20 class ModelAPI_AttributeRefAttrList : public ModelAPI_Attribute
23 /// Returns the type of this class of attributes
24 MODELAPI_EXPORT static std::string typeId()
29 /// Returns the type of this class of attributes, not static method
30 MODELAPI_EXPORT virtual std::string attributeType();
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;
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;
42 /// Removes all references from the list
43 virtual void clear() = 0;
45 /// Returns number of features in the list
46 virtual int size() const = 0;
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;
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;
56 /// Returns true if this is reference to an attribute, not just object
57 virtual bool isAttribute(const int theIndex) const = 0;
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;
66 /// Removes the last element in the list.
67 virtual void removeLast() = 0;
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;
73 MODELAPI_EXPORT virtual ~ModelAPI_AttributeRefAttrList();
75 /// Objects are created for features automatically
76 MODELAPI_EXPORT ModelAPI_AttributeRefAttrList();
80 typedef std::shared_ptr<ModelAPI_AttributeRefAttrList> AttributeRefAttrListPtr;