Salome HOME
Base implementation of Notebook
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_GenericAttribute.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_GenericAttribute.hxx
23 //  Author : SERGEY_RUIN
24 //  Module : SALOME
25 //
26 #include "SALOMEDSImpl_Attributes.hxx"
27 #include "SALOMEDSImpl_Study.hxx"
28 #include "SALOMEDSImpl_StudyBuilder.hxx"
29
30 using namespace std;
31
32 string SALOMEDSImpl_GenericAttribute::Impl_GetType(DF_Attribute* theAttr)
33 {
34   SALOMEDSImpl_GenericAttribute* ga = dynamic_cast<SALOMEDSImpl_GenericAttribute*>(theAttr);  
35   if (ga)
36     return ga->Type();
37
38   return "";
39 }
40
41 string SALOMEDSImpl_GenericAttribute::Impl_GetClassType(DF_Attribute* theAttr)
42 {
43   SALOMEDSImpl_GenericAttribute* ga = dynamic_cast<SALOMEDSImpl_GenericAttribute*>(theAttr);
44   if (ga)
45     return ga->GetClassType();
46   
47   return "";
48
49
50 void SALOMEDSImpl_GenericAttribute::Impl_CheckLocked(DF_Attribute* theAttr)
51 {
52   SALOMEDSImpl_GenericAttribute* ga = dynamic_cast<SALOMEDSImpl_GenericAttribute*>(theAttr);
53   ga->CheckLocked();
54 }
55
56 string SALOMEDSImpl_GenericAttribute::Type() 
57
58     return _type; 
59 }
60
61
62 void SALOMEDSImpl_GenericAttribute::CheckLocked()
63 {
64   DF_Label aLabel = Label();
65   if(aLabel.IsNull()) return;
66
67   SALOMEDSImpl_Study* aStudy = SALOMEDSImpl_Study::GetStudy(aLabel);
68   if(!aStudy) return;
69   if(aStudy->IsLocked()) {
70     aStudy->_errorCode = "LockProtection";
71     throw LockProtection("LockProtection");
72   }                                         
73 }
74
75 SALOMEDSImpl_SObject SALOMEDSImpl_GenericAttribute::GetSObject()
76 {
77   SALOMEDSImpl_SObject so; 
78   DF_Label aLabel = Label();
79   if(aLabel.IsNull()) return so;
80   return SALOMEDSImpl_Study::SObject(aLabel);
81 }
82
83 void SALOMEDSImpl_GenericAttribute::SetModifyFlag()
84 {
85    DF_Label aLabel = Label();
86    if(aLabel.IsNull()) return; 
87
88   SALOMEDSImpl_Study* aStudy = SALOMEDSImpl_Study::GetStudy(aLabel);
89   if(aStudy) aStudy->Modify();
90 }
91