0026912: CLang 3.6.2 compiler warning [-Winconsistent-missing-override]
[occt.git] / src / TDataStd / TDataStd_ReferenceList.cxx
CommitLineData
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
42cf5bc1 16
17#include <Standard_GUID.hxx>
18#include <Standard_Type.hxx>
19#include <TDataStd_ReferenceList.hxx>
20#include <TDF_Attribute.hxx>
21#include <TDF_DataSet.hxx>
22#include <TDF_Label.hxx>
7fd59977 23#include <TDF_ListIteratorOfLabelList.hxx>
42cf5bc1 24#include <TDF_RelocationTable.hxx>
7fd59977 25
26//=======================================================================
27//function : GetID
28//purpose :
29//=======================================================================
30const Standard_GUID& TDataStd_ReferenceList::GetID()
31{
32 static Standard_GUID TDataStd_ReferenceListID ("FCC1A658-59FF-4218-931B-0320A2B469A7");
33 return TDataStd_ReferenceListID;
34}
35
36//=======================================================================
37//function : TDataStd_ReferenceList
38//purpose : Empty Constructor
39//=======================================================================
40TDataStd_ReferenceList::TDataStd_ReferenceList()
41{
42
43}
44
45//=======================================================================
46//function : Set
47//purpose :
48//=======================================================================
49Handle(TDataStd_ReferenceList) TDataStd_ReferenceList::Set(const TDF_Label& label)
50{
51 Handle(TDataStd_ReferenceList) A;
52 if (!label.FindAttribute (TDataStd_ReferenceList::GetID(), A))
53 {
54 A = new TDataStd_ReferenceList;
55 label.AddAttribute(A);
56 }
57 return A;
58}
59
60//=======================================================================
61//function : IsEmpty
62//purpose :
63//=======================================================================
64Standard_Boolean TDataStd_ReferenceList::IsEmpty() const
65{
66 return myList.IsEmpty();
67}
68
69//=======================================================================
70//function : Extent
71//purpose :
72//=======================================================================
73Standard_Integer TDataStd_ReferenceList::Extent() const
74{
75 return myList.Extent();
76}
77
78//=======================================================================
79//function : Prepend
80//purpose :
81//=======================================================================
82void TDataStd_ReferenceList::Prepend(const TDF_Label& value)
83{
84 Backup();
85 myList.Prepend(value);
86}
87
88//=======================================================================
89//function : Append
90//purpose :
91//=======================================================================
92void TDataStd_ReferenceList::Append(const TDF_Label& value)
93{
94 Backup();
95 myList.Append(value);
96}
97
98//=======================================================================
99//function : InsertBefore
100//purpose :
101//=======================================================================
102Standard_Boolean TDataStd_ReferenceList::InsertBefore(const TDF_Label& value,
103 const TDF_Label& before_value)
104{
105 TDF_ListIteratorOfLabelList itr(myList);
106 for (; itr.More(); itr.Next())
107 {
108 if (itr.Value() == before_value)
109 {
110 Backup();
111 myList.InsertBefore(value, itr);
112 return Standard_True;
113 }
114 }
115 return Standard_False;
116}
117
118//=======================================================================
119//function : InsertAfter
120//purpose :
121//=======================================================================
122Standard_Boolean TDataStd_ReferenceList::InsertAfter(const TDF_Label& value,
123 const TDF_Label& after_value)
124{
125 TDF_ListIteratorOfLabelList itr(myList);
126 for (; itr.More(); itr.Next())
127 {
128 if (itr.Value() == after_value)
129 {
130 Backup();
131 myList.InsertAfter(value, itr);
132 return Standard_True;
133 }
134 }
135 return Standard_False;
136}
137
138//=======================================================================
139//function : Remove
140//purpose :
141//=======================================================================
142Standard_Boolean TDataStd_ReferenceList::Remove(const TDF_Label& value)
143{
144 TDF_ListIteratorOfLabelList itr(myList);
145 for (; itr.More(); itr.Next())
146 {
147 if (itr.Value() == value)
148 {
149 Backup();
150 myList.Remove(itr);
151 return Standard_True;
152 }
153 }
154 return Standard_False;
155}
156
157//=======================================================================
158//function : Clear
159//purpose :
160//=======================================================================
161void TDataStd_ReferenceList::Clear()
162{
163 Backup();
164 myList.Clear();
165}
166
167//=======================================================================
168//function : First
169//purpose :
170//=======================================================================
171const TDF_Label& TDataStd_ReferenceList::First() const
172{
173 return myList.First();
174}
175
176//=======================================================================
177//function : Last
178//purpose :
179//=======================================================================
180const TDF_Label& TDataStd_ReferenceList::Last() const
181{
182 return myList.Last();
183}
184
185//=======================================================================
186//function : List
187//purpose :
188//=======================================================================
189const TDF_LabelList& TDataStd_ReferenceList::List() const
190{
191 return myList;
192}
193
194//=======================================================================
195//function : ID
196//purpose :
197//=======================================================================
198const Standard_GUID& TDataStd_ReferenceList::ID () const
199{
200 return GetID();
201}
202
203//=======================================================================
204//function : NewEmpty
205//purpose :
206//=======================================================================
207Handle(TDF_Attribute) TDataStd_ReferenceList::NewEmpty () const
208{
209 return new TDataStd_ReferenceList();
210}
211
212//=======================================================================
213//function : Restore
214//purpose :
215//=======================================================================
216void TDataStd_ReferenceList::Restore(const Handle(TDF_Attribute)& With)
217{
218 myList.Clear();
219 Handle(TDataStd_ReferenceList) aList = Handle(TDataStd_ReferenceList)::DownCast(With);
220 TDF_ListIteratorOfLabelList itr(aList->List());
221 for (; itr.More(); itr.Next())
222 {
223 myList.Append(itr.Value());
224 }
225}
226
227//=======================================================================
228//function : Paste
229//purpose :
230//=======================================================================
231void TDataStd_ReferenceList::Paste (const Handle(TDF_Attribute)& Into,
232 const Handle(TDF_RelocationTable)& RT) const
233{
234 Handle(TDataStd_ReferenceList) aList = Handle(TDataStd_ReferenceList)::DownCast(Into);
235 aList->Clear();
236 TDF_ListIteratorOfLabelList itr(myList);
237 for (; itr.More(); itr.Next())
238 {
239 TDF_Label L = itr.Value(), rL;
240 if (!L.IsNull())
241 {
242 if (!RT->HasRelocation(L, rL))
243 rL = L;
244 aList->Append(rL);
245 }
246 }
247}
248
249//=======================================================================
250//function : References
251//purpose : Adds the referenced attributes or labels.
252//=======================================================================
253void TDataStd_ReferenceList::References(const Handle(TDF_DataSet)& aDataSet) const
254{
255 if (!Label().IsImported())
256 {
257 TDF_ListIteratorOfLabelList itr(myList);
258 for (; itr.More(); itr.Next())
259 {
260 aDataSet->AddLabel(itr.Value());
261 }
262 }
263}
264
265//=======================================================================
266//function : Dump
267//purpose :
268//=======================================================================
269Standard_OStream& TDataStd_ReferenceList::Dump (Standard_OStream& anOS) const
270{
271 anOS << "ReferenceList";
272 return anOS;
273}