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 | |
42cf5bc1 |
17 | |
18 | #include <Standard_GUID.hxx> |
19 | #include <Standard_Type.hxx> |
20 | #include <TDF_Attribute.hxx> |
21 | #include <TDF_Data.hxx> |
22 | #include <TDF_RelocationTable.hxx> |
23 | #include <TDocStd_Document.hxx> |
24 | #include <TDocStd_Owner.hxx> |
7fd59977 |
25 | |
92efcf78 |
26 | IMPLEMENT_STANDARD_RTTIEXT(TDocStd_Owner,TDF_Attribute) |
27 | |
7fd59977 |
28 | //======================================================================= |
29 | //function : GetID |
30 | //purpose : |
31 | //======================================================================= |
7fd59977 |
32 | const Standard_GUID& TDocStd_Owner::GetID() |
33 | { |
34 | static Standard_GUID TDocStd_OwnerID ("2a96b617-ec8b-11d0-bee7-080009dc3333"); |
35 | return TDocStd_OwnerID; |
36 | } |
37 | |
38 | |
39 | //======================================================================= |
40 | //function : SetDocument |
41 | //purpose : |
42 | //======================================================================= |
43 | |
44 | void TDocStd_Owner::SetDocument (const Handle(TDF_Data)& indata, |
45 | const Handle(TDocStd_Document)& D) |
46 | { |
47 | Handle(TDocStd_Owner) A; |
48 | if (!indata->Root().FindAttribute (TDocStd_Owner::GetID(), A)) { |
49 | A = new TDocStd_Owner (); |
50 | A->SetDocument(D); |
51 | indata->Root().AddAttribute(A); |
52 | } |
53 | else { |
9775fa61 |
54 | throw Standard_DomainError("TDocStd_Owner::SetDocument : already called"); |
7fd59977 |
55 | } |
56 | } |
57 | |
58 | //======================================================================= |
59 | //function : GetDocument |
60 | //purpose : |
61 | //======================================================================= |
62 | |
63 | Handle(TDocStd_Document) TDocStd_Owner::GetDocument (const Handle(TDF_Data)& ofdata) |
64 | { |
65 | Handle(TDocStd_Owner) A; |
66 | if (!ofdata->Root().FindAttribute (TDocStd_Owner::GetID(), A)) { |
9775fa61 |
67 | throw Standard_DomainError("TDocStd_Owner::GetDocument : document not found"); |
7fd59977 |
68 | } |
69 | return A->GetDocument(); |
70 | } |
71 | |
72 | //======================================================================= |
73 | //function : TDocStd_Owner |
74 | //purpose : |
75 | //======================================================================= |
76 | |
77 | TDocStd_Owner::TDocStd_Owner () { } |
78 | |
79 | |
80 | //======================================================================= |
81 | //function : SetDocument |
82 | //purpose : |
83 | //======================================================================= |
84 | |
85 | void TDocStd_Owner::SetDocument(const Handle( TDocStd_Document)& D) |
86 | { |
87 | myDocument = D; |
88 | } |
89 | |
90 | |
91 | //======================================================================= |
92 | //function : Get |
93 | //purpose : |
94 | //======================================================================= |
95 | |
96 | Handle(TDocStd_Document) TDocStd_Owner::GetDocument () const |
97 | { return myDocument; |
98 | } |
99 | |
100 | |
101 | //======================================================================= |
102 | //function : ID |
103 | //purpose : |
104 | //======================================================================= |
105 | |
106 | const Standard_GUID& TDocStd_Owner::ID () const { return GetID(); } |
107 | |
108 | |
109 | //======================================================================= |
110 | //function : NewEmpty |
111 | //purpose : |
112 | //======================================================================= |
113 | |
114 | Handle(TDF_Attribute) TDocStd_Owner::NewEmpty () const |
115 | { |
116 | Handle(TDF_Attribute) dummy; |
117 | return dummy; |
118 | } |
119 | |
120 | //======================================================================= |
121 | //function : Restore |
122 | //purpose : |
123 | //======================================================================= |
124 | |
35e08fe8 |
125 | void TDocStd_Owner::Restore(const Handle(TDF_Attribute)&) |
7fd59977 |
126 | { |
127 | } |
128 | |
129 | //======================================================================= |
130 | //function : Paste |
131 | //purpose : |
132 | //======================================================================= |
133 | |
35e08fe8 |
134 | void TDocStd_Owner::Paste (const Handle(TDF_Attribute)&, |
135 | const Handle(TDF_RelocationTable)&) const |
7fd59977 |
136 | { |
137 | } |
138 | |
139 | //======================================================================= |
140 | //function : Dump |
141 | //purpose : |
142 | //======================================================================= |
143 | |
144 | Standard_OStream& TDocStd_Owner::Dump (Standard_OStream& anOS) const |
145 | { |
146 | anOS << "Owner"; |
147 | return anOS; |
148 | } |
149 | |