0024784: Move documentation in CDL files to proper location
[occt.git] / src / TDataStd / TDataStd_Current.cxx
1 // Created on: 1999-08-02
2 // Created by: Denis PASCAL
3 // Copyright (c) 1999-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <TDataStd_Current.ixx>
18 #include <TDF_Data.hxx>
19 #include <Standard_DomainError.hxx>
20
21 //=======================================================================
22 //function : GetID
23 //purpose  : 
24 //=======================================================================
25
26 const Standard_GUID& TDataStd_Current::GetID () 
27 {
28   static Standard_GUID TDataStd_CurrentID("2a96b623-ec8b-11d0-bee7-080009dc3333");
29   return TDataStd_CurrentID;
30 }
31
32 //=======================================================================
33 //function : Set
34 //purpose  : 
35 //=======================================================================
36
37 void TDataStd_Current::Set (const TDF_Label& current)
38
39   Handle(TDataStd_Current) A;
40   Handle(TDF_Data) D = current.Data();
41   if (!D->Root().FindAttribute (TDataStd_Current::GetID(), A)) {
42     A = new TDataStd_Current (); 
43     D->Root().AddAttribute(A);
44   }
45   A->SetLabel (current);
46 }
47
48 //=======================================================================
49 //function : Get
50 //purpose  : 
51 //=======================================================================
52
53 TDF_Label TDataStd_Current::Get (const TDF_Label& access)
54
55 //  TDF_Label current;
56   Handle(TDataStd_Current) A;
57   if (!access.Data()->Root().FindAttribute (TDataStd_Current::GetID(), A)) {
58     Standard_DomainError::Raise("TDataStd_Current::Get : not setted");
59   }  
60   return A->GetLabel();
61 }
62
63 //=======================================================================
64 //function : Has
65 //purpose  : 
66 //=======================================================================
67
68 Standard_Boolean TDataStd_Current::Has (const TDF_Label& access)
69
70   return (access.Data()->Root().IsAttribute (TDataStd_Current::GetID()));
71 }
72
73 //=======================================================================
74 //function : TDataStd_Current
75 //purpose  : 
76 //=======================================================================
77
78 TDataStd_Current::TDataStd_Current () { }
79
80
81
82 //=======================================================================
83 //function : SetLabel
84 //purpose  : 
85 //=======================================================================
86
87 void TDataStd_Current::SetLabel (const TDF_Label& current) 
88 {
89   // OCC2932 correction
90   if(myLabel == current) return;
91
92   Backup();
93   myLabel = current;
94 }
95
96 //=======================================================================
97 //function : GetLabel
98 //purpose  : 
99 //=======================================================================
100
101 TDF_Label TDataStd_Current::GetLabel () const
102 {
103   return myLabel;
104 }
105
106
107 //=======================================================================
108 //function : ID
109 //purpose  : 
110 //=======================================================================
111
112 const Standard_GUID& TDataStd_Current::ID() const { return GetID(); }
113
114
115 //=======================================================================
116 //function : NewEmpty
117 //purpose  : 
118 //=======================================================================
119
120 Handle(TDF_Attribute) TDataStd_Current::NewEmpty () const
121 {  
122   return new TDataStd_Current(); 
123 }
124
125 //=======================================================================
126 //function : Restore
127 //purpose  : 
128 //=======================================================================
129
130 void TDataStd_Current::Restore(const Handle(TDF_Attribute)& With) 
131 {
132   myLabel = Handle(TDataStd_Current)::DownCast (With)->GetLabel ();
133 }
134
135 //=======================================================================
136 //function : Paste
137 //purpose  : 
138 //=======================================================================
139
140 void TDataStd_Current::Paste (const Handle(TDF_Attribute)& Into,
141                                 const Handle(TDF_RelocationTable)& RT) const
142 {
143   TDF_Label tLab;
144   if (!myLabel.IsNull()) {
145     if (!RT->HasRelocation(myLabel,tLab)) tLab = myLabel;
146   }
147   Handle(TDataStd_Current)::DownCast(Into)->SetLabel(tLab);
148 }
149
150 //=======================================================================
151 //function : Dump
152 //purpose  : 
153 //=======================================================================
154
155 Standard_OStream& TDataStd_Current::Dump (Standard_OStream& anOS) const
156 {  
157   anOS << "Current";
158   return anOS;
159 }
160
161