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_ReferenceList.ixx>
22 #include <TDF_ListIteratorOfLabelList.hxx>
24 //=======================================================================
27 //=======================================================================
28 const Standard_GUID& TDataStd_ReferenceList::GetID()
30 static Standard_GUID TDataStd_ReferenceListID ("FCC1A658-59FF-4218-931B-0320A2B469A7");
31 return TDataStd_ReferenceListID;
34 //=======================================================================
35 //function : TDataStd_ReferenceList
36 //purpose : Empty Constructor
37 //=======================================================================
38 TDataStd_ReferenceList::TDataStd_ReferenceList()
43 //=======================================================================
46 //=======================================================================
47 Handle(TDataStd_ReferenceList) TDataStd_ReferenceList::Set(const TDF_Label& label)
49 Handle(TDataStd_ReferenceList) A;
50 if (!label.FindAttribute (TDataStd_ReferenceList::GetID(), A))
52 A = new TDataStd_ReferenceList;
53 label.AddAttribute(A);
58 //=======================================================================
61 //=======================================================================
62 Standard_Boolean TDataStd_ReferenceList::IsEmpty() const
64 return myList.IsEmpty();
67 //=======================================================================
70 //=======================================================================
71 Standard_Integer TDataStd_ReferenceList::Extent() const
73 return myList.Extent();
76 //=======================================================================
79 //=======================================================================
80 void TDataStd_ReferenceList::Prepend(const TDF_Label& value)
83 myList.Prepend(value);
86 //=======================================================================
89 //=======================================================================
90 void TDataStd_ReferenceList::Append(const TDF_Label& value)
96 //=======================================================================
97 //function : InsertBefore
99 //=======================================================================
100 Standard_Boolean TDataStd_ReferenceList::InsertBefore(const TDF_Label& value,
101 const TDF_Label& before_value)
103 TDF_ListIteratorOfLabelList 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_ReferenceList::InsertAfter(const TDF_Label& value,
121 const TDF_Label& after_value)
123 TDF_ListIteratorOfLabelList 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_ReferenceList::Remove(const TDF_Label& value)
142 TDF_ListIteratorOfLabelList 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_ReferenceList::Clear()
165 //=======================================================================
168 //=======================================================================
169 const TDF_Label& TDataStd_ReferenceList::First() const
171 return myList.First();
174 //=======================================================================
177 //=======================================================================
178 const TDF_Label& TDataStd_ReferenceList::Last() const
180 return myList.Last();
183 //=======================================================================
186 //=======================================================================
187 const TDF_LabelList& TDataStd_ReferenceList::List() const
192 //=======================================================================
195 //=======================================================================
196 const Standard_GUID& TDataStd_ReferenceList::ID () const
201 //=======================================================================
202 //function : NewEmpty
204 //=======================================================================
205 Handle(TDF_Attribute) TDataStd_ReferenceList::NewEmpty () const
207 return new TDataStd_ReferenceList();
210 //=======================================================================
213 //=======================================================================
214 void TDataStd_ReferenceList::Restore(const Handle(TDF_Attribute)& With)
217 Handle(TDataStd_ReferenceList) aList = Handle(TDataStd_ReferenceList)::DownCast(With);
218 TDF_ListIteratorOfLabelList itr(aList->List());
219 for (; itr.More(); itr.Next())
221 myList.Append(itr.Value());
225 //=======================================================================
228 //=======================================================================
229 void TDataStd_ReferenceList::Paste (const Handle(TDF_Attribute)& Into,
230 const Handle(TDF_RelocationTable)& RT) const
232 Handle(TDataStd_ReferenceList) aList = Handle(TDataStd_ReferenceList)::DownCast(Into);
234 TDF_ListIteratorOfLabelList itr(myList);
235 for (; itr.More(); itr.Next())
237 TDF_Label L = itr.Value(), rL;
240 if (!RT->HasRelocation(L, rL))
247 //=======================================================================
248 //function : References
249 //purpose : Adds the referenced attributes or labels.
250 //=======================================================================
251 void TDataStd_ReferenceList::References(const Handle(TDF_DataSet)& aDataSet) const
253 if (!Label().IsImported())
255 TDF_ListIteratorOfLabelList itr(myList);
256 for (; itr.More(); itr.Next())
258 aDataSet->AddLabel(itr.Value());
263 //=======================================================================
266 //=======================================================================
267 Standard_OStream& TDataStd_ReferenceList::Dump (Standard_OStream& anOS) const
269 anOS << "ReferenceList";