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 <TDF_Label.hxx>
15 #include <TDataStd_ReferenceList.hxx>
16 #include <TDataStd_ExtStringList.hxx>
18 /**\class Model_AttributeRefAttrList
20 * \brief Attribute that contains list of references to features (located in the same document)
21 * or references to attributes of the features (list of AttributeRefAttr)
24 class Model_AttributeRefAttrList : public ModelAPI_AttributeRefAttrList
26 TDF_Label myLab; ///< the main label of this attribute
27 Handle_TDataStd_ReferenceList myRef; ///< references to the features labels
28 Handle_TDataStd_ExtStringList myIDs; ///< the referenced attributes IDs (empty for just object)
30 /// Appends the feature to the end of a list
31 MODEL_EXPORT virtual void append(ObjectPtr theObject);
32 /// Appends the attribute to the end of a list
33 MODEL_EXPORT virtual void append(AttributePtr theAttr);
35 /// Erases the first meet of the feature in the list
36 MODEL_EXPORT virtual void remove(ObjectPtr theObject);
37 /// Erases the first meet of the attribute in the list
38 MODEL_EXPORT virtual void remove(AttributePtr theAttr);
40 /// Removes all references from the list
41 MODEL_EXPORT virtual void clear();
43 /// Returns number of features in the list
44 MODEL_EXPORT virtual int size() const;
46 /// Returns the list of features and attributes (if it is reference to the attribute)
47 MODEL_EXPORT virtual std::list<std::pair<ObjectPtr, AttributePtr> > list();
49 /// Returns true if the object is in list
50 MODEL_EXPORT virtual bool isInList(const ObjectPtr& theObj);
51 /// Returns true if the attribute is in list
52 MODEL_EXPORT virtual bool isInList(const AttributePtr& theObj);
54 /// Returns true if this is reference to an attribute, not just object
55 MODEL_EXPORT virtual bool isAttribute(const int theIndex) const;
57 /// Returns the referenced object by the zero-based index
58 ///\param theIndex zero-based index in the list
59 MODEL_EXPORT virtual ObjectPtr object(const int theIndex) const;
60 /// Returns the referenced attribute by the zero-based index
61 ///\param theIndex zero-based index in the list
62 MODEL_EXPORT virtual AttributePtr attribute(const int theIndex) const;
64 /// Removes the last element in the list.
65 MODEL_EXPORT virtual void removeLast();
67 /// Removes the elements from the list.
68 /// \param theIndices a list of indices of elements to be removed
69 MODEL_EXPORT virtual void remove(const std::set<int>& theIndices);
71 /// Returns true if attribute was initialized by some value
72 MODEL_EXPORT virtual bool isInitialized();
74 /// Objects are created for features automatically
75 MODEL_EXPORT Model_AttributeRefAttrList(TDF_Label& theLabel);
76 /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
77 virtual void reinit();
79 friend class Model_Data;