From 9675d7ff6c4d5c5deee1963bc7dd32efbc2c5d7a Mon Sep 17 00:00:00 2001 From: caremoli Date: Mon, 11 Feb 2008 08:39:00 +0000 Subject: [PATCH] CCAR: some debugs and more correct handle of maps in container --- salome_adm/unix/config_files/check_omniorb.m4 | 4 +-- src/Container/Container_i.cxx | 31 +++++++++---------- src/Container/SALOME_ContainerPy.py | 10 +++--- .../Datastream/Calcium/CalciumInterface.hxx | 2 +- src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx | 2 +- src/Utils/Utils_ORB_INIT.cxx | 2 +- 6 files changed, 23 insertions(+), 28 deletions(-) diff --git a/salome_adm/unix/config_files/check_omniorb.m4 b/salome_adm/unix/config_files/check_omniorb.m4 index 0f6d198a9..7818bc85f 100644 --- a/salome_adm/unix/config_files/check_omniorb.m4 +++ b/salome_adm/unix/config_files/check_omniorb.m4 @@ -17,7 +17,7 @@ AC_LANG_SAVE AC_LANG_CPLUSPLUS AC_PATH_PROG(OMNIORB_IDL, omniidl) -if test "xOMNIORB_IDL" = "x" +if test "x$OMNIORB_IDL" = "x" then omniORB_ok=no AC_MSG_RESULT(omniORB binaries not in PATH variable) @@ -101,8 +101,6 @@ then fi -dnl omniORB_ok=yes - if test "x$omniORB_ok" = "xyes" then if test "x$OMNIORB_LIB" = "x/usr/lib" diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index 2f5692fdc..ea1c23c11 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -336,8 +336,8 @@ Engines_Container_i::load_component_Library(const char* componentName) _numInstanceMutex.lock(); // lock to be alone // (see decInstanceCnt, finalize_removal)) - if (_toRemove_map[impl_name]) _toRemove_map.erase(impl_name); - if (_library_map[impl_name]) + if (_toRemove_map.count(impl_name) != 0) _toRemove_map.erase(impl_name); + if (_library_map.count(impl_name) != 0) { MESSAGE("Library " << impl_name << " already loaded"); _numInstanceMutex.unlock(); @@ -358,13 +358,6 @@ Engines_Container_i::load_component_Library(const char* componentName) _numInstanceMutex.unlock(); return true; } - else - { - INFOS( "Can't load shared library: " << impl_name ); -#ifndef WNT - INFOS("error dlopen: " << dlerror()); -#endif - } _numInstanceMutex.unlock(); // --- try import Python component @@ -375,7 +368,7 @@ Engines_Container_i::load_component_Library(const char* componentName) INFOS("Supervision Container does not support Python Component Engines"); return false; } - if (_library_map[aCompName]) + if (_library_map.count(aCompName) != 0) { return true; // Python Component, already imported } @@ -389,6 +382,7 @@ Engines_Container_i::load_component_Library(const char* componentName) "import_component", "s",componentName); int ret= PyInt_AsLong(result); + Py_XDECREF(result); SCRUTE(ret); Py_RELEASE_NEW_THREAD; @@ -401,6 +395,9 @@ Engines_Container_i::load_component_Library(const char* componentName) return true; } } + INFOS( "Impossible to load component: " << componentName ); + INFOS( "Can't load shared library: " << impl_name ); + INFOS( "Can't import Python module: " << componentName ); return false; } @@ -429,7 +426,7 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName, Engines::Component_var iobject = Engines::Component::_nil() ; string aCompName = genericRegisterName; - if (_library_map[aCompName]) // Python component + if (_library_map.count(aCompName) != 0) // Python component { if (_isSupervContainer) { @@ -478,14 +475,14 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName, #else string impl_name = genericRegisterName +string("Engine.dll"); #endif - void* handle = _library_map[impl_name]; - if ( !handle ) + if (_library_map.count(impl_name) == 0) { - INFOS("shared library " << impl_name <<"must be loaded before instance"); + INFOS("shared library " << impl_name <<" must be loaded before creating instance"); return Engines::Component::_nil() ; } else { + void* handle = _library_map[impl_name]; iobject = createInstance(genericRegisterName, handle, studyId); @@ -735,16 +732,16 @@ Engines_Container_i::find_or_create_instance(string genericRegisterName, { string aGenRegisterName = genericRegisterName; string impl_name = componentLibraryName; - void* handle = _library_map[impl_name]; - if ( !handle ) + if (_library_map.count(impl_name) == 0) { - INFOS("shared library " << impl_name <<"must be loaded before instance"); + INFOS("shared library " << impl_name <<" must be loaded before creating instance"); return Engines::Component::_nil() ; } else { // --- find a registered instance in naming service, or create + void* handle = _library_map[impl_name]; string component_registerBase = _containerName + "/" + aGenRegisterName; Engines::Component_var iobject = Engines::Component::_nil() ; diff --git a/src/Container/SALOME_ContainerPy.py b/src/Container/SALOME_ContainerPy.py index 843fa794f..1694bc79d 100755 --- a/src/Container/SALOME_ContainerPy.py +++ b/src/Container/SALOME_ContainerPy.py @@ -141,10 +141,10 @@ class SALOME_ContainerPy_i (Engines__POA.Container): self._numInstance = self._numInstance +1 instanceName = nameToRegister + "_inst_" + `self._numInstance` - component=__import__(componentName) - factory=getattr(component,componentName) - comp_i=factory(self._orb, self._poa, self._this(), self._containerName, - instanceName, nameToRegister) + component=__import__(componentName) + factory=getattr(component,componentName) + comp_i=factory(self._orb, self._poa, self._this(), self._containerName, + instanceName, nameToRegister) MESSAGE( "SALOME_ContainerPy_i::instance : component created") comp_o = comp_i._this() @@ -172,7 +172,7 @@ class SALOME_ContainerPy_i (Engines__POA.Container): ret=0 try: if verbose(): print "try import ",componentName - __import__(componentName) + module=__import__(componentName) if verbose(): print "import ",componentName," successful" ret=1 except: diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx index 71f157f16..8e8453c95 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx @@ -224,7 +224,7 @@ namespace CalciumInterface { ( dependencyType != CalciumTypes::SEQUENCE_DEPENDENCY ) ) throw CalciumException(CalciumTypes::CPITVR, LOC(OSS()<<"Le mode de dépendance de la variable " - << nomVar << " ne correspond pas au mode demandé.")); + << nomVar << ": " << portDependencyType << " ne correspond pas au mode demandé: " << dependencyType)); if ( dependencyType == CalciumTypes::TIME_DEPENDENCY ) { diff --git a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx index 830bb21cd..d429d0daa 100644 --- a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx +++ b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx @@ -112,7 +112,7 @@ public : typedef PortableServer::ServantBase TServant; if(_PtrObjet){ if(dynamic_cast(_PtrObjet)){ - std::cerr << "WARNING: automatic destruction for servant is no more used. It's too late in exit. Use explicit call" << std::endl; + // std::cerr << "WARNING: automatic destruction for servant is no more used. It's too late in exit. Use explicit call" << std::endl; /* if(TServant* aServant = dynamic_cast(_PtrObjet)){ PortableServer::POA_var aPOA = aServant->_default_POA(); diff --git a/src/Utils/Utils_ORB_INIT.cxx b/src/Utils/Utils_ORB_INIT.cxx index e2649a580..7d7370e71 100644 --- a/src/Utils/Utils_ORB_INIT.cxx +++ b/src/Utils/Utils_ORB_INIT.cxx @@ -40,7 +40,7 @@ ORB_INIT::~ORB_INIT() { if ( ! CORBA::is_nil( _orb ) ) { - std::cerr << "WARNING: orb destroy is no more called at exit. Use explicit call." << std::endl; + MESSAGE("WARNING: orb destroy is no more called at exit. Use explicit call."); //std::cerr << "appel _orb->destroy()" << std::endl; /* try { -- 2.39.2