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