0031615: Coding - New warnings after integration fix for 0031552
[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,
46 const Handle(TDocStd_Document)& D)
47{
48 Handle(TDocStd_Owner) A;
49 if (!indata->Root().FindAttribute (TDocStd_Owner::GetID(), A)) {
50 A = new TDocStd_Owner ();
51 A->SetDocument(D);
52 indata->Root().AddAttribute(A);
53 }
54 else {
9775fa61 55 throw Standard_DomainError("TDocStd_Owner::SetDocument : already called");
7fd59977 56 }
57}
58
59//=======================================================================
60//function : GetDocument
61//purpose :
62//=======================================================================
63
64Handle(TDocStd_Document) TDocStd_Owner::GetDocument (const Handle(TDF_Data)& ofdata)
65{
66 Handle(TDocStd_Owner) A;
67 if (!ofdata->Root().FindAttribute (TDocStd_Owner::GetID(), A)) {
9775fa61 68 throw Standard_DomainError("TDocStd_Owner::GetDocument : document not found");
7fd59977 69 }
70 return A->GetDocument();
71}
72
73//=======================================================================
74//function : TDocStd_Owner
75//purpose :
76//=======================================================================
77
78TDocStd_Owner::TDocStd_Owner () { }
79
80
81//=======================================================================
82//function : SetDocument
83//purpose :
84//=======================================================================
85
86void TDocStd_Owner::SetDocument(const Handle( TDocStd_Document)& D)
87{
88 myDocument = D;
89}
90
91
92//=======================================================================
93//function : Get
94//purpose :
95//=======================================================================
96
97Handle(TDocStd_Document) TDocStd_Owner::GetDocument () const
98{ return myDocument;
99}
100
101
102//=======================================================================
103//function : ID
104//purpose :
105//=======================================================================
106
107const Standard_GUID& TDocStd_Owner::ID () const { return GetID(); }
108
109
110//=======================================================================
111//function : NewEmpty
112//purpose :
113//=======================================================================
114
115Handle(TDF_Attribute) TDocStd_Owner::NewEmpty () const
116{
117 Handle(TDF_Attribute) dummy;
118 return dummy;
119}
120
121//=======================================================================
122//function : Restore
123//purpose :
124//=======================================================================
125
35e08fe8 126void TDocStd_Owner::Restore(const Handle(TDF_Attribute)&)
7fd59977 127{
128}
129
130//=======================================================================
131//function : Paste
132//purpose :
133//=======================================================================
134
35e08fe8 135void TDocStd_Owner::Paste (const Handle(TDF_Attribute)&,
136 const Handle(TDF_RelocationTable)&) const
7fd59977 137{
138}
139
140//=======================================================================
141//function : Dump
142//purpose :
143//=======================================================================
144
145Standard_OStream& TDocStd_Owner::Dump (Standard_OStream& anOS) const
146{
147 anOS << "Owner";
148 return anOS;
149}
150
bc73b006 151//=======================================================================
152//function : DumpJson
153//purpose :
154//=======================================================================
155void TDocStd_Owner::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
156{
157 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
158
159 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myDocument.get())
160}
161