1 // Created by: DAUTRY Philippe
2 // Copyright (c) 1997-1999 Matra Datavision
3 // Copyright (c) 1999-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.
23 //Version Date Purpose
24 // 0.0 Sep 15 1997 Creation
28 #include <TDocStd_XLinkRoot.ixx>
30 #include <TDocStd_XLink.hxx>
33 //=======================================================================
35 //=======================================================================
37 //=======================================================================
40 //=======================================================================
42 const Standard_GUID& TDocStd_XLinkRoot::GetID()
44 static Standard_GUID myID("5d587401-5690-11d1-8940-080009dc3333");
49 //=======================================================================
51 //purpose : CLASS method.
52 //=======================================================================
54 Handle(TDocStd_XLinkRoot) TDocStd_XLinkRoot::Set
55 (const Handle(TDF_Data)& aDF)
57 Handle(TDocStd_XLinkRoot) xRefRoot;
58 if (!aDF->Root().FindAttribute (TDocStd_XLinkRoot::GetID(),xRefRoot)) {
59 xRefRoot = new TDocStd_XLinkRoot;
60 aDF->Root().AddAttribute(xRefRoot);
66 //=======================================================================
69 //=======================================================================
71 void TDocStd_XLinkRoot::Insert(const TDocStd_XLinkPtr& anXLinkPtr)
73 Handle(TDocStd_XLinkRoot) xRefRoot =
74 TDocStd_XLinkRoot::Set(anXLinkPtr->Label().Data());
75 // Insertion at beginning because the order is not significant.
76 anXLinkPtr->Next(xRefRoot->First());
77 xRefRoot->First(anXLinkPtr);
81 //=======================================================================
84 //=======================================================================
86 void TDocStd_XLinkRoot::Remove(const TDocStd_XLinkPtr& anXLinkPtr)
88 Handle(TDocStd_XLinkRoot) xRefRoot;
89 if (anXLinkPtr->Label().Root().FindAttribute(TDocStd_XLinkRoot::GetID(),
91 TDocStd_XLink* previous = xRefRoot->First();
92 if (previous == anXLinkPtr) {
93 xRefRoot->First(anXLinkPtr->Next());
94 previous = NULL; anXLinkPtr->Next(previous);
97 while (previous != NULL && previous->Next() != anXLinkPtr)
98 previous = previous->Next();
99 if (previous != NULL) {
100 previous->Next(anXLinkPtr->Next());
101 previous = NULL; anXLinkPtr->Next(previous);
108 //=======================================================================
110 //=======================================================================
112 //=======================================================================
113 //function : TDocStd_XLinkRoot
115 //=======================================================================
117 TDocStd_XLinkRoot::TDocStd_XLinkRoot()
122 //=======================================================================
125 //=======================================================================
127 const Standard_GUID& TDocStd_XLinkRoot::ID() const
131 //=======================================================================
132 //function : BackupCopy
134 //=======================================================================
136 Handle(TDF_Attribute) TDocStd_XLinkRoot::BackupCopy() const
137 { return new TDocStd_XLinkRoot; } // Does nothing.
140 //=======================================================================
143 //=======================================================================
145 void TDocStd_XLinkRoot::Restore(const Handle(TDF_Attribute)& /*anAttribute*/)
149 //=======================================================================
150 //function : NewEmpty
152 //=======================================================================
154 Handle(TDF_Attribute) TDocStd_XLinkRoot::NewEmpty() const
155 { return new TDocStd_XLinkRoot; }
158 //=======================================================================
161 //=======================================================================
163 void TDocStd_XLinkRoot::Paste
164 (const Handle(TDF_Attribute)&,
165 const Handle(TDF_RelocationTable)&) const
169 //=======================================================================
172 //=======================================================================
174 Standard_OStream& TDocStd_XLinkRoot::Dump(Standard_OStream& anOS) const