b311480e |
1 | // Created on: 2007-05-29 |
2 | // Created by: Vlad Romashko |
973c2be1 |
3 | // Copyright (c) 2007-2014 OPEN CASCADE SAS |
b311480e |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
b311480e |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
7fd59977 |
15 | |
16 | #include <TDataStd_IntegerList.ixx> |
17 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
18 | |
19 | //======================================================================= |
20 | //function : GetID |
21 | //purpose : |
22 | //======================================================================= |
23 | const Standard_GUID& TDataStd_IntegerList::GetID() |
24 | { |
25 | static Standard_GUID TDataStd_IntegerListID ("E406AA18-FF3F-483b-9A78-1A5EA5D1AA52"); |
26 | return TDataStd_IntegerListID; |
27 | } |
28 | |
29 | //======================================================================= |
30 | //function : TDataStd_IntegerList |
31 | //purpose : Empty Constructor |
32 | //======================================================================= |
33 | TDataStd_IntegerList::TDataStd_IntegerList() |
34 | { |
35 | |
36 | } |
37 | |
38 | //======================================================================= |
39 | //function : Set |
40 | //purpose : |
41 | //======================================================================= |
42 | Handle(TDataStd_IntegerList) TDataStd_IntegerList::Set(const TDF_Label& label) |
43 | { |
44 | Handle(TDataStd_IntegerList) A; |
45 | if (!label.FindAttribute (TDataStd_IntegerList::GetID(), A)) |
46 | { |
47 | A = new TDataStd_IntegerList; |
48 | label.AddAttribute(A); |
49 | } |
50 | return A; |
51 | } |
52 | |
53 | //======================================================================= |
54 | //function : IsEmpty |
55 | //purpose : |
56 | //======================================================================= |
57 | Standard_Boolean TDataStd_IntegerList::IsEmpty() const |
58 | { |
59 | return myList.IsEmpty(); |
60 | } |
61 | |
62 | //======================================================================= |
63 | //function : Extent |
64 | //purpose : |
65 | //======================================================================= |
66 | Standard_Integer TDataStd_IntegerList::Extent() const |
67 | { |
68 | return myList.Extent(); |
69 | } |
70 | |
71 | //======================================================================= |
72 | //function : Prepend |
73 | //purpose : |
74 | //======================================================================= |
75 | void TDataStd_IntegerList::Prepend(const Standard_Integer value) |
76 | { |
77 | Backup(); |
78 | myList.Prepend(value); |
79 | } |
80 | |
81 | //======================================================================= |
82 | //function : Append |
83 | //purpose : |
84 | //======================================================================= |
85 | void TDataStd_IntegerList::Append(const Standard_Integer value) |
86 | { |
87 | Backup(); |
88 | myList.Append(value); |
89 | } |
90 | |
91 | //======================================================================= |
92 | //function : InsertBefore |
93 | //purpose : |
94 | //======================================================================= |
95 | Standard_Boolean TDataStd_IntegerList::InsertBefore(const Standard_Integer value, |
96 | const Standard_Integer before_value) |
97 | { |
98 | TColStd_ListIteratorOfListOfInteger itr(myList); |
99 | for (; itr.More(); itr.Next()) |
100 | { |
101 | if (itr.Value() == before_value) |
102 | { |
103 | Backup(); |
104 | myList.InsertBefore(value, itr); |
105 | return Standard_True; |
106 | } |
107 | } |
108 | return Standard_False; |
109 | } |
110 | |
111 | //======================================================================= |
112 | //function : InsertAfter |
113 | //purpose : |
114 | //======================================================================= |
115 | Standard_Boolean TDataStd_IntegerList::InsertAfter(const Standard_Integer value, |
116 | const Standard_Integer after_value) |
117 | { |
118 | TColStd_ListIteratorOfListOfInteger itr(myList); |
119 | for (; itr.More(); itr.Next()) |
120 | { |
121 | if (itr.Value() == after_value) |
122 | { |
123 | Backup(); |
124 | myList.InsertAfter(value, itr); |
125 | return Standard_True; |
126 | } |
127 | } |
128 | return Standard_False; |
129 | } |
130 | |
131 | //======================================================================= |
132 | //function : Remove |
133 | //purpose : |
134 | //======================================================================= |
135 | Standard_Boolean TDataStd_IntegerList::Remove(const Standard_Integer value) |
136 | { |
137 | TColStd_ListIteratorOfListOfInteger itr(myList); |
138 | for (; itr.More(); itr.Next()) |
139 | { |
140 | if (itr.Value() == value) |
141 | { |
142 | Backup(); |
143 | myList.Remove(itr); |
144 | return Standard_True; |
145 | } |
146 | } |
147 | return Standard_False; |
148 | } |
149 | |
150 | //======================================================================= |
151 | //function : Clear |
152 | //purpose : |
153 | //======================================================================= |
154 | void TDataStd_IntegerList::Clear() |
155 | { |
156 | Backup(); |
157 | myList.Clear(); |
158 | } |
159 | |
160 | //======================================================================= |
161 | //function : First |
162 | //purpose : |
163 | //======================================================================= |
164 | Standard_Integer TDataStd_IntegerList::First() const |
165 | { |
166 | return myList.First(); |
167 | } |
168 | |
169 | //======================================================================= |
170 | //function : Last |
171 | //purpose : |
172 | //======================================================================= |
173 | Standard_Integer TDataStd_IntegerList::Last() const |
174 | { |
175 | return myList.Last(); |
176 | } |
177 | |
178 | //======================================================================= |
179 | //function : List |
180 | //purpose : |
181 | //======================================================================= |
182 | const TColStd_ListOfInteger& TDataStd_IntegerList::List() const |
183 | { |
184 | return myList; |
185 | } |
186 | |
187 | //======================================================================= |
188 | //function : ID |
189 | //purpose : |
190 | //======================================================================= |
191 | const Standard_GUID& TDataStd_IntegerList::ID () const |
192 | { |
193 | return GetID(); |
194 | } |
195 | |
196 | //======================================================================= |
197 | //function : NewEmpty |
198 | //purpose : |
199 | //======================================================================= |
200 | Handle(TDF_Attribute) TDataStd_IntegerList::NewEmpty () const |
201 | { |
202 | return new TDataStd_IntegerList(); |
203 | } |
204 | |
205 | //======================================================================= |
206 | //function : Restore |
207 | //purpose : |
208 | //======================================================================= |
209 | void TDataStd_IntegerList::Restore(const Handle(TDF_Attribute)& With) |
210 | { |
211 | myList.Clear(); |
212 | Handle(TDataStd_IntegerList) aList = Handle(TDataStd_IntegerList)::DownCast(With); |
213 | TColStd_ListIteratorOfListOfInteger itr(aList->List()); |
214 | for (; itr.More(); itr.Next()) |
215 | { |
216 | myList.Append(itr.Value()); |
217 | } |
218 | } |
219 | |
220 | //======================================================================= |
221 | //function : Paste |
222 | //purpose : |
223 | //======================================================================= |
224 | void TDataStd_IntegerList::Paste (const Handle(TDF_Attribute)& Into, |
225 | const Handle(TDF_RelocationTable)& ) const |
226 | { |
227 | Handle(TDataStd_IntegerList) aList = Handle(TDataStd_IntegerList)::DownCast(Into); |
228 | aList->Clear(); |
229 | TColStd_ListIteratorOfListOfInteger itr(myList); |
230 | for (; itr.More(); itr.Next()) |
231 | { |
232 | aList->Append(itr.Value()); |
233 | } |
234 | } |
235 | |
236 | //======================================================================= |
237 | //function : Dump |
238 | //purpose : |
239 | //======================================================================= |
240 | Standard_OStream& TDataStd_IntegerList::Dump (Standard_OStream& anOS) const |
241 | { |
242 | anOS << "IntegerList"; |
243 | return anOS; |
244 | } |