1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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, or (at your option) any later version.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SALOMEDS_SimanStudy.cxx
24 // Author : Mikhail PONIKAROV
27 #include "utilities.h"
29 #include "SALOMEDS_SimanStudy.hxx"
31 #include "SALOMEDS.hxx"
32 #include "SALOMEDS_Study.hxx"
34 #include "SALOMEDSImpl_Study.hxx"
36 #include "SALOMEDS_SimanStudy_i.hxx"
38 #include "Basics_Utils.hxx"
40 #include "Utils_ORB_INIT.hxx"
41 #include "Utils_SINGLETON.hxx"
44 SALOMEDS_SimanStudy::SALOMEDS_SimanStudy(SALOMEDSImpl_SimanStudy* theStudy)
47 _local_impl = theStudy;
48 _corba_impl = SALOMEDS::SimanStudy::_nil();
52 SALOMEDS_SimanStudy::SALOMEDS_SimanStudy(SALOMEDS::SimanStudy_ptr theStudy)
56 long pid = (long)_getpid();
58 long pid = (long)getpid();
61 long addr = theStudy->GetLocalImpl(Kernel_Utils::GetHostname().c_str(), pid, _isLocal);
63 _local_impl = reinterpret_cast<SALOMEDSImpl_SimanStudy*>(addr);
64 _corba_impl = SALOMEDS::SimanStudy::_duplicate(theStudy);
68 _corba_impl = SALOMEDS::SimanStudy::_duplicate(theStudy);
71 _corba_impl = SALOMEDS::SimanStudy::_duplicate(theStudy);
76 SALOMEDS_SimanStudy::~SALOMEDS_SimanStudy()
80 void SALOMEDS_SimanStudy::CheckOut(const _PTR(Study) theTarget)
82 if (!theTarget) return;
83 SALOMEDS_Study* aStudy = dynamic_cast<SALOMEDS_Study*>(theTarget.get());
85 //SALOMEDS::Locker lock; mpv: this may cause dedlock when importData in module calls another SALOMEDS method with lock
86 _local_impl->CheckOut(aStudy->GetLocalImpl());
88 else*/ _corba_impl->CheckOut(aStudy->GetStudy());
91 void SALOMEDS_SimanStudy::CheckIn(const std::string theModuleName)
94 //SALOMEDS::Locker lock; mpv: this may cause dedlock when getModifiedData in module calls another SALOMEDS method with lock
95 _local_impl->CheckIn(theModuleName);
97 else*/ _corba_impl->CheckIn((char*)theModuleName.c_str());
100 _PTR(Study) SALOMEDS_SimanStudy::getReferencedStudy()
102 SALOMEDSClient_Study* aStudy = NULL;
104 SALOMEDS::Locker lock;
106 SALOMEDSImpl_Study* aStudy_impl = _local_impl->getReferencedStudy();
107 if (!aStudy_impl) return _PTR(Study)(aStudy);
108 aStudy = new SALOMEDS_Study(aStudy_impl);
111 SALOMEDS::Study_var aStudy_impl = _corba_impl->getReferencedStudy();
112 if (CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy);
113 aStudy = new SALOMEDS_Study(aStudy_impl);
115 SALOMEDS::Study_var aStudy_impl = _corba_impl->getReferencedStudy();
116 if (CORBA::is_nil(aStudy_impl)) return _PTR(Study)(aStudy);
117 aStudy = new SALOMEDS_Study(aStudy_impl);
118 return _PTR(Study)(aStudy);
121 std::string SALOMEDS_SimanStudy::StudyId()
125 SALOMEDS::Locker lock;
126 anId = _local_impl->StudyId();
128 else*/ anId = (CORBA::String_var)_corba_impl->StudyId();
132 void SALOMEDS_SimanStudy::StudyId(const std::string theId)
135 SALOMEDS::Locker lock;
136 _local_impl->StudyId(theId);
138 else*/ _corba_impl->StudyId((char*)theId.c_str());
141 std::string SALOMEDS_SimanStudy::ScenarioId()
145 SALOMEDS::Locker lock;
146 anId = _local_impl->ScenarioId();
148 else*/ anId = (CORBA::String_var)_corba_impl->ScenarioId();
152 void SALOMEDS_SimanStudy::ScenarioId(const std::string theId)
155 SALOMEDS::Locker lock;
156 _local_impl->ScenarioId(theId);
158 else*/ _corba_impl->ScenarioId((char*)theId.c_str());
161 std::string SALOMEDS_SimanStudy::UserId()
165 SALOMEDS::Locker lock;
166 anId = _local_impl->UserId();
168 else*/ anId = (CORBA::String_var)_corba_impl->UserId();
172 void SALOMEDS_SimanStudy::UserId(const std::string theId)
175 SALOMEDS::Locker lock;
176 _local_impl->UserId(theId);
178 else*/ _corba_impl->UserId((char*)theId.c_str());
181 void SALOMEDS_SimanStudy::init_orb()
183 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
184 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());