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