Salome HOME
updated copyright message
[modules/kernel.git] / src / ParallelContainer / SALOME_ParallelContainerProxyDummy.cxx
index e8df8733bf1344b160b9e889d16cf39b5be9066b..9b3c052479b2bb73acfa5c4ce1dd4ac25d90ec8d 100644 (file)
@@ -1,35 +1,35 @@
-//  SALOME ParallelContainerProxyDummy : Proxy of a PaCO++ object using Dummy
+// Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
-//  Copyright (C) 2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
 //
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
 //
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+//  SALOME ParallelContainerProxyDummy : Proxy of a PaCO++ object using Dummy
 //  File   : SALOME_ParallelContainerProxyDummy.cxx
-//  Author : André Ribes, EDF
+//  Author : Andr Ribes, EDF
 //  Module : SALOME PARALLEL
-
+//
 #include <iostream>
 #include <string>
 #include <stdio.h>
 
-#ifndef WNT
+#ifndef WIN32
 #include <unistd.h>
 #else
 #include <process.h>
 #include "SALOME_NamingService.hxx"
 
 #include "utilities.h"
-#include "Utils_ORB_INIT.hxx"
-#include "Utils_SINGLETON.hxx"
+#include "ArgvKeeper.hxx"
+#include "Basics_Utils.hxx"
 #include "SALOMETraceCollector.hxx"
 #include "OpUtil.hxx"
 
+#include "Container_init_python.hxx"
+
 #ifdef DEBUG_PARALLEL
 #include <signal.h>
-using namespace std;
 
 void handler(int t) {
-  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-  cerr << "SIGSEGV in :" << getpid() << endl;
-  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
-  cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << endl;
+  std::cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
+  std::cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
+  std::cerr << "SIGSEGV in :" << getpid() << std::endl;
+  std::cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
+  std::cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" << std::endl;
   while (1) {}
 }
 #endif
@@ -71,57 +72,68 @@ int main(int argc, char* argv[])
   signal(SIGSEGV, handler);
 #endif
   // Initialise the ORB.
-  CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);
+  SetArgcArgv(argc, argv);
+  CORBA::ORB_var orb = KERNEL::GetRefToORB();
+  KERNEL_PYTHON::init_python(argc,argv);
 
   std::string containerName("");
   if(argc > 1) {
     containerName = argv[1];
   }
 
+  int nbnodes = 1;
+  if(argc > 4) 
+    sscanf(argv[4],"%d",&nbnodes);
+
   try {  
     CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
     ASSERT(!CORBA::is_nil(obj));
     PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj);
     PortableServer::POAManager_var pman = root_poa->the_POAManager();
 
-#ifndef WNT
+#ifndef WIN32
     // add this container to the kill list
     char aCommand[100];
     sprintf(aCommand, "addToKillList.py %d SALOME_ParallelContainerProxyDummy", getpid());
     system(aCommand);
 #endif
 
-    SALOME_NamingService * ns = new SALOME_NamingService(CORBA::ORB::_duplicate(orb));
-//    Engines::Container_proxy_impl * proxy = 
-//      new Engines::Container_proxy_impl(orb,
-//                                     new paco_omni_fabrique());
+    SALOME_NamingService * ns = new SALOME_NamingService(orb);
 
-    Container_proxy_impl_final * proxy = 
-      new Container_proxy_impl_final(orb,
-                                    new paco_omni_fabrique());
     // PaCO++ code
     paco_fabrique_manager* pfm = paco_getFabriqueManager();
     pfm->register_com("dummy", new paco_dummy_fabrique());
-    proxy->setLibCom("dummy", proxy);
     pfm->register_thread("omnithread", new paco_omni_fabrique());
+
+    Container_proxy_impl_final * proxy = 
+      new Container_proxy_impl_final(orb,
+                                     pfm->get_thread("omnithread"),
+                                     root_poa,
+                                     containerName);
+    proxy->setLibCom("dummy", proxy);
     proxy->setLibThread("omnithread");
     // Topo of the parallel object
     PaCO::PacoTopology_t serveur_topo;
-    serveur_topo.total = 1;
+    serveur_topo.total = nbnodes;
     proxy->setTopology(serveur_topo);
 
-    PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
-    obj = root_poa->id_to_reference(_id);
+    //PortableServer::ObjectId_var _id = root_poa->activate_object(proxy);
+    //obj = root_poa->id_to_reference(_id);
+    obj = proxy->_this();
 
     // In the NamingService
-    string hostname = GetHostname();
+    std::string hostname = Kernel_Utils::GetHostname();
     Engines::Container_var pCont = Engines::Container::_narrow(obj);
     string _containerName = ns->BuildContainerNameForNS(containerName.c_str(),
-                                                       hostname.c_str());
-    cerr << "---------" << _containerName << "----------" << endl;
+                                                        hostname.c_str());
+    std::cerr << "---------" << _containerName << "----------" << std::endl;
     ns->Register(pCont, _containerName.c_str());
     pman->activate();
     orb->run();
+    PyGILState_Ensure();
+    //Delete python container that destroy orb from python (pyCont._orb.destroy())
+    Py_Finalize();
+    delete ns;
   }
   catch (PaCO::PACO_Exception& e)
   {