1 // SALOME ParallelContainerProxyDummy : Proxy of a PaCO++ object using Dummy
3 // Copyright (C) 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.
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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SALOME_ParallelContainerProxyDummy.cxx
25 // Author : André Ribes, EDF
26 // Module : SALOME PARALLEL
39 #include "SALOME_ComponentPaCO_Engines_Container_server.h"
40 #include <paco_omni.h>
41 #include <paco_dummy.h>
43 #include "SALOME_NamingService.hxx"
45 #include "utilities.h"
46 #include "Utils_ORB_INIT.hxx"
47 #include "Utils_SINGLETON.hxx"
48 #include "SALOMETraceCollector.hxx"
56 cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
57 cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
58 cerr << "SIGSEGV in :" << getpid() << endl;
59 cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
60 cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
65 int main(int argc, char* argv[])
67 INFOS("Launching a parallel proxy container");
70 signal(SIGSEGV, handler);
73 // Initialise the ORB.
74 ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
75 ASSERT(SINGLETON_<ORB_INIT>::IsAlreadyExisting());
76 CORBA::ORB_var orb = init(0, 0);
77 //CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
79 char *containerName = "";
81 containerName = argv[1];
85 CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
86 ASSERT(!CORBA::is_nil(obj));
87 PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
88 PortableServer::POAManager_var pman = root_poa->the_POAManager();
91 // add this container to the kill list
93 sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxy", getpid());
97 SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
98 Engines::Container_proxy_impl * proxy = new Engines::Container_proxy_impl(CORBA::ORB::_duplicate(orb));
101 paco_fabrique_manager* pfm = paco_getFabriqueManager();
103 PaCO_operation * global_ptr = proxy->getContext("global_paco_context");
104 pfm->register_com("dummy", new paco_dummy_fabrique());
105 global_ptr->setLibCom("dummy", NULL);
106 pfm->register_thread("omnithread", new paco_omni_fabrique());
107 global_ptr->setLibThread("omnithread");
108 global_ptr->setTypeClient(true);
109 // The proxy is a PaCO++ client
110 PaCO::PacoTopology_t client_topo;
111 client_topo.total = 1;
112 global_ptr->setClientTopo(client_topo);
113 // Topo of the parallel object
114 PaCO::PacoTopology_t serveur_topo;
115 serveur_topo.total = 1;
116 proxy->setTopo(serveur_topo);
118 PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
119 obj = root_poa->id_to_reference(_id);
121 // In the NamingService
122 string hostname = GetHostname();
123 Engines::Container_var pCont = Engines::Container::_narrow(obj);
124 string _containerName = ns->BuildContainerNameForNS(containerName,
126 cerr << "---------" << _containerName << "----------" << endl;
127 ns->Register(pCont, _containerName.c_str());
131 catch(CORBA::SystemException&)
133 INFOS("Caught CORBA::SystemException.");
135 catch(PortableServer::POA::ServantAlreadyActive&)
137 INFOS("Caught CORBA::ServantAlreadyActiveException");
139 catch(CORBA::Exception&)
141 INFOS("Caught CORBA::Exception.");
143 catch(std::exception& exc)
145 INFOS("Caught std::exception - "<<exc.what());
149 INFOS("Caught unknown exception.");