1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Model_AttributeRefList.h
5 // Author: Mikhail PONIKAROV
7 #ifndef Model_AttributeRefList_H_
8 #define Model_AttributeRefList_H_
11 #include "ModelAPI_AttributeRefList.h"
12 #include "ModelAPI_Feature.h"
13 #include "Model_Document.h"
15 #include <TDataStd_ReferenceList.hxx>
16 #include <TDataStd_ExtStringList.hxx>
18 /**\class Model_AttributeRefList
20 * \brief Attribute that contains list of references to features, may be located in different documents.
23 class Model_AttributeRefList : public ModelAPI_AttributeRefList
25 Handle_TDataStd_ReferenceList myRef; ///< references to the features labels
26 /// pairs of doc ID and entries if reference is to external object, appends some in this list if
27 /// something in myRef is empty
28 Handle_TDataStd_ExtStringList myExtDocRef;
30 /// Appends the feature to the end of a list
31 MODEL_EXPORT virtual void append(ObjectPtr theObject);
33 /// Erases the first meet of the feature in the list
34 MODEL_EXPORT virtual void remove(ObjectPtr theObject);
36 /// Returns number of features in the list
37 ///\param theWithEmpty if it is false, returns the number of not-empty referenced objects
38 MODEL_EXPORT virtual int size(const bool theWithEmpty = true) const;
40 /// Removes all references from the list
41 MODEL_EXPORT virtual void clear();
43 /// Returns the list of features
44 MODEL_EXPORT virtual std::list<ObjectPtr> list();
46 /// Returns true if the object is in list
47 MODEL_EXPORT virtual bool isInList(const ObjectPtr& theObj);
49 /// Returns the list of features
50 ///\param theIndex zero-based index in the list
51 ///\param theWithEmpty if it is false, counts the not-empty referenced objects only
52 MODEL_EXPORT virtual ObjectPtr object(const int theIndex, const bool theWithEmpty = true) const;
54 /// Substitutes the feature by another one. Does nothing if such object is not found.
55 /// Does not support the external documents objects yet.
56 MODEL_EXPORT virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew);
58 /// Substitutes the object by another one and back. So, features will become exchanged in the list
59 /// Does not support the external documents objects yet.
60 MODEL_EXPORT virtual void exchange(const ObjectPtr& theObject1, const ObjectPtr& theObject2);
62 /// Removes the last element in the list.
63 /// Does not support the external documents objects yet.
64 MODEL_EXPORT virtual void removeLast();
66 /// Removes the elements from the list.
67 /// Does not support the external documents objects yet.
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_AttributeRefList(TDF_Label& theLabel);
76 /// Returns the object by iterators (theExtIter is iterated if necessary)
77 ObjectPtr iteratedObject(TDF_ListIteratorOfLabelList& theLIter,
78 TDataStd_ListIteratorOfListOfExtendedString& theExtIter,
79 std::shared_ptr<Model_Document> theDoc) const;
81 friend class Model_Data;