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