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
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <Standard_DomainError.hxx>
19 #include <Standard_GUID.hxx>
20 #include <Standard_Type.hxx>
21 #include <TDataStd_Current.hxx>
22 #include <TDF_Attribute.hxx>
23 #include <TDF_Data.hxx>
24 #include <TDF_Label.hxx>
25 #include <TDF_RelocationTable.hxx>
27 IMPLEMENT_STANDARD_RTTIEXT(TDataStd_Current,TDF_Attribute)
29 //=======================================================================
32 //=======================================================================
33 const Standard_GUID& TDataStd_Current::GetID ()
35 static Standard_GUID TDataStd_CurrentID("2a96b623-ec8b-11d0-bee7-080009dc3333");
36 return TDataStd_CurrentID;
39 //=======================================================================
42 //=======================================================================
44 void TDataStd_Current::Set (const TDF_Label& current)
46 Handle(TDataStd_Current) A;
47 Handle(TDF_Data) D = current.Data();
48 if (!D->Root().FindAttribute (TDataStd_Current::GetID(), A)) {
49 A = new TDataStd_Current ();
50 D->Root().AddAttribute(A);
52 A->SetLabel (current);
55 //=======================================================================
58 //=======================================================================
60 TDF_Label TDataStd_Current::Get (const TDF_Label& access)
63 Handle(TDataStd_Current) A;
64 if (!access.Data()->Root().FindAttribute (TDataStd_Current::GetID(), A)) {
65 throw Standard_DomainError("TDataStd_Current::Get : not setted");
70 //=======================================================================
73 //=======================================================================
75 Standard_Boolean TDataStd_Current::Has (const TDF_Label& access)
77 return (access.Data()->Root().IsAttribute (TDataStd_Current::GetID()));
80 //=======================================================================
81 //function : TDataStd_Current
83 //=======================================================================
85 TDataStd_Current::TDataStd_Current () { }
89 //=======================================================================
92 //=======================================================================
94 void TDataStd_Current::SetLabel (const TDF_Label& current)
97 if(myLabel == current) return;
103 //=======================================================================
104 //function : GetLabel
106 //=======================================================================
108 TDF_Label TDataStd_Current::GetLabel () const
114 //=======================================================================
117 //=======================================================================
119 const Standard_GUID& TDataStd_Current::ID() const { return GetID(); }
122 //=======================================================================
123 //function : NewEmpty
125 //=======================================================================
127 Handle(TDF_Attribute) TDataStd_Current::NewEmpty () const
129 return new TDataStd_Current();
132 //=======================================================================
135 //=======================================================================
137 void TDataStd_Current::Restore(const Handle(TDF_Attribute)& With)
139 myLabel = Handle(TDataStd_Current)::DownCast (With)->GetLabel ();
142 //=======================================================================
145 //=======================================================================
147 void TDataStd_Current::Paste (const Handle(TDF_Attribute)& Into,
148 const Handle(TDF_RelocationTable)& RT) const
151 if (!myLabel.IsNull()) {
152 if (!RT->HasRelocation(myLabel,tLab)) tLab = myLabel;
154 Handle(TDataStd_Current)::DownCast(Into)->SetLabel(tLab);
157 //=======================================================================
160 //=======================================================================
162 Standard_OStream& TDataStd_Current::Dump (Standard_OStream& anOS) const