SHAPER  9.12.0
ModelAPI_AttributeRefList.h
1 // Copyright (C) 2014-2023 CEA, EDF
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 
20 #ifndef ModelAPI_AttributeRefList_H_
21 #define ModelAPI_AttributeRefList_H_
22 
23 #include "ModelAPI_Attribute.h"
24 #include "ModelAPI_Feature.h"
25 #include <list>
26 
33 {
34  public:
36  MODELAPI_EXPORT static std::string typeId()
37  {
38  return "RefList";
39  }
40 
42  MODELAPI_EXPORT virtual std::string attributeType();
43 
45  virtual void append(ObjectPtr theObject) = 0;
46 
48  virtual void remove(ObjectPtr theObject) = 0;
49 
51  virtual void clear() = 0;
52 
55  virtual int size(const bool theWithEmpty = true) const = 0;
56 
58  virtual std::list<ObjectPtr> list() = 0;
59 
61  virtual bool isInList(const ObjectPtr& theObj) = 0;
62 
66  virtual ObjectPtr object(const int theIndex, const bool theWithEmpty = true) = 0;
67 
69  virtual void substitute(const ObjectPtr& theCurrent, const ObjectPtr& theNew) = 0;
70 
72  virtual void removeLast() = 0;
73 
76  virtual void remove(const std::set<int>& theIndices) = 0;
77 
78  MODELAPI_EXPORT virtual ~ModelAPI_AttributeRefList();
79  protected:
81  MODELAPI_EXPORT ModelAPI_AttributeRefList();
82 
83 };
84 
85 typedef std::shared_ptr<ModelAPI_AttributeRefList> AttributeRefListPtr;
86 
87 #endif
Attribute that contains list of references to features (located in the same document).
Definition: ModelAPI_AttributeRefList.h:33
virtual void remove(const std::set< int > &theIndices)=0
Removes the elements from the list.
virtual void append(ObjectPtr theObject)=0
Appends the feature to the end of a list.
virtual std::string attributeType()
Returns the type of this class of attributes, not static method.
Definition: ModelAPI_AttributeRefList.cpp:22
virtual void substitute(const ObjectPtr &theCurrent, const ObjectPtr &theNew)=0
Substitutes the object by another one. Does nothing if such object is not found.
virtual int size(const bool theWithEmpty=true) const =0
Returns number of features in the list.
virtual void remove(ObjectPtr theObject)=0
Erases the first meet of the feature in the list.
virtual void clear()=0
Removes all references from the list.
static std::string typeId()
Returns the type of this class of attributes.
Definition: ModelAPI_AttributeRefList.h:36
virtual ObjectPtr object(const int theIndex, const bool theWithEmpty=true)=0
Returns the referenced object by the zero-based index.
ModelAPI_AttributeRefList()
Objects are created for features automatically.
Definition: ModelAPI_AttributeRefList.cpp:32
virtual void removeLast()=0
Removes the last element in the list.
virtual bool isInList(const ObjectPtr &theObj)=0
Returns true if the object is in list.
virtual std::list< ObjectPtr > list()=0
Returns the list of features.
Generic attribute of the Object.
Definition: ModelAPI_Attribute.h:34