1 // Copyright (C) 2014-2019 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 email : webmaster.salome@opencascade.com
20 #ifndef Model_AttributeRefAttrList_H_
21 #define Model_AttributeRefAttrList_H_
24 #include "ModelAPI_AttributeRefAttrList.h"
25 #include "ModelAPI_Feature.h"
27 #include <TDF_Label.hxx>
28 #include <TDataStd_ReferenceList.hxx>
29 #include <TDataStd_ExtStringList.hxx>
31 /**\class Model_AttributeRefAttrList
33 * \brief Attribute that contains list of references to features (located in the same document)
34 * or references to attributes of the features (list of AttributeRefAttr)
37 class Model_AttributeRefAttrList : public ModelAPI_AttributeRefAttrList
39 TDF_Label myLab; ///< the main label of this attribute
40 Handle_TDataStd_ReferenceList myRef; ///< references to the features labels
41 Handle_TDataStd_ExtStringList myIDs; ///< the referenced attributes IDs (empty for just object)
43 /// Appends the feature to the end of a list
44 MODEL_EXPORT virtual void append(ObjectPtr theObject);
45 /// Appends the attribute to the end of a list
46 MODEL_EXPORT virtual void append(AttributePtr theAttr);
48 /// Erases the first meet of the feature in the list
49 MODEL_EXPORT virtual void remove(ObjectPtr theObject);
50 /// Erases the first meet of the attribute in the list
51 MODEL_EXPORT virtual void remove(AttributePtr theAttr);
53 /// Removes all references from the list
54 MODEL_EXPORT virtual void clear();
56 /// Returns number of features in the list
57 MODEL_EXPORT virtual int size() const;
59 /// Returns the list of features and attributes (if it is reference to the attribute)
60 MODEL_EXPORT virtual std::list<std::pair<ObjectPtr, AttributePtr> > list();
62 /// Returns true if the object is in list
63 MODEL_EXPORT virtual bool isInList(const ObjectPtr& theObj);
64 /// Returns true if the attribute is in list
65 MODEL_EXPORT virtual bool isInList(const AttributePtr& theObj);
67 /// Returns true if this is reference to an attribute, not just object
68 MODEL_EXPORT virtual bool isAttribute(const int theIndex) const;
70 /// Returns the referenced object by the zero-based index
71 ///\param theIndex zero-based index in the list
72 MODEL_EXPORT virtual ObjectPtr object(const int theIndex) const;
73 /// Returns the referenced attribute by the zero-based index
74 ///\param theIndex zero-based index in the list
75 MODEL_EXPORT virtual AttributePtr attribute(const int theIndex) const;
77 /// Removes the last element in the list.
78 MODEL_EXPORT virtual void removeLast();
80 /// Removes the elements from the list.
81 /// \param theIndices a list of indices of elements to be removed
82 MODEL_EXPORT virtual void remove(const std::set<int>& theIndices);
84 /// Returns true if attribute was initialized by some value
85 MODEL_EXPORT virtual bool isInitialized();
87 /// Objects are created for features automatically
88 MODEL_EXPORT Model_AttributeRefAttrList(TDF_Label& theLabel);
89 /// Reinitializes the internal state of the attribute (may be needed on undo/redo, abort, etc)
90 virtual void reinit();
92 friend class Model_Data;