1 // Created on: 2007-05-29
2 // Created by: Vlad Romashko
3 // Copyright (c) 2007-2012 OPEN CASCADE SAS
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
21 #include <TDataStd_IntegerList.ixx>
22 #include <TColStd_ListIteratorOfListOfInteger.hxx>
24 //=======================================================================
27 //=======================================================================
28 const Standard_GUID& TDataStd_IntegerList::GetID()
30 static Standard_GUID TDataStd_IntegerListID ("E406AA18-FF3F-483b-9A78-1A5EA5D1AA52");
31 return TDataStd_IntegerListID;
34 //=======================================================================
35 //function : TDataStd_IntegerList
36 //purpose : Empty Constructor
37 //=======================================================================
38 TDataStd_IntegerList::TDataStd_IntegerList()
43 //=======================================================================
46 //=======================================================================
47 Handle(TDataStd_IntegerList) TDataStd_IntegerList::Set(const TDF_Label& label)
49 Handle(TDataStd_IntegerList) A;
50 if (!label.FindAttribute (TDataStd_IntegerList::GetID(), A))
52 A = new TDataStd_IntegerList;
53 label.AddAttribute(A);
58 //=======================================================================
61 //=======================================================================
62 Standard_Boolean TDataStd_IntegerList::IsEmpty() const
64 return myList.IsEmpty();
67 //=======================================================================
70 //=======================================================================
71 Standard_Integer TDataStd_IntegerList::Extent() const
73 return myList.Extent();
76 //=======================================================================
79 //=======================================================================
80 void TDataStd_IntegerList::Prepend(const Standard_Integer value)
83 myList.Prepend(value);
86 //=======================================================================
89 //=======================================================================
90 void TDataStd_IntegerList::Append(const Standard_Integer value)
96 //=======================================================================
97 //function : InsertBefore
99 //=======================================================================
100 Standard_Boolean TDataStd_IntegerList::InsertBefore(const Standard_Integer value,
101 const Standard_Integer before_value)
103 TColStd_ListIteratorOfListOfInteger itr(myList);
104 for (; itr.More(); itr.Next())
106 if (itr.Value() == before_value)
109 myList.InsertBefore(value, itr);
110 return Standard_True;
113 return Standard_False;
116 //=======================================================================
117 //function : InsertAfter
119 //=======================================================================
120 Standard_Boolean TDataStd_IntegerList::InsertAfter(const Standard_Integer value,
121 const Standard_Integer after_value)
123 TColStd_ListIteratorOfListOfInteger itr(myList);
124 for (; itr.More(); itr.Next())
126 if (itr.Value() == after_value)
129 myList.InsertAfter(value, itr);
130 return Standard_True;
133 return Standard_False;
136 //=======================================================================
139 //=======================================================================
140 Standard_Boolean TDataStd_IntegerList::Remove(const Standard_Integer value)
142 TColStd_ListIteratorOfListOfInteger itr(myList);
143 for (; itr.More(); itr.Next())
145 if (itr.Value() == value)
149 return Standard_True;
152 return Standard_False;
155 //=======================================================================
158 //=======================================================================
159 void TDataStd_IntegerList::Clear()
165 //=======================================================================
168 //=======================================================================
169 Standard_Integer TDataStd_IntegerList::First() const
171 return myList.First();
174 //=======================================================================
177 //=======================================================================
178 Standard_Integer TDataStd_IntegerList::Last() const
180 return myList.Last();
183 //=======================================================================
186 //=======================================================================
187 const TColStd_ListOfInteger& TDataStd_IntegerList::List() const
192 //=======================================================================
195 //=======================================================================
196 const Standard_GUID& TDataStd_IntegerList::ID () const
201 //=======================================================================
202 //function : NewEmpty
204 //=======================================================================
205 Handle(TDF_Attribute) TDataStd_IntegerList::NewEmpty () const
207 return new TDataStd_IntegerList();
210 //=======================================================================
213 //=======================================================================
214 void TDataStd_IntegerList::Restore(const Handle(TDF_Attribute)& With)
217 Handle(TDataStd_IntegerList) aList = Handle(TDataStd_IntegerList)::DownCast(With);
218 TColStd_ListIteratorOfListOfInteger itr(aList->List());
219 for (; itr.More(); itr.Next())
221 myList.Append(itr.Value());
225 //=======================================================================
228 //=======================================================================
229 void TDataStd_IntegerList::Paste (const Handle(TDF_Attribute)& Into,
230 const Handle(TDF_RelocationTable)& ) const
232 Handle(TDataStd_IntegerList) aList = Handle(TDataStd_IntegerList)::DownCast(Into);
234 TColStd_ListIteratorOfListOfInteger itr(myList);
235 for (; itr.More(); itr.Next())
237 aList->Append(itr.Value());
241 //=======================================================================
244 //=======================================================================
245 Standard_OStream& TDataStd_IntegerList::Dump (Standard_OStream& anOS) const
247 anOS << "IntegerList";