0031075: Application Framework - reading STEP file into TDocStd_Document leads to...
[occt.git] / src / TDocStd / TDocStd_Owner.cxx
CommitLineData
b311480e 1// Created on: 1999-07-12
2// Created by: Denis PASCAL
3// Copyright (c) 1999-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
bc73b006 17#include <TDocStd_Owner.hxx>
42cf5bc1 18
bc73b006 19#include <Standard_Dump.hxx>
42cf5bc1 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>
7fd59977 26
92efcf78 27IMPLEMENT_STANDARD_RTTIEXT(TDocStd_Owner,TDF_Attribute)
28
7fd59977 29//=======================================================================
30//function : GetID
31//purpose :
32//=======================================================================
7fd59977 33const Standard_GUID& TDocStd_Owner::GetID()
34{
35 static Standard_GUID TDocStd_OwnerID ("2a96b617-ec8b-11d0-bee7-080009dc3333");
36 return TDocStd_OwnerID;
37}
38
39
40//=======================================================================
41//function : SetDocument
42//purpose :
43//=======================================================================
44
45void TDocStd_Owner::SetDocument (const Handle(TDF_Data)& indata,
ef779ae0 46 const Handle(TDocStd_Document)& doc)
7fd59977 47{
48 Handle(TDocStd_Owner) A;
49 if (!indata->Root().FindAttribute (TDocStd_Owner::GetID(), A)) {
50 A = new TDocStd_Owner ();
ef779ae0 51 A->SetDocument(doc);
52 indata->Root().AddAttribute(A);
53 }
54 else {
55 throw Standard_DomainError("TDocStd_Owner::SetDocument : already called");
56 }
57}
58
59//=======================================================================
60//function : SetDocument
61//purpose :
62//=======================================================================
63
64void TDocStd_Owner::SetDocument (const Handle(TDF_Data)& indata,
65 TDocStd_Document* doc)
66{
67 Handle(TDocStd_Owner) A;
68 if (!indata->Root().FindAttribute (TDocStd_Owner::GetID(), A)) {
69 A = new TDocStd_Owner ();
70 A->SetDocument(doc);
7fd59977 71 indata->Root().AddAttribute(A);
72 }
73 else {
9775fa61 74 throw Standard_DomainError("TDocStd_Owner::SetDocument : already called");
7fd59977 75 }
76}
77
78//=======================================================================
79//function : GetDocument
80//purpose :
81//=======================================================================
82
83Handle(TDocStd_Document) TDocStd_Owner::GetDocument (const Handle(TDF_Data)& ofdata)
84{
85 Handle(TDocStd_Owner) A;
86 if (!ofdata->Root().FindAttribute (TDocStd_Owner::GetID(), A)) {
9775fa61 87 throw Standard_DomainError("TDocStd_Owner::GetDocument : document not found");
7fd59977 88 }
89 return A->GetDocument();
90}
91
92//=======================================================================
93//function : TDocStd_Owner
94//purpose :
95//=======================================================================
96
ef779ae0 97TDocStd_Owner::TDocStd_Owner() { }
7fd59977 98
99
100//=======================================================================
101//function : SetDocument
102//purpose :
103//=======================================================================
104
ef779ae0 105void TDocStd_Owner::SetDocument (const Handle( TDocStd_Document)& document)
7fd59977 106{
ef779ae0 107 myDocument = document.get();
7fd59977 108}
109
ef779ae0 110//=======================================================================
111//function : SetDocument
112//purpose :
113//=======================================================================
114
115void TDocStd_Owner::SetDocument (TDocStd_Document* document)
116{
117 myDocument = document;
118}
7fd59977 119
120//=======================================================================
121//function : Get
122//purpose :
123//=======================================================================
124
ef779ae0 125Handle(TDocStd_Document) TDocStd_Owner::GetDocument() const
126{
127 return Handle(TDocStd_Document)(myDocument);
7fd59977 128}
129
130
131//=======================================================================
132//function : ID
133//purpose :
134//=======================================================================
135
ef779ae0 136const Standard_GUID& TDocStd_Owner::ID() const { return GetID(); }
7fd59977 137
138
139//=======================================================================
140//function : NewEmpty
141//purpose :
142//=======================================================================
143
ef779ae0 144Handle(TDF_Attribute) TDocStd_Owner::NewEmpty() const
7fd59977 145{
146 Handle(TDF_Attribute) dummy;
147 return dummy;
148}
149
150//=======================================================================
151//function : Restore
152//purpose :
153//=======================================================================
154
ef779ae0 155void TDocStd_Owner::Restore (const Handle(TDF_Attribute)&)
7fd59977 156{
157}
158
159//=======================================================================
160//function : Paste
161//purpose :
162//=======================================================================
163
35e08fe8 164void TDocStd_Owner::Paste (const Handle(TDF_Attribute)&,
165 const Handle(TDF_RelocationTable)&) const
7fd59977 166{
167}
168
169//=======================================================================
170//function : Dump
171//purpose :
172//=======================================================================
173
174Standard_OStream& TDocStd_Owner::Dump (Standard_OStream& anOS) const
175{
176 anOS << "Owner";
177 return anOS;
178}
179
bc73b006 180//=======================================================================
181//function : DumpJson
182//purpose :
183//=======================================================================
184void TDocStd_Owner::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
185{
186 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
187
ef779ae0 188 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myDocument)
bc73b006 189}
190