#define SLASH '/'
#endif
-std::map<std::string, int> Engines_Container_i::_cntInstances_map;
-std::map<std::string, void *> Engines_Container_i::_library_map;
-std::map<std::string, void *> Engines_Container_i::_toRemove_map;
-omni_mutex Engines_Container_i::_numInstanceMutex ;
+std::map<std::string, int> Abstract_Engines_Container_i::_cntInstances_map;
+std::map<std::string, void *> Abstract_Engines_Container_i::_library_map;
+std::map<std::string, void *> Abstract_Engines_Container_i::_toRemove_map;
+omni_mutex Abstract_Engines_Container_i::_numInstanceMutex ;
static PyObject* _pyCont;
*/
//=============================================================================
-Engines_Container_i::Engines_Container_i () :
- _NS(0),_id(0),_numInstance(0)
+Abstract_Engines_Container_i::Abstract_Engines_Container_i () :
+ _NS(nullptr),_id(nullptr),_numInstance(0)
{
}
*/
//=============================================================================
-Engines_Container_i::Engines_Container_i (CORBA::ORB_ptr orb,
- PortableServer::POA_ptr poa,
- char *containerName ,
- int argc , char* argv[],
- SALOME_NamingService_Container_Abstract *ns,
- bool isServantAloneInProcess
- ) :
+Abstract_Engines_Container_i::Abstract_Engines_Container_i (CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ char *containerName ,
+ int argc , char* argv[],
+ SALOME_NamingService_Container_Abstract *ns,
+ bool isServantAloneInProcess
+ ) :
_NS(nullptr),_id(0),_numInstance(0),_isServantAloneInProcess(isServantAloneInProcess)
{
_pid = (long)getpid();
*/
//=============================================================================
-Engines_Container_i::~Engines_Container_i()
+Abstract_Engines_Container_i::~Abstract_Engines_Container_i()
{
- MESSAGE("Container_i::~Container_i()");
+ MESSAGE("Abstract_Container_i::~Abstract_Container_i()");
if(_id)
delete _id;
if(_NS)
*/
//=============================================================================
-char* Engines_Container_i::name()
+char* Abstract_Engines_Container_i::name()
{
return CORBA::string_dup(_containerName.c_str()) ;
}
*/
//=============================================================================
-char* Engines_Container_i::workingdir()
+char* Abstract_Engines_Container_i::workingdir()
{
char wd[256];
getcwd (wd,256);
*/
//=============================================================================
-char* Engines_Container_i::logfilename()
+char* Abstract_Engines_Container_i::logfilename()
{
return CORBA::string_dup(_logfilename.c_str()) ;
}
//! Set container log file name
-void Engines_Container_i::logfilename(const char* name)
+void Abstract_Engines_Container_i::logfilename(const char* name)
{
_logfilename=name;
}
*/
//=============================================================================
-char* Engines_Container_i::getHostName()
+char* Abstract_Engines_Container_i::getHostName()
{
std::string s = Kernel_Utils::GetHostname();
// MESSAGE("Engines_Container_i::getHostName " << s);
*/
//=============================================================================
-CORBA::Long Engines_Container_i::getPID()
+CORBA::Long Abstract_Engines_Container_i::getPID()
{
return (CORBA::Long)getpid();
}
* CORBA method: check if servant is still alive
*/
//=============================================================================
-void Engines_Container_i::ping()
+void Abstract_Engines_Container_i::ping()
{
MESSAGE("Engines_Container_i::ping() pid "<< getpid());
}
* - orb shutdown if no other servants in the process
*/
//=============================================================================
-void Engines_Container_i::Shutdown()
+void Abstract_Engines_Container_i::Shutdown()
{
MESSAGE("Engines_Container_i::Shutdown()");
*/
//=============================================================================
bool
-Engines_Container_i::load_component_Library(const char* componentName, CORBA::String_out reason)
+Abstract_Engines_Container_i::load_component_Library(const char* componentName, CORBA::String_out reason)
{
//=================================================================
*/
//=============================================================================
bool
-Engines_Container_i::load_component_CppImplementation(const char* componentName, std::string& reason)
+Abstract_Engines_Container_i::load_component_CppImplementation(const char* componentName, std::string& reason)
{
std::string aCompName(componentName);
std::string impl_name = std::string(LIB) + aCompName + ENGINESO;
*/
//=============================================================================
bool
-Engines_Container_i::load_component_PythonImplementation(const char* componentName, std::string& reason)
+Abstract_Engines_Container_i::load_component_PythonImplementation(const char* componentName, std::string& reason)
{
std::string aCompName(componentName);
*/
//=============================================================================
bool
-Engines_Container_i::load_component_ExecutableImplementation(const char* componentName, std::string& reason)
+Abstract_Engines_Container_i::load_component_ExecutableImplementation(const char* componentName, std::string& reason)
{
std::string aCompName(componentName);
std::string executable=aCompName+".exe";
*/
//=============================================================================
Engines::EngineComponent_ptr
-Engines_Container_i::create_component_instance(const char*genericRegisterName)
+Abstract_Engines_Container_i::create_component_instance(const char*genericRegisterName)
{
Engines::FieldsDict_var env = new Engines::FieldsDict;
char* reason;
*/
//=============================================================================
Engines::EngineComponent_ptr
-Engines_Container_i::create_component_instance_env(const char*genericRegisterName,
+Abstract_Engines_Container_i::create_component_instance_env(const char*genericRegisterName,
const Engines::FieldsDict& env,
CORBA::String_out reason)
{
*/
//=============================================================================
Engines::EngineComponent_ptr
-Engines_Container_i::createExecutableInstance(std::string CompName,
- const Engines::FieldsDict& env,
- std::string& reason)
+Abstract_Engines_Container_i::createExecutableInstance(std::string CompName,
+ const Engines::FieldsDict& env,
+ std::string& reason)
{
Engines::EngineComponent_var iobject = Engines::EngineComponent::_nil() ;
*/
//=============================================================================
Engines::EngineComponent_ptr
-Engines_Container_i::createPythonInstance(std::string CompName,
+Abstract_Engines_Container_i::createPythonInstance(std::string CompName,
std::string& reason)
{
Engines::EngineComponent_var iobject = Engines::EngineComponent::_nil() ;
}
char *
-Engines_Container_i::create_python_service_instance(const char * CompName,
+Abstract_Engines_Container_i::create_python_service_instance(const char * CompName,
CORBA::String_out reason)
{
CORBA::Object_var object = CORBA::Object::_nil();
*/
//=============================================================================
Engines::EngineComponent_ptr
-Engines_Container_i::createInstance(std::string genericRegisterName,
+Abstract_Engines_Container_i::createInstance(std::string genericRegisterName,
void *handle,
std::string& reason)
{
*/
//=============================================================================
Engines::EngineComponent_ptr
-Engines_Container_i::find_component_instance( const char* registeredName)
+Abstract_Engines_Container_i::find_component_instance( const char* registeredName)
{
Engines::EngineComponent_var anEngine = Engines::EngineComponent::_nil();
std::map<std::string,Engines::EngineComponent_var>::iterator itm =_listInstances_map.begin();
*/
//=============================================================================
-void Engines_Container_i::remove_impl(Engines::EngineComponent_ptr component_i)
+void Abstract_Engines_Container_i::remove_impl(Engines::EngineComponent_ptr component_i)
{
ASSERT(! CORBA::is_nil(component_i));
std::string instanceName = component_i->instanceName() ;
* CORBA method: Discharges unused libraries from the container.
*/
//=============================================================================
-void Engines_Container_i::finalize_removal()
+void Abstract_Engines_Container_i::finalize_removal()
{
MESSAGE("finalize unload : dlclose");
_numInstanceMutex.lock(); // lock to be alone
*
*/
//=============================================================================
-void Engines_Container_i::decInstanceCnt(std::string genericRegisterName)
+void Abstract_Engines_Container_i::decInstanceCnt(std::string genericRegisterName)
{
if(_cntInstances_map.count(genericRegisterName)==0)
return;
//=============================================================================
Engines::EngineComponent_ptr
-Engines_Container_i::load_impl( const char* genericRegisterName,
- const char* /*componentName*/ )
+Abstract_Engines_Container_i::load_impl( const char* genericRegisterName,
+ const char* /*componentName*/ )
{
char* reason;
std::string impl_name = std::string(LIB) + genericRegisterName + ENGINESO;
return iobject._retn();
}
-Engines::EmbeddedNamingService_ptr Engines_Container_i::get_embedded_NS_if_ssl()
+Engines::EmbeddedNamingService_ptr Abstract_Engines_Container_i::get_embedded_NS_if_ssl()
{
SALOME_Embedded_NamingService_Client *nsc(dynamic_cast<SALOME_Embedded_NamingService_Client *>(this->_NS));
if(nsc)
//=============================================================================
Engines::EngineComponent_ptr
-Engines_Container_i::find_or_create_instance(std::string genericRegisterName,
- std::string componentLibraryName)
+Abstract_Engines_Container_i::find_or_create_instance(std::string genericRegisterName,
+ std::string componentLibraryName)
{
std::string aGenRegisterName = genericRegisterName;
std::string impl_name = componentLibraryName;
* Retrieves only with container naming convention if it is a python container
*/
//=============================================================================
-bool Engines_Container_i::isPythonContainer(const char* ContainerName)
+bool Abstract_Engines_Container_i::isPythonContainer(const char* ContainerName)
{
bool ret=false;
size_t len=strlen(ContainerName);
* To remove : never returns !
*/
//=============================================================================
-bool Engines_Container_i::Kill_impl()
+bool Abstract_Engines_Container_i::Kill_impl()
{
MESSAGE("Engines_Container_i::Kill() pid "<< getpid() << " containerName "
<< _containerName.c_str() << " machineName "
*/
//=============================================================================
Engines::fileRef_ptr
-Engines_Container_i::createFileRef(const char* origFileName)
+Abstract_Engines_Container_i::createFileRef(const char* origFileName)
{
std::string origName(origFileName);
Engines::fileRef_var theFileRef = Engines::fileRef::_nil();
*/
//=============================================================================
Engines::fileTransfer_ptr
-Engines_Container_i::getFileTransfer()
+Abstract_Engines_Container_i::getFileTransfer()
{
Engines::fileTransfer_var aFileTransfer
= Engines::fileTransfer::_duplicate(_fileTransfer);
//! Create a Salome file
//=============================================================================
Engines::Salome_file_ptr
-Engines_Container_i::createSalome_file(const char* origFileName)
+Abstract_Engines_Container_i::createSalome_file(const char* origFileName)
{
std::string origName(origFileName);
if (CORBA::is_nil(_Salome_file_map[origName]))
* \param localFile the local file
*/
//=============================================================================
-void Engines_Container_i::copyFile(Engines::Container_ptr container, const char* remoteFile, const char* localFile)
+void Abstract_Engines_Container_i::copyFile(Engines::Container_ptr container, const char* remoteFile, const char* localFile)
{
Engines::fileTransfer_var fileTransfer = container->getFileTransfer();
* \return the PyNode
*/
//=============================================================================
-Engines::PyNode_ptr Engines_Container_i::createPyNode(const char* nodeName, const char* code)
+Engines::PyNode_ptr Abstract_Engines_Container_i::createPyNode(const char* nodeName, const char* code)
{
Engines::PyNode_var node= Engines::PyNode::_nil();
*
*/
//=============================================================================
-Engines::PyNode_ptr Engines_Container_i::getDefaultPyNode(const char *nodeName)
+Engines::PyNode_ptr Abstract_Engines_Container_i::getDefaultPyNode(const char *nodeName)
{
Utils_Locker lck(&_mutexForDftPy);
std::map<std::string,Engines::PyNode_var>::iterator it(_dftPyNode.find(nodeName));
* \return the PyScriptNode
*/
//=============================================================================
-Engines::PyScriptNode_ptr Engines_Container_i::createPyScriptNode(const char* nodeName, const char* code)
+Engines::PyScriptNode_ptr Abstract_Engines_Container_i::createPyScriptNode(const char* nodeName, const char* code)
{
Engines::PyScriptNode_var node= Engines::PyScriptNode::_nil();
}
}
-void Engines_Container_i::removePyScriptNode(const char *nodeName)
+void Abstract_Engines_Container_i::removePyScriptNode(const char *nodeName)
{
std::map<std::string,Engines::PyScriptNode_var>::iterator it(_dftPyScriptNode.find(nodeName));
if(it==_dftPyScriptNode.end())
_dftPyScriptNode.erase(it);
}
-void Engines_Container_i::cleanAllPyScripts()
+void Abstract_Engines_Container_i::cleanAllPyScripts()
{
for(std::map<std::string,Engines::PyNode_var>::iterator it=_dftPyNode.begin();it!=_dftPyNode.end();it++)
{
*
*/
//=============================================================================
-Engines::PyScriptNode_ptr Engines_Container_i::getDefaultPyScriptNode(const char *nodeName)
+Engines::PyScriptNode_ptr Abstract_Engines_Container_i::getDefaultPyScriptNode(const char *nodeName)
{
Utils_Locker lck(&_mutexForDftPy);
std::map<std::string,Engines::PyScriptNode_var>::iterator it(_dftPyScriptNode.find(nodeName));
return found;
}
-void Engines_Container_i::registerTemporaryFile( const std::string& fileName )
+void Abstract_Engines_Container_i::registerTemporaryFile( const std::string& fileName )
{
_tmp_files.remove( fileName );
_tmp_files.push_back( fileName );
}
-void Engines_Container_i::unregisterTemporaryFile( const std::string& fileName )
+void Abstract_Engines_Container_i::unregisterTemporaryFile( const std::string& fileName )
{
_tmp_files.remove( fileName );
}
-void Engines_Container_i::clearTemporaryFiles()
+void Abstract_Engines_Container_i::clearTemporaryFiles()
{
std::list<std::string>::const_iterator it;
for ( it = _tmp_files.begin(); it != _tmp_files.end(); ++it ) {
_tmp_files.clear();
}
-static Engines_Container_i *_container_singleton_ssl = nullptr;
+static Engines_Container_SSL_i *_container_singleton_ssl = nullptr;
static Engines::Container_var _container_ref_singleton_ssl;
-Engines_Container_i *KERNEL::getContainerSA()
+Engines_Container_SSL_i *KERNEL::getContainerSA()
{
if(!_container_singleton_ssl)
{
//
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);
+ _container_singleton_ssl = new Engines_Container_SSL_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);
#include <list>
#include <string>
-class SALOME_NamingService_Container_Abstract;
+class SALOME_NamingService_Container_Abstract;
-class CONTAINER_EXPORT Engines_Container_i:
- public virtual POA_Engines::Container,
- public virtual PortableServer::ServantBase
+class CONTAINER_EXPORT Abstract_Engines_Container_i : public virtual POA_Engines::Container,
+ public virtual PortableServer::ServantBase
{
public:
- Engines_Container_i();
- Engines_Container_i(CORBA::ORB_ptr orb,
- PortableServer::POA_ptr poa,
- char * containerName ,
- int argc, char* argv[],
- SALOME_NamingService_Container_Abstract *ns = nullptr,
- bool isServantAloneInProcess = true);
- virtual ~Engines_Container_i();
+ Abstract_Engines_Container_i();
+ Abstract_Engines_Container_i(CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ char *containerName,
+ int argc, char *argv[],
+ SALOME_NamingService_Container_Abstract *ns = nullptr,
+ bool isServantAloneInProcess = true);
+ virtual ~Abstract_Engines_Container_i();
+
+ virtual bool isSSLMode() const = 0;
// --- CORBA methods
- virtual bool load_component_Library(const char* componentName, CORBA::String_out reason);
+ virtual bool load_component_Library(const char *componentName, CORBA::String_out reason);
virtual Engines::EngineComponent_ptr
- create_component_instance( const char* componentName);
+ create_component_instance(const char *componentName);
virtual Engines::EngineComponent_ptr
- create_component_instance_env( const char* componentName,
- const Engines::FieldsDict& env,
- CORBA::String_out reason);
+ create_component_instance_env(const char *componentName,
+ const Engines::FieldsDict &env,
+ CORBA::String_out reason);
virtual char *
- create_python_service_instance(const char* CompName,
+ create_python_service_instance(const char *CompName,
CORBA::String_out reason);
Engines::EngineComponent_ptr
- find_component_instance( const char* registeredName);
+ find_component_instance(const char *registeredName);
Engines::EngineComponent_ptr
- load_impl(const char* nameToRegister,
- const char* componentName);
+ load_impl(const char *nameToRegister,
+ const char *componentName);
Engines::EmbeddedNamingService_ptr get_embedded_NS_if_ssl() override;
void finalize_removal();
virtual void ping();
- char* name();
- char* workingdir();
- char* logfilename();
- void logfilename(const char* name);
+ char *name();
+ char *workingdir();
+ char *logfilename();
+ void logfilename(const char *name);
virtual void Shutdown();
- char* getHostName();
+ char *getHostName();
CORBA::Long getPID();
//! Kill current container
bool Kill_impl();
- Engines::fileRef_ptr createFileRef(const char* origFileName);
+ Engines::fileRef_ptr createFileRef(const char *origFileName);
Engines::fileTransfer_ptr getFileTransfer();
- virtual Engines::Salome_file_ptr createSalome_file(const char* origFileName);
- void copyFile(Engines::Container_ptr container, const char* remoteFile, const char* localFile);
- Engines::PyNode_ptr createPyNode(const char* nodeName, const char* code);
+ virtual Engines::Salome_file_ptr createSalome_file(const char *origFileName);
+ void copyFile(Engines::Container_ptr container, const char *remoteFile, const char *localFile);
+ Engines::PyNode_ptr createPyNode(const char *nodeName, const char *code);
Engines::PyNode_ptr getDefaultPyNode(const char *nodeName);
- Engines::PyScriptNode_ptr createPyScriptNode(const char* nodeName, const char* code);
+ Engines::PyScriptNode_ptr createPyScriptNode(const char *nodeName, const char *code);
void removePyScriptNode(const char *nodeName) override;
void cleanAllPyScripts() override;
Engines::PyScriptNode_ptr getDefaultPyScriptNode(const char *nodeName);
// --- local C++ methods
Engines::EngineComponent_ptr
- find_or_create_instance( std::string genericRegisterName,
- std::string componentLibraryName);
+ find_or_create_instance(std::string genericRegisterName,
+ std::string componentLibraryName);
- bool load_component_CppImplementation(const char* componentName,std::string& reason);
- bool load_component_PythonImplementation(const char* componentName,std::string& reason);
- bool load_component_ExecutableImplementation(const char* componentName,std::string& reason);
+ bool load_component_CppImplementation(const char *componentName, std::string &reason);
+ bool load_component_PythonImplementation(const char *componentName, std::string &reason);
+ bool load_component_ExecutableImplementation(const char *componentName, std::string &reason);
- Engines::EngineComponent_ptr createPythonInstance(std::string CompName, std::string& error);
- Engines::EngineComponent_ptr createExecutableInstance(std::string CompName, const Engines::FieldsDict& env, std::string& error);
- Engines::EngineComponent_ptr createInstance(std::string genericRegisterName, void *handle, std::string& error);
+ Engines::EngineComponent_ptr createPythonInstance(std::string CompName, std::string &error);
+ Engines::EngineComponent_ptr createExecutableInstance(std::string CompName, const Engines::FieldsDict &env, std::string &error);
+ Engines::EngineComponent_ptr createInstance(std::string genericRegisterName, void *handle, std::string &error);
- static bool isPythonContainer(const char* ContainerName);
+ static bool isPythonContainer(const char *ContainerName);
static void decInstanceCnt(std::string genericRegisterName);
//??? char* machineName();
int getArgc() { return _argc; }
char **getArgv() { return _argv; }
- void registerTemporaryFile( const std::string& fileName );
- void unregisterTemporaryFile( const std::string& fileName );
+ void registerTemporaryFile(const std::string &fileName);
+ void unregisterTemporaryFile(const std::string &fileName);
void clearTemporaryFiles();
PortableServer::ObjectId *getCORBAId() const { return _id; }
protected:
-
static std::map<std::string, int> _cntInstances_map;
- static std::map<std::string, void *> _library_map; // library names, loaded
- static std::map<std::string, void *> _toRemove_map;// library names to remove
- static omni_mutex _numInstanceMutex ; // lib and instance protection
+ static std::map<std::string, void *> _library_map; // library names, loaded
+ static std::map<std::string, void *> _toRemove_map; // library names to remove
+ static omni_mutex _numInstanceMutex; // lib and instance protection
bool _isSupervContainer;
- SALOME_NamingService_Container_Abstract *_NS ;
+ SALOME_NamingService_Container_Abstract *_NS;
std::string _library_path;
std::string _containerName;
std::string _logfilename;
CORBA::ORB_var _orb;
PortableServer::POA_var _poa;
- PortableServer::ObjectId * _id ;
- int _numInstance ;
- std::map<std::string,Engines::EngineComponent_var> _listInstances_map;
- std::map<std::string,Engines::fileRef_var> _fileRef_map;
- std::map<std::string,Engines::Salome_file_var> _Salome_file_map;
- std::map<std::string,Engines::PyScriptNode_var> _dftPyScriptNode;
- std::map<std::string,Engines::PyNode_var> _dftPyNode;
+ PortableServer::ObjectId *_id;
+ int _numInstance;
+ std::map<std::string, Engines::EngineComponent_var> _listInstances_map;
+ std::map<std::string, Engines::fileRef_var> _fileRef_map;
+ std::map<std::string, Engines::Salome_file_var> _Salome_file_map;
+ std::map<std::string, Engines::PyScriptNode_var> _dftPyScriptNode;
+ std::map<std::string, Engines::PyNode_var> _dftPyNode;
Utils_Mutex _mutexForDftPy;
std::list<std::string> _tmp_files;
Engines::fileTransfer_var _fileTransfer;
- int _argc ;
- char** _argv ;
- long _pid;
- bool _isServantAloneInProcess;
+ int _argc;
+ char **_argv;
+ long _pid;
+ bool _isServantAloneInProcess;
+};
+
+class CONTAINER_EXPORT Engines_Container_i : public Abstract_Engines_Container_i
+{
+public:
+ Engines_Container_i();
+ Engines_Container_i(CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ char *containerName,
+ int argc, char *argv[],
+ SALOME_NamingService_Container_Abstract *ns = nullptr,
+ bool isServantAloneInProcess = true) :
+ Abstract_Engines_Container_i(orb, poa, containerName, argc, argv, ns, isServantAloneInProcess) {}
+ bool isSSLMode() const override { return false; }
+};
+
+class CONTAINER_EXPORT Engines_Container_SSL_i : public Abstract_Engines_Container_i
+{
+public:
+ Engines_Container_SSL_i();
+ Engines_Container_SSL_i(CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ char *containerName,
+ int argc, char *argv[],
+ SALOME_NamingService_Container_Abstract *ns = nullptr,
+ bool isServantAloneInProcess = true) :
+ Abstract_Engines_Container_i(orb, poa, containerName, argc, argv, ns, isServantAloneInProcess) {}
+ bool isSSLMode() const override { return true; }
};
/*!
*/
namespace KERNEL
{
- CONTAINER_EXPORT Engines_Container_i *getContainerSA();
+ CONTAINER_EXPORT Engines_Container_SSL_i *getContainerSA();
CONTAINER_EXPORT Engines::Container_var getContainerRefSA();
-}
+} // namespace KERNEL
#endif