Salome HOME
187bae24b428e53eacba02472198cec4a8cb492b
[modules/homard.git] / src / SalomeSessionless / HOMARDHelper.cxx
1 // Copyright (C) 2021  CEA/DEN, EDF R&D
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
20 #include "HOMARDHelper.h"
21
22 #include "HOMARD_Gen_i_No_Session.hxx"
23 #include "SALOME_Container_i.hxx"
24 #include "SALOME_KernelServices.hxx"
25
26 #include <cstring>
27
28 std::string BuildHOMARDInstanceInternal()
29 {
30     CORBA::ORB_var orb;
31     { int argc(0); orb = CORBA::ORB_init(argc,nullptr); }
32     CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
33     PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
34     PortableServer::POAManager_var pman = poa->the_POAManager();
35     auto *cont(KERNEL::getContainerSA());
36     PortableServer::ObjectId *conId(cont->getCORBAId());
37     //
38     pman->activate();
39     //
40     HOMARD_Gen_i_No_Session *servant = new HOMARD_Gen_i_No_Session(orb,poa,conId,"HOMARD_inst_2","HOMARD");
41     PortableServer::ObjectId *zeId = servant->getId();
42     CORBA::Object_var zeRef = poa->id_to_reference(*zeId);
43     CORBA::String_var ior = orb->object_to_string(zeRef);
44     return std::string(ior.in());
45 }