Salome HOME
New implementation of SALOMEDSImpl package based on DF data structure instead of...
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_StudyHandle.cxx
1 // Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
2 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
3 // 
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.
8 // 
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.
13 //
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
17 //
18 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 //
20 //  File   : SALOMEDSImpl_StudyHandle.cxx
21 //  Author : Sergey LITONIN
22 //  Module : SALOME
23
24 #include "SALOMEDSImpl_StudyHandle.hxx"
25
26 /*
27   Class       : SALOMEDSImpl_StudyHandle
28   Description : This class is intended for storing information about
29                 graphic representation of objects in dirrent views
30 */
31
32
33 //=======================================================================
34 //function : GetID
35 //purpose  : Get GUID of this attribute
36 //=======================================================================
37 const std::string& SALOMEDSImpl_StudyHandle::GetID()
38 {
39   static std::string SALOMEDSImpl_StudyHandleID( "050C9555-4BA8-49bf-8F1C-086F0469A40B" );
40   return SALOMEDSImpl_StudyHandleID;
41 }
42
43 //=======================================================================
44 //function : SALOMEDSImpl_StudyHandle
45 //purpose  : Empty Constructor
46 //=======================================================================
47 SALOMEDSImpl_StudyHandle::SALOMEDSImpl_StudyHandle()
48 {
49   myHandle = NULL;
50 }
51
52 //=======================================================================
53 //function : Set
54 //purpose  : 
55 //=======================================================================
56 SALOMEDSImpl_StudyHandle* SALOMEDSImpl_StudyHandle::Set(const DF_Label& theLabel, 
57                                                         SALOMEDSImpl_Study* theStudy)
58 {
59   SALOMEDSImpl_StudyHandle* A = NULL;
60   if (!(A=(SALOMEDSImpl_StudyHandle*)theLabel.FindAttribute(GetID()))) {
61     A = new SALOMEDSImpl_StudyHandle; 
62     theLabel.AddAttribute(A);
63   }
64
65   A->Set(theStudy);
66   return A;  
67 }
68
69
70 //=======================================================================
71 //function : ID
72 //purpose  : Get GUID of this attribute
73 //=======================================================================
74 const std::string& SALOMEDSImpl_StudyHandle::ID () const
75 {
76   return GetID();
77 }
78
79
80 //=======================================================================
81 //function : NewEmpty
82 //purpose  : Create new empty attribute
83 //=======================================================================
84 DF_Attribute* SALOMEDSImpl_StudyHandle::NewEmpty () const
85 {
86   return new SALOMEDSImpl_StudyHandle ();
87 }
88
89
90 //=======================================================================
91 //function : Restore
92 //purpose  : Restore value of attribute with value of theWith one
93 //=======================================================================
94 void SALOMEDSImpl_StudyHandle::Restore( DF_Attribute* theWith )
95 {
96   SALOMEDSImpl_StudyHandle* anAttr = dynamic_cast<SALOMEDSImpl_StudyHandle*>( theWith );
97   if ( anAttr ) Set ( anAttr->Get() );
98 }
99
100 //=======================================================================
101 //function : Paste
102 //purpose  : Paste value of current attribute to the value of entry one
103 //=======================================================================
104 void SALOMEDSImpl_StudyHandle::Paste( DF_Attribute* theInto)
105 {
106   SALOMEDSImpl_StudyHandle* anAttr =  dynamic_cast<SALOMEDSImpl_StudyHandle*>( theInto );
107   if ( anAttr ) anAttr->Set ( myHandle );
108 }
109