1 // Created on: 1999-07-12
2 // Created by: Denis PASCAL
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <TDocStd_Owner.hxx>
19 #include <Standard_Dump.hxx>
20 #include <Standard_GUID.hxx>
21 #include <Standard_Type.hxx>
22 #include <TDF_Attribute.hxx>
23 #include <TDF_Data.hxx>
24 #include <TDF_RelocationTable.hxx>
25 #include <TDocStd_Document.hxx>
27 IMPLEMENT_STANDARD_RTTIEXT(TDocStd_Owner,TDF_Attribute)
29 //=======================================================================
32 //=======================================================================
33 const Standard_GUID& TDocStd_Owner::GetID()
35 static Standard_GUID TDocStd_OwnerID ("2a96b617-ec8b-11d0-bee7-080009dc3333");
36 return TDocStd_OwnerID;
40 //=======================================================================
41 //function : SetDocument
43 //=======================================================================
45 void TDocStd_Owner::SetDocument (const Handle(TDF_Data)& indata,
46 const Handle(TDocStd_Document)& D)
48 Handle(TDocStd_Owner) A;
49 if (!indata->Root().FindAttribute (TDocStd_Owner::GetID(), A)) {
50 A = new TDocStd_Owner ();
52 indata->Root().AddAttribute(A);
55 throw Standard_DomainError("TDocStd_Owner::SetDocument : already called");
59 //=======================================================================
60 //function : GetDocument
62 //=======================================================================
64 Handle(TDocStd_Document) TDocStd_Owner::GetDocument (const Handle(TDF_Data)& ofdata)
66 Handle(TDocStd_Owner) A;
67 if (!ofdata->Root().FindAttribute (TDocStd_Owner::GetID(), A)) {
68 throw Standard_DomainError("TDocStd_Owner::GetDocument : document not found");
70 return A->GetDocument();
73 //=======================================================================
74 //function : TDocStd_Owner
76 //=======================================================================
78 TDocStd_Owner::TDocStd_Owner () { }
81 //=======================================================================
82 //function : SetDocument
84 //=======================================================================
86 void TDocStd_Owner::SetDocument(const Handle( TDocStd_Document)& D)
92 //=======================================================================
95 //=======================================================================
97 Handle(TDocStd_Document) TDocStd_Owner::GetDocument () const
102 //=======================================================================
105 //=======================================================================
107 const Standard_GUID& TDocStd_Owner::ID () const { return GetID(); }
110 //=======================================================================
111 //function : NewEmpty
113 //=======================================================================
115 Handle(TDF_Attribute) TDocStd_Owner::NewEmpty () const
117 Handle(TDF_Attribute) dummy;
121 //=======================================================================
124 //=======================================================================
126 void TDocStd_Owner::Restore(const Handle(TDF_Attribute)&)
130 //=======================================================================
133 //=======================================================================
135 void TDocStd_Owner::Paste (const Handle(TDF_Attribute)&,
136 const Handle(TDF_RelocationTable)&) const
140 //=======================================================================
143 //=======================================================================
145 Standard_OStream& TDocStd_Owner::Dump (Standard_OStream& anOS) const
151 //=======================================================================
152 //function : DumpJson
154 //=======================================================================
155 void TDocStd_Owner::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
157 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
159 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myDocument.get())