Salome HOME
DCQ : Merge with Ecole_ete_a6.
[modules/yacs.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 using namespace std;
30 #include "SALOMEDS_IORAttribute.ixx"
31 #include <TDataStd_Comment.hxx>
32 #include <TCollection_ExtendedString.hxx>
33 #include "SALOMEDS_Study_i.hxx"
34
35 //=======================================================================
36 //function : GetID
37 //purpose  : 
38 //=======================================================================
39
40 const Standard_GUID& SALOMEDS_IORAttribute::GetID () 
41 {
42   static Standard_GUID SALOMEDS_IORAttributeID ("92888E01-7074-11d5-A690-0800369C8A03");
43   return SALOMEDS_IORAttributeID;
44 }
45
46
47
48 //=======================================================================
49 //function : Set
50 //purpose  : 
51 //=======================================================================
52
53 Handle(SALOMEDS_IORAttribute) SALOMEDS_IORAttribute::Set (const TDF_Label& L,
54                                                           const TCollection_ExtendedString& S,
55                                                           CORBA::ORB_ptr orb) 
56 {
57   Handle(SALOMEDS_IORAttribute) A;
58   if (!L.FindAttribute(SALOMEDS_IORAttribute::GetID(),A)) {
59     A = new  SALOMEDS_IORAttribute(); 
60     L.AddAttribute(A);
61   }
62   
63   (Handle(TDataStd_Comment)::DownCast(A))->Set (S); 
64   SALOMEDS_Study_i::IORUpdated(A,orb);
65   return A;
66 }
67
68 //=======================================================================
69 //function : constructor
70 //purpose  : 
71 //=======================================================================
72 SALOMEDS_IORAttribute::SALOMEDS_IORAttribute()
73 {}
74
75 //=======================================================================
76 //function : ID
77 //purpose  : 
78 //=======================================================================
79
80 const Standard_GUID& SALOMEDS_IORAttribute::ID () const { return GetID(); }
81
82
83 //=======================================================================
84 //function : NewEmpty
85 //purpose  : 
86 //=======================================================================
87
88 Handle(TDF_Attribute) SALOMEDS_IORAttribute::NewEmpty () const
89 {  
90   return new SALOMEDS_IORAttribute(); 
91 }
92
93 //=======================================================================
94 //function : Restore
95 //purpose  : 
96 //=======================================================================
97
98 void SALOMEDS_IORAttribute::Restore(const Handle(TDF_Attribute)& with) 
99 {
100   TCollection_ExtendedString s = Handle(TDataStd_Comment)::DownCast (with)->Get ();
101   TDataStd_Comment::Set(s);
102   return;
103 }
104
105 //=======================================================================
106 //function : Paste
107 //purpose  : 
108 //=======================================================================
109
110 void SALOMEDS_IORAttribute::Paste (const Handle(TDF_Attribute)& into,
111                            const Handle(TDF_RelocationTable)& RT) const
112 {
113   Handle(TDataStd_Comment)::DownCast (into)->Set (Get());
114 }
115