-// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#include "SALOME_FileTransfer_i.hxx"
#include "Salome_file_i.hxx"
#include "SALOME_NamingService.hxx"
+#include "SALOME_Fake_NamingService.hxx"
#include "Basics_Utils.hxx"
#ifdef _XOPEN_SOURCE
//=============================================================================
Engines_Container_i::Engines_Container_i () :
-_numInstance(0),_id(0),_NS(0)
+ _NS(0),_id(0),_numInstance(0)
{
}
PortableServer::POA_ptr poa,
char *containerName ,
int argc , char* argv[],
- bool activAndRegist,
+ SALOME_NamingService_Abstract *ns,
bool isServantAloneInProcess
) :
- _numInstance(0),_isServantAloneInProcess(isServantAloneInProcess),_id(0),_NS(0)
+ _NS(0),_id(0),_numInstance(0),_isServantAloneInProcess(isServantAloneInProcess)
{
_pid = (long)getpid();
- if(activAndRegist)
+ if(ns)
ActSigIntHandler() ;
_argc = argc ;
// Pour les containers paralleles: il ne faut pas enregistrer et activer
// le container generique, mais le container specialise
- if(activAndRegist)
{
_id = _poa->activate_object(this);
- _NS = new SALOME_NamingService();
+ _NS = ns==nullptr ? new SALOME_NamingService : ns->clone();
_NS->init_orb( _orb ) ;
CORBA::Object_var obj=_poa->id_to_reference(*_id);
Engines::Container_var pCont
{
itm->second->destroy();
}
- catch(const CORBA::Exception& e)
+ catch(const CORBA::Exception&)
{
// ignore this entry and continue
}
Engines::EngineComponent_ptr
Engines_Container_i::load_impl( const char* genericRegisterName,
- const char* componentName )
+ const char* /*componentName*/ )
{
char* reason;
std::string impl_name = std::string(LIB) + genericRegisterName + ENGINESO;
bool Engines_Container_i::isPythonContainer(const char* ContainerName)
{
bool ret=false;
- int len=strlen(ContainerName);
+ size_t len=strlen(ContainerName);
if(len>=2)
if(strcmp(ContainerName+len-2,"Py")==0)
ret=true;
void CallCancelThread() ;
#ifndef WIN32
-void SigIntHandler(int what ,
+void SigIntHandler(int /*what*/ ,
siginfo_t * siginfo ,
- void * toto )
+ void * /*toto*/ )
{
//PAL9042 JR : during the execution of a Signal Handler (and of methods called through Signal Handlers)
// use of streams (and so on) should never be used because :
aSalome_file->setLocalFile(origFileName);
aSalome_file->recvFiles();
}
- catch (const SALOME::SALOME_Exception& e)
+ catch (const SALOME::SALOME_Exception& /*e*/) //!< TODO: unused variable
{
return Engines::Salome_file::_nil();
}
_tmp_files.clear();
}
-/*
-std::string Engines_Container_i::AnotherMethodeToReplace_PyString_AsString(PyObject * result)
+static Engines_Container_i *_container_singleton_ssl = nullptr;
+
+static Engines::Container_var _container_ref_singleton_ssl;
+
+Engines_Container_i *KERNEL::getContainerSA()
{
- std::string my_result = "";
- if (PyUnicode_Check(result)) {
- // Convert string to bytes.
- // strdup() bytes into my_result.
- PyObject * temp_bytes = PyUnicode_AsEncodedString(result, "ASCII", "strict"); // Owned reference
- if (temp_bytes != NULL) {
- my_result = PyBytes_AS_STRING(temp_bytes); // Borrowed pointer
- my_result = strdup(my_result);
- Py_DECREF(temp_bytes);
- } else {
- // TODO PY3: Handle encoding error.
- Py_DECREF(temp_bytes);
- }
+ if(!_container_singleton_ssl)
+ {
+ int argc(0);
+ CORBA::ORB_var orb = CORBA::ORB_init(argc,nullptr);
+ CORBA::Object_var obj = orb->resolve_initial_references("RootPOA");
+ PortableServer::POA_var poa = PortableServer::POA::_narrow(obj);
+ PortableServer::POAManager_var pman = poa->the_POAManager();
+ CORBA::PolicyList policies;
+ policies.length(0);
+ //
+ char *argv[4] = {"Container","FactoryServer","toto",nullptr};
+ SALOME_Fake_NamingService ns;
+ _container_singleton_ssl = new Engines_Container_i(orb,poa,"FactoryServer",2,argv,&ns,false);
+ PortableServer::ObjectId * cont_id = _container_singleton_ssl->getCORBAId();
+ //
+ CORBA::Object_var zeRef = poa->id_to_reference(*cont_id);
+ _container_ref_singleton_ssl = Engines::Container::_narrow(zeRef);
+ }
+ return _container_singleton_ssl;
+}
- } else if (PyBytes_Check(result)) {
- // strdup() bytes into my_result.
- my_result = PyBytes_AS_STRING(result); // Borrowed pointer
- my_result = strdup(my_result);
- } else {
- // Convert into your favorite string representation.
- // Convert string to bytes if it is not already.
- // strdup() bytes into my_result.
- // TODO PY3: Check if only bytes is ok.
- PyObject * temp_bytes = PyObject_Bytes(result); // Owned reference
- if (temp_bytes != NULL) {
- my_result = PyBytes_AS_STRING(temp_bytes); // Borrowed pointer
- my_result = strdup(my_result);
- Py_DECREF(temp_bytes);
- } else {
- // TODO PY3: Handle error.
- Py_DECREF(temp_bytes);
- }
- }
- return my_result;
+Engines::Container_var KERNEL::getContainerRefSA()
+{
+ getContainerSA();
+ return _container_ref_singleton_ssl;
}
-*/