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.
17 #include <TDataStd_Current.ixx>
18 #include <TDF_Data.hxx>
19 #include <Standard_DomainError.hxx>
21 //=======================================================================
24 //=======================================================================
26 const Standard_GUID& TDataStd_Current::GetID ()
28 static Standard_GUID TDataStd_CurrentID("2a96b623-ec8b-11d0-bee7-080009dc3333");
29 return TDataStd_CurrentID;
32 //=======================================================================
35 //=======================================================================
37 void TDataStd_Current::Set (const TDF_Label& current)
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);
45 A->SetLabel (current);
48 //=======================================================================
51 //=======================================================================
53 TDF_Label TDataStd_Current::Get (const TDF_Label& access)
56 Handle(TDataStd_Current) A;
57 if (!access.Data()->Root().FindAttribute (TDataStd_Current::GetID(), A)) {
58 Standard_DomainError::Raise("TDataStd_Current::Get : not setted");
63 //=======================================================================
66 //=======================================================================
68 Standard_Boolean TDataStd_Current::Has (const TDF_Label& access)
70 return (access.Data()->Root().IsAttribute (TDataStd_Current::GetID()));
73 //=======================================================================
74 //function : TDataStd_Current
76 //=======================================================================
78 TDataStd_Current::TDataStd_Current () { }
82 //=======================================================================
85 //=======================================================================
87 void TDataStd_Current::SetLabel (const TDF_Label& current)
90 if(myLabel == current) return;
96 //=======================================================================
99 //=======================================================================
101 TDF_Label TDataStd_Current::GetLabel () const
107 //=======================================================================
110 //=======================================================================
112 const Standard_GUID& TDataStd_Current::ID() const { return GetID(); }
115 //=======================================================================
116 //function : NewEmpty
118 //=======================================================================
120 Handle(TDF_Attribute) TDataStd_Current::NewEmpty () const
122 return new TDataStd_Current();
125 //=======================================================================
128 //=======================================================================
130 void TDataStd_Current::Restore(const Handle(TDF_Attribute)& With)
132 myLabel = Handle(TDataStd_Current)::DownCast (With)->GetLabel ();
135 //=======================================================================
138 //=======================================================================
140 void TDataStd_Current::Paste (const Handle(TDF_Attribute)& Into,
141 const Handle(TDF_RelocationTable)& RT) const
144 if (!myLabel.IsNull()) {
145 if (!RT->HasRelocation(myLabel,tLab)) tLab = myLabel;
147 Handle(TDataStd_Current)::DownCast(Into)->SetLabel(tLab);
150 //=======================================================================
153 //=======================================================================
155 Standard_OStream& TDataStd_Current::Dump (Standard_OStream& anOS) const