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.
17 #include <Standard_GUID.hxx>
18 #include <Standard_Type.hxx>
19 #include <TColStd_ListIteratorOfListOfInteger.hxx>
20 #include <TDataStd_IntegerList.hxx>
21 #include <TDF_Attribute.hxx>
22 #include <TDF_Label.hxx>
23 #include <TDF_RelocationTable.hxx>
25 IMPLEMENT_STANDARD_RTTIEXT(TDataStd_IntegerList,TDF_Attribute)
27 //=======================================================================
30 //=======================================================================
31 const Standard_GUID& TDataStd_IntegerList::GetID()
33 static Standard_GUID TDataStd_IntegerListID ("E406AA18-FF3F-483b-9A78-1A5EA5D1AA52");
34 return TDataStd_IntegerListID;
37 //=======================================================================
38 //function : TDataStd_IntegerList
39 //purpose : Empty Constructor
40 //=======================================================================
41 TDataStd_IntegerList::TDataStd_IntegerList()
46 //=======================================================================
49 //=======================================================================
50 Handle(TDataStd_IntegerList) TDataStd_IntegerList::Set(const TDF_Label& label)
52 Handle(TDataStd_IntegerList) A;
53 if (!label.FindAttribute (TDataStd_IntegerList::GetID(), A))
55 A = new TDataStd_IntegerList;
56 label.AddAttribute(A);
61 //=======================================================================
64 //=======================================================================
65 Standard_Boolean TDataStd_IntegerList::IsEmpty() const
67 return myList.IsEmpty();
70 //=======================================================================
73 //=======================================================================
74 Standard_Integer TDataStd_IntegerList::Extent() const
76 return myList.Extent();
79 //=======================================================================
82 //=======================================================================
83 void TDataStd_IntegerList::Prepend(const Standard_Integer value)
86 myList.Prepend(value);
89 //=======================================================================
92 //=======================================================================
93 void TDataStd_IntegerList::Append(const Standard_Integer value)
99 //=======================================================================
100 //function : InsertBefore
102 //=======================================================================
103 Standard_Boolean TDataStd_IntegerList::InsertBefore(const Standard_Integer value,
104 const Standard_Integer before_value)
106 TColStd_ListIteratorOfListOfInteger itr(myList);
107 for (; itr.More(); itr.Next())
109 if (itr.Value() == before_value)
112 myList.InsertBefore(value, itr);
113 return Standard_True;
116 return Standard_False;
119 //=======================================================================
120 //function : InsertAfter
122 //=======================================================================
123 Standard_Boolean TDataStd_IntegerList::InsertAfter(const Standard_Integer value,
124 const Standard_Integer after_value)
126 TColStd_ListIteratorOfListOfInteger itr(myList);
127 for (; itr.More(); itr.Next())
129 if (itr.Value() == after_value)
132 myList.InsertAfter(value, itr);
133 return Standard_True;
136 return Standard_False;
139 //=======================================================================
142 //=======================================================================
143 Standard_Boolean TDataStd_IntegerList::Remove(const Standard_Integer value)
145 TColStd_ListIteratorOfListOfInteger itr(myList);
146 for (; itr.More(); itr.Next())
148 if (itr.Value() == value)
152 return Standard_True;
155 return Standard_False;
158 //=======================================================================
161 //=======================================================================
162 void TDataStd_IntegerList::Clear()
168 //=======================================================================
171 //=======================================================================
172 Standard_Integer TDataStd_IntegerList::First() const
174 return myList.First();
177 //=======================================================================
180 //=======================================================================
181 Standard_Integer TDataStd_IntegerList::Last() const
183 return myList.Last();
186 //=======================================================================
189 //=======================================================================
190 const TColStd_ListOfInteger& TDataStd_IntegerList::List() const
195 //=======================================================================
198 //=======================================================================
199 const Standard_GUID& TDataStd_IntegerList::ID () const
204 //=======================================================================
205 //function : NewEmpty
207 //=======================================================================
208 Handle(TDF_Attribute) TDataStd_IntegerList::NewEmpty () const
210 return new TDataStd_IntegerList();
213 //=======================================================================
216 //=======================================================================
217 void TDataStd_IntegerList::Restore(const Handle(TDF_Attribute)& With)
220 Handle(TDataStd_IntegerList) aList = Handle(TDataStd_IntegerList)::DownCast(With);
221 TColStd_ListIteratorOfListOfInteger itr(aList->List());
222 for (; itr.More(); itr.Next())
224 myList.Append(itr.Value());
228 //=======================================================================
231 //=======================================================================
232 void TDataStd_IntegerList::Paste (const Handle(TDF_Attribute)& Into,
233 const Handle(TDF_RelocationTable)& ) const
235 Handle(TDataStd_IntegerList) aList = Handle(TDataStd_IntegerList)::DownCast(Into);
237 TColStd_ListIteratorOfListOfInteger itr(myList);
238 for (; itr.More(); itr.Next())
240 aList->Append(itr.Value());
244 //=======================================================================
247 //=======================================================================
248 Standard_OStream& TDataStd_IntegerList::Dump (Standard_OStream& anOS) const
250 anOS << "IntegerList";