Salome HOME
Fix on [Bug PAL7750] Regression of UNDO in GEOM
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_IORAttribute.cxx
1 //  SALOME SALOMEDS : data structure of SALOME and sources of Salome data server 
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : SALOMEDS_IORAttribute.cxx
25 //  Author : Yves FRICAUD
26 //  Module : SALOME
27 //  $Header$
28
29 #include <TDataStd_Comment.hxx>
30 #include <TCollection_ExtendedString.hxx>
31
32 #include "SALOMEDS_IORAttribute.ixx"
33 #include "SALOMEDS_Study_i.hxx"
34
35 using namespace std;
36
37 //=======================================================================
38 //function : GetID
39 //purpose  : 
40 //=======================================================================
41
42 const Standard_GUID& SALOMEDS_IORAttribute::GetID () 
43 {
44   static Standard_GUID SALOMEDS_IORAttributeID ("92888E01-7074-11d5-A690-0800369C8A03");
45   return SALOMEDS_IORAttributeID;
46 }
47
48
49
50 //=======================================================================
51 //function : Set
52 //purpose  : 
53 //=======================================================================
54
55 Handle(SALOMEDS_IORAttribute) SALOMEDS_IORAttribute::Set (const TDF_Label& L,
56                                                           const TCollection_ExtendedString& S,
57                                                           SALOMEDS_Study_i* theStudy) 
58 {
59   Handle(SALOMEDS_IORAttribute) A;
60   if (!L.FindAttribute(SALOMEDS_IORAttribute::GetID(),A)) {
61     A = new  SALOMEDS_IORAttribute(); 
62     L.AddAttribute(A);
63   }
64   
65   (Handle(TDataStd_Comment)::DownCast(A))->Set (S); 
66   theStudy->IORUpdated(A);
67   return A;
68 }
69
70 //=======================================================================
71 //function : constructor
72 //purpose  : 
73 //=======================================================================
74 SALOMEDS_IORAttribute::SALOMEDS_IORAttribute()
75 {}
76
77 //=======================================================================
78 //function : ID
79 //purpose  : 
80 //=======================================================================
81
82 const Standard_GUID& SALOMEDS_IORAttribute::ID () const { return GetID(); }
83
84
85 //=======================================================================
86 //function : NewEmpty
87 //purpose  : 
88 //=======================================================================
89
90 Handle(TDF_Attribute) SALOMEDS_IORAttribute::NewEmpty () const
91 {  
92   return new SALOMEDS_IORAttribute(); 
93 }
94
95 //=======================================================================
96 //function : Restore
97 //purpose  : 
98 //=======================================================================
99
100 void SALOMEDS_IORAttribute::Restore(const Handle(TDF_Attribute)& with) 
101 {
102   TCollection_ExtendedString s = Handle(TDataStd_Comment)::DownCast (with)->Get ();
103   TDataStd_Comment::Set(s);
104   return;
105 }
106
107 //=======================================================================
108 //function : Paste
109 //purpose  : 
110 //=======================================================================
111
112 void SALOMEDS_IORAttribute::Paste (const Handle(TDF_Attribute)& into,
113                            const Handle(TDF_RelocationTable)& RT) const
114 {
115   Handle(TDataStd_Comment)::DownCast (into)->Set (Get());
116 }
117