Salome HOME
PR: mergefrom_BSEC_br1_14Mar04
[modules/kernel.git] / src / SALOMEDS / SALOMEDS_GenericAttribute_i.cxx
1 //  SALOME SALOMEDS : data structure of SALOME and sources of Salome data server 
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : SALOMEDS_GenericAttribute_i.cxx
8 //  Author : Mikhail PONIKAROV
9 //  Module : SALOME
10 //  $Header$
11
12 #include "SALOMEDS_StudyBuilder_i.hxx"
13 using namespace std;
14
15 void SALOMEDS_GenericAttribute_i::CheckLocked() throw (SALOMEDS::GenericAttribute::LockProtection) {
16   if (!_myAttr.IsNull() && _myAttr->IsValid() && !CORBA::is_nil(_myOrb)) {
17     Handle(SALOMEDS_IORAttribute) Att;
18     if (_myAttr->Label().Root().FindAttribute(SALOMEDS_IORAttribute::GetID(),Att)){
19       TCollection_AsciiString ch(Att->Get());
20       char* IOR = CORBA::string_dup(ch.ToCString());
21       CORBA::Object_var obj = _myOrb->string_to_object(IOR);
22       SALOMEDS::Study_ptr aStudy = SALOMEDS::Study::_narrow(obj);
23       //        ASSERT(!CORBA::is_nil(aStudy));
24       if (aStudy->NewBuilder()->HasOpenCommand()) return;
25       if (aStudy->GetProperties()->IsLocked()) {
26         //        INFOS("Locked document modification !!!");
27         throw SALOMEDS::GenericAttribute::LockProtection();
28       }
29     }
30   }
31 }