Salome HOME
6f2384fb60499ce3057271c52892094a5d020478
[modules/kernel.git] / src / SALOMEDSImpl / SALOMEDSImpl_GenericAttribute.cxx
1 //  File   : SALOMEDSImpl_GenericAttribute.hxx
2 //  Author : SERGEY_RUIN
3 //  Module : SALOME
4
5
6 #include "SALOMEDSImpl_Attributes.hxx"
7 #include "SALOMEDSImpl_Study.hxx"
8 #include "SALOMEDSImpl_StudyBuilder.hxx"
9
10 using namespace std;
11
12 IMPLEMENT_STANDARD_HANDLE( SALOMEDSImpl_GenericAttribute, TDF_Attribute )
13 IMPLEMENT_STANDARD_RTTIEXT( SALOMEDSImpl_GenericAttribute, TDF_Attribute )
14
15 char* SALOMEDSImpl_GenericAttribute::Impl_GetType(const Handle(TDF_Attribute)& theAttr)
16 {
17   Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(theAttr);  
18   return ga->Type().ToCString();
19 }
20
21 char* SALOMEDSImpl_GenericAttribute::Impl_GetClassType(const Handle(TDF_Attribute)& theAttr)
22 {
23   Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(theAttr);
24   return ga->GetClassType().ToCString();
25
26
27 void SALOMEDSImpl_GenericAttribute::Impl_CheckLocked(const Handle(TDF_Attribute)& theAttr)
28 {
29   Handle(SALOMEDSImpl_GenericAttribute) ga = Handle(SALOMEDSImpl_GenericAttribute)::DownCast(theAttr);
30   ga->CheckLocked();
31 }
32
33 TCollection_AsciiString SALOMEDSImpl_GenericAttribute::Type() 
34
35     return _type; 
36 }
37
38
39 void SALOMEDSImpl_GenericAttribute::CheckLocked()
40 {
41   TDF_Label aLabel = Label();
42   if(aLabel.IsNull()) return;
43
44   Handle(SALOMEDSImpl_Study) aStudy = SALOMEDSImpl_Study::GetStudy(aLabel);
45   if(aStudy.IsNull() || aStudy->NewBuilder()->HasOpenCommand()) return;
46   if(aStudy->IsLocked()) {
47     aStudy->_errorCode = "LockProtection";
48     throw LockProtection("LockProtection");
49   }                                         
50 }
51
52 Handle(SALOMEDSImpl_SObject) SALOMEDSImpl_GenericAttribute::GetSObject()
53 {
54   TDF_Label aLabel = Label();
55   if(aLabel.IsNull()) return NULL;
56   return SALOMEDSImpl_Study::SObject(aLabel);
57 }
58
59 void SALOMEDSImpl_GenericAttribute::SetModifyFlag()
60 {
61    TDF_Label aLabel = Label();
62    if(aLabel.IsNull()) return; 
63
64   Handle(SALOMEDSImpl_Study) aStudy = SALOMEDSImpl_Study::GetStudy(aLabel);
65   if(!aStudy.IsNull()) aStudy->Modify();
66 }
67