7fd59977 |
1 | // File: TDataStd_Current.cxx |
2 | // Created: Mon Aug 2 09:58:09 1999 |
3 | // Author: Denis PASCAL |
4 | // <dp@dingox.paris1.matra-dtv.fr> |
5 | |
6 | |
7 | #include <TDataStd_Current.ixx> |
8 | #include <TDF_Data.hxx> |
9 | #include <Standard_DomainError.hxx> |
10 | |
11 | //======================================================================= |
12 | //function : GetID |
13 | //purpose : |
14 | //======================================================================= |
15 | |
16 | const Standard_GUID& TDataStd_Current::GetID () |
17 | { |
18 | static Standard_GUID TDataStd_CurrentID("2a96b623-ec8b-11d0-bee7-080009dc3333"); |
19 | return TDataStd_CurrentID; |
20 | } |
21 | |
22 | //======================================================================= |
23 | //function : Set |
24 | //purpose : |
25 | //======================================================================= |
26 | |
27 | void TDataStd_Current::Set (const TDF_Label& current) |
28 | { |
29 | Handle(TDataStd_Current) A; |
30 | Handle(TDF_Data) D = current.Data(); |
31 | if (!D->Root().FindAttribute (TDataStd_Current::GetID(), A)) { |
32 | A = new TDataStd_Current (); |
33 | D->Root().AddAttribute(A); |
34 | } |
35 | A->SetLabel (current); |
36 | } |
37 | |
38 | //======================================================================= |
39 | //function : Get |
40 | //purpose : |
41 | //======================================================================= |
42 | |
43 | TDF_Label TDataStd_Current::Get (const TDF_Label& access) |
44 | { |
45 | // TDF_Label current; |
46 | Handle(TDataStd_Current) A; |
47 | if (!access.Data()->Root().FindAttribute (TDataStd_Current::GetID(), A)) { |
48 | Standard_DomainError::Raise("TDataStd_Current::Get : not setted"); |
49 | } |
50 | return A->GetLabel(); |
51 | } |
52 | |
53 | //======================================================================= |
54 | //function : Has |
55 | //purpose : |
56 | //======================================================================= |
57 | |
58 | Standard_Boolean TDataStd_Current::Has (const TDF_Label& access) |
59 | { |
60 | return (access.Data()->Root().IsAttribute (TDataStd_Current::GetID())); |
61 | } |
62 | |
63 | //======================================================================= |
64 | //function : TDataStd_Current |
65 | //purpose : |
66 | //======================================================================= |
67 | |
68 | TDataStd_Current::TDataStd_Current () { } |
69 | |
70 | |
71 | |
72 | //======================================================================= |
73 | //function : SetLabel |
74 | //purpose : |
75 | //======================================================================= |
76 | |
77 | void TDataStd_Current::SetLabel (const TDF_Label& current) |
78 | { |
79 | // OCC2932 correction |
80 | if(myLabel == current) return; |
81 | |
82 | Backup(); |
83 | myLabel = current; |
84 | } |
85 | |
86 | //======================================================================= |
87 | //function : GetLabel |
88 | //purpose : |
89 | //======================================================================= |
90 | |
91 | TDF_Label TDataStd_Current::GetLabel () const |
92 | { |
93 | return myLabel; |
94 | } |
95 | |
96 | |
97 | //======================================================================= |
98 | //function : ID |
99 | //purpose : |
100 | //======================================================================= |
101 | |
102 | const Standard_GUID& TDataStd_Current::ID() const { return GetID(); } |
103 | |
104 | |
105 | //======================================================================= |
106 | //function : NewEmpty |
107 | //purpose : |
108 | //======================================================================= |
109 | |
110 | Handle(TDF_Attribute) TDataStd_Current::NewEmpty () const |
111 | { |
112 | return new TDataStd_Current(); |
113 | } |
114 | |
115 | //======================================================================= |
116 | //function : Restore |
117 | //purpose : |
118 | //======================================================================= |
119 | |
120 | void TDataStd_Current::Restore(const Handle(TDF_Attribute)& With) |
121 | { |
122 | myLabel = Handle(TDataStd_Current)::DownCast (With)->GetLabel (); |
123 | } |
124 | |
125 | //======================================================================= |
126 | //function : Paste |
127 | //purpose : |
128 | //======================================================================= |
129 | |
130 | void TDataStd_Current::Paste (const Handle(TDF_Attribute)& Into, |
131 | const Handle(TDF_RelocationTable)& RT) const |
132 | { |
133 | TDF_Label tLab; |
134 | if (!myLabel.IsNull()) { |
135 | if (!RT->HasRelocation(myLabel,tLab)) tLab = myLabel; |
136 | } |
137 | Handle(TDataStd_Current)::DownCast(Into)->SetLabel(tLab); |
138 | } |
139 | |
140 | //======================================================================= |
141 | //function : Dump |
142 | //purpose : |
143 | //======================================================================= |
144 | |
145 | Standard_OStream& TDataStd_Current::Dump (Standard_OStream& anOS) const |
146 | { |
147 | anOS << "Current"; |
148 | return anOS; |
149 | } |
150 | |
151 | |