1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #ifndef Model_AttributeRefAttrList_H_
22 #define Model_AttributeRefAttrList_H_
25 #include "ModelAPI_AttributeRefAttrList.h"
26 #include "ModelAPI_Feature.h"
28 #include <TDF_Label.hxx>
29 #include <TDataStd_ReferenceList.hxx>
30 #include <TDataStd_ExtStringList.hxx>
32 /**\class Model_AttributeRefAttrList
34 * \brief Attribute that contains list of references to features (located in the same document)
35 * or references to attributes of the features (list of AttributeRefAttr)
38 class Model_AttributeRefAttrList : public ModelAPI_AttributeRefAttrList
40 TDF_Label myLab; ///< the main label of this attribute
41 Handle_TDataStd_ReferenceList myRef; ///< references to the features labels
42 Handle_TDataStd_ExtStringList myIDs; ///< the referenced attributes IDs (empty for just object)
44 /// Appends the feature to the end of a list
45 MODEL_EXPORT virtual void append(ObjectPtr theObject);
46 /// Appends the attribute to the end of a list
47 MODEL_EXPORT virtual void append(AttributePtr theAttr);
49 /// Erases the first meet of the feature in the list
50 MODEL_EXPORT virtual void remove(ObjectPtr theObject);
51 /// Erases the first meet of the attribute in the list
52 MODEL_EXPORT virtual void remove(AttributePtr theAttr);
54 /// Removes all references from the list
55 MODEL_EXPORT virtual void clear();
57 /// Returns number of features in the list
58 MODEL_EXPORT virtual int size() const;
60 /// Returns the list of features and attributes (if it is reference to the attribute)
61 MODEL_EXPORT virtual std::list<std::pair<ObjectPtr, AttributePtr> > list();
63 /// Returns true if the object is in list
64 MODEL_EXPORT virtual bool isInList(const ObjectPtr& theObj);
65 /// Returns true if the attribute is in list
66 MODEL_EXPORT virtual bool isInList(const AttributePtr& theObj);
68 /// Returns true if this is reference to an attribute, not just object
69 MODEL_EXPORT virtual bool isAttribute(const int theIndex) const;
71 /// Returns the referenced object by the zero-based index
72 ///\param theIndex zero-based index in the list
73 MODEL_EXPORT virtual ObjectPtr object(const int theIndex) const;
74 /// Returns the referenced attribute by the zero-based index
75 ///\param theIndex zero-based index in the list
76 MODEL_EXPORT virtual AttributePtr attribute(const int theIndex) const;
78 /// Removes the last element in the list.
79 MODEL_EXPORT virtual void removeLast();
81 /// Removes the elements from the list.
82 /// \param theIndices a list of indices of elements to be removed
83 MODEL_EXPORT virtual void remove(const std::set<int>& theIndices);
85 /// Returns true if attribute was initialized by some value
86 MODEL_EXPORT virtual bool isInitialized();
88 /// Objects are created for features automatically
89 MODEL_EXPORT Model_AttributeRefAttrList(TDF_Label& theLabel);
90 /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
91 virtual void reinit();
93 friend class Model_Data;