Salome HOME
Go on for RequestSwitcher conquest
[modules/kernel.git] / src / SALOMESDS / SALOMESDS_RequestSwitcher.cxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony GEAY (EDF R&D)
20
21 #include "SALOMESDS_RequestSwitcher.hxx"
22
23 using namespace SALOMESDS;
24
25 RequestSwitcherBase::RequestSwitcherBase(CORBA::ORB_ptr orb)
26 {
27   CORBA::Object_var obj(orb->resolve_initial_references("RootPOA"));
28   PortableServer::POA_var poa(PortableServer::POA::_narrow(obj));
29   _poa_manager_under_control=poa->the_POAManager();
30   //
31   CORBA::PolicyList policies;
32   policies.length(1);
33   PortableServer::ThreadPolicy_var threadPol(poa->create_thread_policy(PortableServer::SINGLE_THREAD_MODEL));
34   policies[0]=PortableServer::ThreadPolicy::_duplicate(threadPol);
35   // all is in PortableServer::POAManager::_nil. By specifying _nil cf Advanced CORBA Programming with C++ p 506
36   // a new POA manager is created. This POA manager is independent from POA manager of the son ones.
37   _poa_for_request_control=poa->create_POA("4RqstSwitcher",PortableServer::POAManager::_nil(),policies);
38   threadPol->destroy();
39   PortableServer::POAManager_var mgr(_poa_for_request_control->the_POAManager());
40   mgr->activate();
41   //obj=orb->resolve_initial_references ("POACurrent");// agy : usage of POACurrent breaks the hold_requests. Why ?
42   //PortableServer::Current_var current(PortableServer::Current::_narrow(obj));
43 }
44
45 void RequestSwitcherBase::holdRequests()
46 {
47   _poa_manager_under_control->hold_requests(true);
48 }
49
50 void RequestSwitcherBase::activeRequests()
51 {
52   _poa_manager_under_control->activate();
53 }