1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Model_AttributeRefAttrList.h
4 // Created: 20 Jan 2016
5 // Author: Mikhail PONIKAROV
7 #ifndef Model_AttributeRefAttrList_H_
8 #define Model_AttributeRefAttrList_H_
11 #include "ModelAPI_AttributeRefAttrList.h"
12 #include "ModelAPI_Feature.h"
14 #include <TDataStd_ReferenceList.hxx>
15 #include <TDataStd_ExtStringList.hxx>
17 /**\class Model_AttributeRefAttrList
19 * \brief Attribute that contains list of references to features (located in the same document)
20 * or references to attributes of the features (list of AttributeRefAttr)
23 class Model_AttributeRefAttrList : public ModelAPI_AttributeRefAttrList
25 Handle_TDataStd_ReferenceList myRef; ///< references to the features labels
26 Handle_TDataStd_ExtStringList myIDs; ///< the referenced attributes IDs (empty for just object)
28 /// Appends the feature to the end of a list
29 MODEL_EXPORT virtual void append(ObjectPtr theObject);
30 /// Appends the attribute to the end of a list
31 MODEL_EXPORT virtual void append(AttributePtr theAttr);
33 /// Erases the first meet of the feature in the list
34 MODEL_EXPORT virtual void remove(ObjectPtr theObject);
35 /// Erases the first meet of the attribute in the list
36 MODEL_EXPORT virtual void remove(AttributePtr theAttr);
38 /// Removes all references from the list
39 MODEL_EXPORT virtual void clear();
41 /// Returns number of features in the list
42 MODEL_EXPORT virtual int size() const;
44 /// Returns the list of features and attributes (if it is reference to the attribute)
45 MODEL_EXPORT virtual std::list<std::pair<ObjectPtr, AttributePtr> > list();
47 /// Returns true if the object is in list
48 MODEL_EXPORT virtual bool isInList(const ObjectPtr& theObj);
49 /// Returns true if the attribute is in list
50 MODEL_EXPORT virtual bool isInList(const AttributePtr& theObj);
52 /// Returns true if this is reference to an attribute, not just object
53 MODEL_EXPORT virtual bool isAttribute(const int theIndex) const;
55 /// Returns the referenced object by the zero-based index
56 ///\param theIndex zero-based index in the list
57 MODEL_EXPORT virtual ObjectPtr object(const int theIndex) const;
58 /// Returns the referenced attribute by the zero-based index
59 ///\param theIndex zero-based index in the list
60 MODEL_EXPORT virtual AttributePtr attribute(const int theIndex) const;
62 /// Removes the last element in the list.
63 MODEL_EXPORT virtual void removeLast();
65 /// Removes the elements from the list.
66 /// \param theIndices a list of indices of elements to be removed
67 MODEL_EXPORT virtual void remove(const std::set<int>& theIndices);
69 /// Returns true if attribute was initialized by some value
70 MODEL_EXPORT virtual bool isInitialized();
72 /// Objects are created for features automatically
73 MODEL_EXPORT Model_AttributeRefAttrList(TDF_Label& theLabel);
75 friend class Model_Data;