1 // Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License.
9 // This library is distributed in the hope that it will be useful
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File : SALOMEDSImpl_AttributeReference.cxx
21 // Author : Sergey RUIN
24 #include "SALOMEDSImpl_AttributeReference.hxx"
25 #include <TDF_Tool.hxx>
26 #include <TDF_Data.hxx>
27 #include <TDF_RelocationTable.hxx>
31 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_AttributeReference, SALOMEDSImpl_GenericAttribute )
32 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_AttributeReference, SALOMEDSImpl_GenericAttribute )
35 //=======================================================================
38 //=======================================================================
39 const Standard_GUID& SALOMEDSImpl_AttributeReference::GetID ()
41 static Standard_GUID refID ("D913E0B3-0A9F-4ea6-9480-18A9B72D9D86");
45 Handle(SALOMEDSImpl_AttributeReference) SALOMEDSImpl_AttributeReference::Set(const TDF_Label& theLabel,
46 const TDF_Label& theRefLabel)
48 Handle(SALOMEDSImpl_AttributeReference) A;
49 if (!theLabel.FindAttribute(SALOMEDSImpl_AttributeReference::GetID(), A)) {
50 A = new SALOMEDSImpl_AttributeReference();
51 theLabel.AddAttribute(A);
58 //=======================================================================
61 //=======================================================================
62 void SALOMEDSImpl_AttributeReference::Set(const TDF_Label& Origin)
66 if(myLabel == Origin) return;
71 SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved
74 //=======================================================================
77 //=======================================================================
78 const Standard_GUID& SALOMEDSImpl_AttributeReference::ID () const { return GetID(); }
81 TCollection_AsciiString SALOMEDSImpl_AttributeReference::Save()
83 TCollection_AsciiString anEntry;
84 TDF_Tool::Entry(myLabel, anEntry);
88 void SALOMEDSImpl_AttributeReference::Load(const TCollection_AsciiString& value)
91 TDF_Tool::Label(Label().Data(), value, aLabel);
95 //=======================================================================
98 //=======================================================================
99 Handle(TDF_Attribute) SALOMEDSImpl_AttributeReference::NewEmpty () const
101 return new SALOMEDSImpl_AttributeReference();
104 //=======================================================================
107 //=======================================================================
109 void SALOMEDSImpl_AttributeReference::Restore(const Handle(TDF_Attribute)& With)
111 myLabel = Handle(SALOMEDSImpl_AttributeReference)::DownCast (With)->Get ();
114 //=======================================================================
117 //=======================================================================
119 void SALOMEDSImpl_AttributeReference::Paste (const Handle(TDF_Attribute)& Into,
120 const Handle(TDF_RelocationTable)& RT) const
123 if (!myLabel.IsNull()) {
124 if (!RT->HasRelocation(myLabel,tLab)) tLab = myLabel;
126 Handle(SALOMEDSImpl_AttributeReference)::DownCast(Into)->Set(tLab);