1 // Created on: 2007-05-29
2 // Created by: Vlad Romashko
3 // Copyright (c) 2007-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <TDataStd_IntegerList.ixx>
17 #include <TColStd_ListIteratorOfListOfInteger.hxx>
19 //=======================================================================
22 //=======================================================================
23 const Standard_GUID& TDataStd_IntegerList::GetID()
25 static Standard_GUID TDataStd_IntegerListID ("E406AA18-FF3F-483b-9A78-1A5EA5D1AA52");
26 return TDataStd_IntegerListID;
29 //=======================================================================
30 //function : TDataStd_IntegerList
31 //purpose : Empty Constructor
32 //=======================================================================
33 TDataStd_IntegerList::TDataStd_IntegerList()
38 //=======================================================================
41 //=======================================================================
42 Handle(TDataStd_IntegerList) TDataStd_IntegerList::Set(const TDF_Label& label)
44 Handle(TDataStd_IntegerList) A;
45 if (!label.FindAttribute (TDataStd_IntegerList::GetID(), A))
47 A = new TDataStd_IntegerList;
48 label.AddAttribute(A);
53 //=======================================================================
56 //=======================================================================
57 Standard_Boolean TDataStd_IntegerList::IsEmpty() const
59 return myList.IsEmpty();
62 //=======================================================================
65 //=======================================================================
66 Standard_Integer TDataStd_IntegerList::Extent() const
68 return myList.Extent();
71 //=======================================================================
74 //=======================================================================
75 void TDataStd_IntegerList::Prepend(const Standard_Integer value)
78 myList.Prepend(value);
81 //=======================================================================
84 //=======================================================================
85 void TDataStd_IntegerList::Append(const Standard_Integer value)
91 //=======================================================================
92 //function : InsertBefore
94 //=======================================================================
95 Standard_Boolean TDataStd_IntegerList::InsertBefore(const Standard_Integer value,
96 const Standard_Integer before_value)
98 TColStd_ListIteratorOfListOfInteger itr(myList);
99 for (; itr.More(); itr.Next())
101 if (itr.Value() == before_value)
104 myList.InsertBefore(value, itr);
105 return Standard_True;
108 return Standard_False;
111 //=======================================================================
112 //function : InsertAfter
114 //=======================================================================
115 Standard_Boolean TDataStd_IntegerList::InsertAfter(const Standard_Integer value,
116 const Standard_Integer after_value)
118 TColStd_ListIteratorOfListOfInteger itr(myList);
119 for (; itr.More(); itr.Next())
121 if (itr.Value() == after_value)
124 myList.InsertAfter(value, itr);
125 return Standard_True;
128 return Standard_False;
131 //=======================================================================
134 //=======================================================================
135 Standard_Boolean TDataStd_IntegerList::Remove(const Standard_Integer value)
137 TColStd_ListIteratorOfListOfInteger itr(myList);
138 for (; itr.More(); itr.Next())
140 if (itr.Value() == value)
144 return Standard_True;
147 return Standard_False;
150 //=======================================================================
153 //=======================================================================
154 void TDataStd_IntegerList::Clear()
160 //=======================================================================
163 //=======================================================================
164 Standard_Integer TDataStd_IntegerList::First() const
166 return myList.First();
169 //=======================================================================
172 //=======================================================================
173 Standard_Integer TDataStd_IntegerList::Last() const
175 return myList.Last();
178 //=======================================================================
181 //=======================================================================
182 const TColStd_ListOfInteger& TDataStd_IntegerList::List() const
187 //=======================================================================
190 //=======================================================================
191 const Standard_GUID& TDataStd_IntegerList::ID () const
196 //=======================================================================
197 //function : NewEmpty
199 //=======================================================================
200 Handle(TDF_Attribute) TDataStd_IntegerList::NewEmpty () const
202 return new TDataStd_IntegerList();
205 //=======================================================================
208 //=======================================================================
209 void TDataStd_IntegerList::Restore(const Handle(TDF_Attribute)& With)
212 Handle(TDataStd_IntegerList) aList = Handle(TDataStd_IntegerList)::DownCast(With);
213 TColStd_ListIteratorOfListOfInteger itr(aList->List());
214 for (; itr.More(); itr.Next())
216 myList.Append(itr.Value());
220 //=======================================================================
223 //=======================================================================
224 void TDataStd_IntegerList::Paste (const Handle(TDF_Attribute)& Into,
225 const Handle(TDF_RelocationTable)& ) const
227 Handle(TDataStd_IntegerList) aList = Handle(TDataStd_IntegerList)::DownCast(Into);
229 TColStd_ListIteratorOfListOfInteger itr(myList);
230 for (; itr.More(); itr.Next())
232 aList->Append(itr.Value());
236 //=======================================================================
239 //=======================================================================
240 Standard_OStream& TDataStd_IntegerList::Dump (Standard_OStream& anOS) const
242 anOS << "IntegerList";