Salome HOME
Copyrights update
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_GenericAttribute.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/
19 //
20 //  File   : SALOMEDSImpl_GenericAttribute.hxx
21 //  Author : SERGEY_RUIN
22 //  Module : SALOME
23
24
25 #include "SALOMEDSImpl_Attributes.hxx"
26 #include "SALOMEDSImpl_Study.hxx"
27 #include "SALOMEDSImpl_StudyBuilder.hxx"
28
29 using namespace std;
30
31 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_GenericAttribute, TDF_Attribute )
32 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_GenericAttribute, TDF_Attribute )
33
34 char* SALOMEDSImpl_GenericAttribute::Impl_GetType(const Handle(TDF_Attribute)& theAttr)
35 {
36   Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(theAttr);  
37   return ga->Type().ToCString();
38 }
39
40 char* SALOMEDSImpl_GenericAttribute::Impl_GetClassType(const Handle(TDF_Attribute)& theAttr)
41 {
42   Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(theAttr);
43   return ga->GetClassType().ToCString();
44
45
46 void SALOMEDSImpl_GenericAttribute::Impl_CheckLocked(const Handle(TDF_Attribute)& theAttr)
47 {
48   Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(theAttr);
49   ga->CheckLocked();
50 }
51
52 TCollection_AsciiString SALOMEDSImpl_GenericAttribute::Type() 
53
54     return _type; 
55 }
56
57
58 void SALOMEDSImpl_GenericAttribute::CheckLocked()
59 {
60   TDF_Label aLabel = Label();
61   if(aLabel.IsNull()) return;
62
63   Handle(SALOMEDSImpl_Study) aStudy = SALOMEDSImpl_Study::GetStudy(aLabel);
64   if(aStudy.IsNull() || aStudy->NewBuilder()->HasOpenCommand()) return;
65   if(aStudy->IsLocked()) {
66     aStudy->_errorCode = "LockProtection";
67     throw LockProtection("LockProtection");
68   }                                         
69 }
70
71 Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_GenericAttribute::GetSObject()
72 {
73   TDF_Label aLabel = Label();
74   if(aLabel.IsNull()) return NULL;
75   return SALOMEDSImpl_Study::SObject(aLabel);
76 }
77
78 void SALOMEDSImpl_GenericAttribute::SetModifyFlag()
79 {
80    TDF_Label aLabel = Label();
81    if(aLabel.IsNull()) return; 
82
83   Handle(SALOMEDSImpl_Study) aStudy = SALOMEDSImpl_Study::GetStudy(aLabel);
84   if(!aStudy.IsNull()) aStudy->Modify();
85 }
86