X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FParallelContainer%2FSALOME_ParallelContainer_i.cxx;h=d0a58336ea2c6f4d4685a6698d01751219c3fddc;hb=8764993ca8f4c49e9115a82431facec577aba8a5;hp=1beef16323b716e224ea3a9f9af7dbdcae7b9f94;hpb=0fac7040be417aab7228a4e23904b4cf22a8dda4;p=modules%2Fkernel.git diff --git a/src/ParallelContainer/SALOME_ParallelContainer_i.cxx b/src/ParallelContainer/SALOME_ParallelContainer_i.cxx index 1beef1632..d0a58336e 100644 --- a/src/ParallelContainer/SALOME_ParallelContainer_i.cxx +++ b/src/ParallelContainer/SALOME_ParallelContainer_i.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2016 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 @@ -66,7 +66,7 @@ extern "C" {void SigIntHandler( int ) ; } //============================================================================= /*! - * Construtor + * Constructor */ //============================================================================= @@ -282,7 +282,7 @@ void Engines_Parallel_Container_i::Shutdown() * \param componentName like COMPONENT * try to make a Python import of COMPONENT, * then a lib open of libCOMPONENTEngine.so - * \return true if dlopen successfull or already done, false otherwise + * \return true if dlopen successful or already done, false otherwise */ //============================================================================= @@ -295,7 +295,11 @@ Engines_Parallel_Container_i::load_component_Library(const char* componentName, bool ret = false; std::string aCompName = componentName; #ifndef WIN32 +#ifdef __APPLE__ + std::string impl_name = string ("lib") + aCompName + string("Engine.dylib"); +#else std::string impl_name = string ("lib") + aCompName + string("Engine.so"); +#endif #else std::string impl_name = aCompName + string("Engine.dll"); #endif @@ -321,7 +325,7 @@ Engines_Parallel_Container_i::load_component_Library(const char* componentName, MESSAGE("Try to load C++ component"); void* handle; #ifndef WIN32 - handle = dlopen( impl_name.c_str() , RTLD_LAZY ) ; + handle = dlopen( impl_name.c_str() , RTLD_LAZY | RTLD_GLOBAL ) ; #else handle = dlopen( impl_name.c_str() , 0 ) ; #endif @@ -349,7 +353,7 @@ Engines_Parallel_Container_i::load_component_Library(const char* componentName, PyObject *result = PyObject_CallMethod(pyCont, (char*)"import_component", (char*)"s",componentName); - std::string ret_p= PyString_AsString(result); + std::string ret_p= PyUnicode_AsUTF8(result); Py_XDECREF(result); Py_RELEASE_NEW_THREAD; @@ -376,18 +380,15 @@ Engines_Parallel_Container_i::load_component_Library(const char* componentName, * The servant registers itself to naming service and Registry. * \param genericRegisterName Name of the component instance to register * in Registry & Name Service (without _inst_n suffix) - * \param studyId 0 for multiStudy instance, - * study Id (>0) otherwise * \return a loaded component */ //============================================================================= Engines::EngineComponent_ptr -Engines_Parallel_Container_i::create_component_instance(const char*genericRegisterName, - CORBA::Long studyId) +Engines_Parallel_Container_i::create_component_instance(const char*genericRegisterName) { Engines::FieldsDict_var env = new Engines::FieldsDict; char* reason; - Engines::EngineComponent_ptr compo = create_component_instance_env(genericRegisterName,studyId,env, reason); + Engines::EngineComponent_ptr compo = create_component_instance_env(genericRegisterName,env, reason); CORBA::string_free(reason); return compo; } @@ -399,8 +400,6 @@ Engines_Parallel_Container_i::create_component_instance(const char*genericRegist * The servant registers itself to naming service and Registry. * \param genericRegisterName Name of the component instance to register * in Registry & Name Service (without _inst_n suffix) - * \param studyId 0 for multiStudy instance, - * study Id (>0) otherwise * \param env dict of environment variables * \return a loaded component */ @@ -408,22 +407,19 @@ Engines_Parallel_Container_i::create_component_instance(const char*genericRegist Engines::EngineComponent_ptr Engines_Parallel_Container_i::create_component_instance_env(const char*genericRegisterName, - CORBA::Long studyId, const Engines::FieldsDict& env, CORBA::String_out reason) { MESSAGE("Begin of create_component_instance in node : " << getMyRank()); reason=CORBA::string_dup(""); - if (studyId < 0) - { - INFOS("studyId must be > 0 for mono study instance, =0 for multiStudy"); - return Engines::EngineComponent::_nil() ; - } - std::string aCompName = genericRegisterName; #ifndef WIN32 +#ifdef __APPLE__ + std::string impl_name = string ("lib") + aCompName + string("Engine.dylib"); +#else std::string impl_name = string ("lib") + aCompName +string("Engine.so"); +#endif #else std::string impl_name = aCompName +string("Engine.dll"); #endif @@ -436,7 +432,7 @@ Engines_Parallel_Container_i::create_component_instance_env(const char*genericRe void* handle = _library_map[impl_name]; if (handle) type_of_lib = "cpp"; - if (_library_map.count(aCompName) != 0 and !handle) + if (_library_map.count(aCompName) != 0 && !handle) type_of_lib = "python"; if (type_of_lib == "Not Loaded") @@ -448,9 +444,9 @@ Engines_Parallel_Container_i::create_component_instance_env(const char*genericRe Engines::EngineComponent_var iobject = Engines::EngineComponent::_nil(); if (type_of_lib == "cpp") - iobject = createCPPInstance(aCompName, handle, studyId); + iobject = createCPPInstance(aCompName, handle); else - iobject = createPythonInstance(aCompName, studyId); + iobject = createPythonInstance(aCompName); _numInstanceMutex.unlock(); return iobject._retn(); @@ -462,14 +458,11 @@ Engines_Parallel_Container_i::create_component_instance_env(const char*genericRe * CORBA method: Finds a servant instance of a component * \param registeredName Name of the component in Registry or Name Service, * without instance suffix number - * \param studyId 0 if instance is not associated to a study, - * >0 otherwise (== study id) - * \return the first instance found with same studyId + * \return the first found instance */ //============================================================================= -Engines::EngineComponent_ptr Engines_Parallel_Container_i::find_component_instance( const char* registeredName, - CORBA::Long studyId) +Engines::EngineComponent_ptr Engines_Parallel_Container_i::find_component_instance(const char* registeredName) { Engines::EngineComponent_var anEngine = Engines::EngineComponent::_nil(); std::map::iterator itm =_listInstances_map.begin(); @@ -480,16 +473,21 @@ Engines::EngineComponent_ptr Engines_Parallel_Container_i::find_component_instan if (instance.find(registeredName) == 0) { anEngine = (*itm).second; - if (studyId == anEngine->getStudyId()) - { - return anEngine._retn(); - } + return anEngine._retn(); } itm++; } return anEngine._retn(); } +char* Engines_Parallel_Container_i::create_python_service_instance(const char* CompName, + CORBA::String_out reason) +{ + // not implemented + reason=CORBA::string_dup(""); + return CORBA::string_dup(""); +} + //============================================================================= //! Find or create a new component instance /*! @@ -619,7 +617,7 @@ Engines_Parallel_Container_i::createFileRef(const char* origFileName) if (origName[0] != '/') { - INFOS("path of file to copy must be an absolute path begining with '/'"); + INFOS("path of file to copy must be an absolute path beginning with '/'"); return Engines::fileRef::_nil(); } @@ -721,27 +719,16 @@ Engines_Parallel_Container_i::find_or_create_instance(std::string genericRegiste CORBA::Object_var obj = _NS->ResolveFirst(component_registerBase.c_str()); if (CORBA::is_nil( obj )) { - iobject = create_component_instance(genericRegisterName.c_str(), - 0); // force multiStudy instance here ! + iobject = create_component_instance(genericRegisterName.c_str()); } else { iobject = Engines::EngineComponent::_narrow(obj) ; - Engines_Component_i *servant = dynamic_cast(_poa->reference_to_servant(iobject)); - ASSERT(servant) - int studyId = servant->getStudyId(); - ASSERT (studyId >= 0); - if (studyId != 0) // monoStudy instance: NOK - { - iobject = Engines::EngineComponent::_nil(); - INFOS("load_impl & find_component_instance methods " - << "NOT SUITABLE for mono study components"); - } } } catch (...) { - INFOS( "Container_i::load_impl catched" ) ; + INFOS( "Container_i::load_impl caught" ) ; } return iobject._retn(); } @@ -754,8 +741,6 @@ Engines_Parallel_Container_i::find_or_create_instance(std::string genericRegiste * in Registry & Name Service, * (without _inst_n suffix, like "COMPONENT") * \param handle loaded library handle - * \param studyId 0 for multiStudy instance, - * study Id (>0) otherwise * \return a loaded component * * example with names: @@ -768,7 +753,7 @@ Engines_Parallel_Container_i::find_or_create_instance(std::string genericRegiste */ //============================================================================= Engines::EngineComponent_ptr -Engines_Parallel_Container_i::createPythonInstance(std::string genericRegisterName, int studyId) +Engines_Parallel_Container_i::createPythonInstance(std::string genericRegisterName) { Engines::EngineComponent_var iobject = Engines::EngineComponent::_nil(); @@ -785,10 +770,9 @@ Engines_Parallel_Container_i::createPythonInstance(std::string genericRegisterNa PyObject *pyCont = PyDict_GetItemString(globals, "pyCont"); PyObject *result = PyObject_CallMethod(pyCont, (char*)"create_component_instance", - (char*)"ssl", + (char*)"ss", genericRegisterName.c_str(), - instanceName.c_str(), - studyId); + instanceName.c_str()); const char *ior; const char *error; PyArg_ParseTuple(result,"ss", &ior, &error); @@ -816,8 +800,6 @@ Engines_Parallel_Container_i::createPythonInstance(std::string genericRegisterNa * in Registry & Name Service, * (without _inst_n suffix, like "COMPONENT") * \param handle loaded library handle - * \param studyId 0 for multiStudy instance, - * study Id (>0) otherwise * \return a loaded component * * example with names: @@ -831,8 +813,7 @@ Engines_Parallel_Container_i::createPythonInstance(std::string genericRegisterNa //============================================================================= Engines::EngineComponent_ptr Engines_Parallel_Container_i::createCPPInstance(std::string genericRegisterName, - void *handle, - int studyId) + void *handle) { MESSAGE("Entering Engines_Parallel_Container_i::createCPPInstance"); @@ -875,7 +856,7 @@ Engines_Parallel_Container_i::createCPPInstance(std::string genericRegisterName, std::string component_registerName = _containerName + "/" + instanceName; - // --- Instanciate required CORBA object + // --- Instantiate required CORBA object PortableServer::ObjectId *id; //not owner, do not delete (nore use var) id = (Component_factory) ( _orb, _poa, _id, instanceName.c_str(), @@ -886,22 +867,12 @@ Engines_Parallel_Container_i::createCPPInstance(std::string genericRegisterName, return iobject._retn(); } - // --- get reference & servant from id + // --- get reference from id CORBA::Object_var obj = _poa->id_to_reference(*id); iobject = Engines::EngineComponent::_narrow(obj); - Engines_Component_i *servant = - dynamic_cast(_poa->reference_to_servant(iobject)); - ASSERT(servant); - servant->_remove_ref(); // compensate previous id_to_reference _listInstances_map[instanceName] = iobject; _cntInstances_map[aGenRegisterName] += 1; -#if defined(_DEBUG_) || defined(_DEBUG) - bool ret_studyId = servant->setStudyId(studyId); - ASSERT(ret_studyId); -#else - servant->setStudyId(studyId); -#endif // --- register the engine under the name // containerName(.dir)/instanceName(.object) @@ -910,15 +881,14 @@ Engines_Parallel_Container_i::createCPPInstance(std::string genericRegisterName, } catch (...) { - INFOS( "Container_i::createInstance exception catched" ); + INFOS( "Container_i::createInstance exception caught" ); } return iobject._retn(); } void Engines_Parallel_Container_i::create_paco_component_node_instance(const char* componentName, - const char* proxy_containerName, - CORBA::Long studyId) + const char* proxy_containerName) { // Init de la méthode char * proxy_ior; @@ -927,7 +897,11 @@ Engines_Parallel_Container_i::create_paco_component_node_instance(const char* co std::string _proxy_containerName = proxy_containerName; #ifndef WIN32 +#ifdef __APPLE__ + string impl_name = string ("lib") + aCompName + string("Engine.dylib"); +#else string impl_name = string ("lib") + aCompName +string("Engine.so"); +#endif #else string impl_name = aCompName +string("Engine.dll"); #endif @@ -978,12 +952,12 @@ Engines_Parallel_Container_i::create_paco_component_node_instance(const char* co std::string instanceName = aCompName + "_inst_" + aNumI + "_work_node_" + aNumI2; std::string component_registerName = _containerName + "/" + instanceName; - // --- Instanciate work node + // --- Instantiate work node PortableServer::ObjectId *id ; //not owner, do not delete (nore use var) id = (Component_factory) (_orb, proxy_ior, getMyRank(), _poa, _id, instanceName.c_str(), componentName); CORBA::string_free(proxy_ior); - // --- get reference & servant from id + // --- get reference from id CORBA::Object_var obj = _poa->id_to_reference(*id); work_node = Engines::EngineComponent_PaCO::_narrow(obj) ; if (CORBA::is_nil(work_node)) @@ -1001,10 +975,10 @@ Engines_Parallel_Container_i::create_paco_component_node_instance(const char* co } catch (...) { - INFOS("Container_i::create_paco_component_node_instance exception catched"); + INFOS("Container_i::create_paco_component_node_instance exception caught"); SALOME::ExceptionStruct es; es.type = SALOME::INTERNAL_ERROR; - es.text = "Container_i::create_paco_component_node_instance exception catched"; + es.text = "Container_i::create_paco_component_node_instance exception caught"; throw SALOME::SALOME_Exception(es); } } @@ -1127,6 +1101,12 @@ Engines_Parallel_Container_i::createPyNode(const char* nodeName, const char* cod return node._retn(); } +Engines::PyNode_ptr Engines_Parallel_Container_i::getDefaultPyNode(const char *nodeName) +{ + INFOS("Python component not yet implemented"); + return Engines::PyNode::_nil(); +} + Engines::PyScriptNode_ptr Engines_Parallel_Container_i::createPyScriptNode(const char* nodeName, const char* cod) { @@ -1135,6 +1115,12 @@ Engines_Parallel_Container_i::createPyScriptNode(const char* nodeName, const cha return node._retn(); } +Engines::PyScriptNode_ptr Engines_Parallel_Container_i::getDefaultPyScriptNode(const char *nodeName) +{ + INFOS("Python script node not yet implemented"); + return Engines::PyScriptNode::_nil(); +} + //============================================================================= /*! *