From: vsr Date: Wed, 15 Oct 2008 09:12:23 +0000 (+0000) Subject: Issue 0019981: integrate patch for compilation with cmake (from E.Adam) X-Git-Tag: V5_1_0a3~16 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7f1e3682e3e9124f4e27d3adaeccddcde4ac6cc7;p=modules%2Fkernel.git Issue 0019981: integrate patch for compilation with cmake (from E.Adam) --- diff --git a/src/Basics/Basics_DirUtils.cxx b/src/Basics/Basics_DirUtils.cxx index 9b6afd8c3..f16df6be7 100644 --- a/src/Basics/Basics_DirUtils.cxx +++ b/src/Basics/Basics_DirUtils.cxx @@ -45,6 +45,14 @@ using namespace std; namespace Kernel_Utils { + string GetBaseName( const std::string& file_path ) + { + int pos = file_path.rfind( _separator_ ); + if ( pos >= 0 ) + return pos < file_path.size()-1 ? file_path.substr( pos+1 ) : ""; + return file_path; + } + string GetTmpDirByEnv( const std::string& tmp_path_env ) { string dir; diff --git a/src/Basics/Basics_DirUtils.hxx b/src/Basics/Basics_DirUtils.hxx index 5a64a84f9..3f39f88e6 100644 --- a/src/Basics/Basics_DirUtils.hxx +++ b/src/Basics/Basics_DirUtils.hxx @@ -34,6 +34,9 @@ namespace Kernel_Utils { + // Extracts and returns the base name of the specified file name. + BASICS_EXPORT std::string GetBaseName( const std::string& file_path ); + // Returns the unique temporary directory, that is defined in tmp_path_env if this variable is set // otherwise return /tmp/something/ for Unix or c:\something\ for WIN32 BASICS_EXPORT std::string GetTmpDirByEnv( const std::string& tmp_path_env ); diff --git a/src/LifeCycleCORBA/TestContainerManager.cxx b/src/LifeCycleCORBA/TestContainerManager.cxx index c53de4e84..f502e60da 100644 --- a/src/LifeCycleCORBA/TestContainerManager.cxx +++ b/src/LifeCycleCORBA/TestContainerManager.cxx @@ -28,7 +28,9 @@ #include "utilities.h" #include +#ifndef WNT #include +#endif #include #include "SALOME_NamingService.hxx" #include "SALOME_ContainerManager.hxx" @@ -39,12 +41,12 @@ #include "Utils_SINGLETON.hxx" #include "Utils_SALOME_Exception.hxx" #include "Utils_CommException.hxx" -using namespace std; +#include "Basics_DirUtils.hxx" int main (int argc, char * argv[]) { - map cycle; - map first; + std::map cycle; + std::map first; Engines::Container_ptr cont; Engines::Component_ptr compo; bool error = false; @@ -107,9 +109,9 @@ int main (int argc, char * argv[]) _NS->Change_Directory("/Containers"); - vector vec = _NS->list_directory_recurs(); - list lstCont; - for(vector::iterator iter = vec.begin();iter!=vec.end();iter++){ + std::vector vec = _NS->list_directory_recurs(); + std::list lstCont; + for(std::vector::iterator iter = vec.begin();iter!=vec.end();iter++){ CORBA::Object_var obj=_NS->Resolve((*iter).c_str()); Engines::Container_var cont=Engines::Container::_narrow(obj); if(!CORBA::is_nil(cont)){ @@ -118,13 +120,14 @@ int main (int argc, char * argv[]) lstCont.push_back((*iter)); } } - for(list::iterator iter=lstCont.begin();iter!=lstCont.end();iter++){ + for(std::list::iterator iter=lstCont.begin();iter!=lstCont.end();iter++){ CORBA::Object_var obj=_NS->Resolve((*iter).c_str()); Engines::Container_var cont=Engines::Container::_narrow(obj); if(!CORBA::is_nil(cont)){ - if(strncmp(basename(cont->name()),"cycl",4)==0) + std::string basename = Kernel_Utils::GetBaseName(cont->name()); + if(basename.compare(0,4,"cycl")==0) cycle[cont->getHostName()]++; - if(strncmp(basename(cont->name()),"first",5)==0) + if(basename.compare(0,5,"first")==0) first[cont->getHostName()]++; } } @@ -135,7 +138,7 @@ int main (int argc, char * argv[]) int fmin=10; int fmax=0; int nbpmax; - for(map::iterator iter=cycle.begin();iter!=cycle.end();iter++){ + for(std::map::iterator iter=cycle.begin();iter!=cycle.end();iter++){ if(strcmp((*iter).first.c_str(),"localhost")!=0){ Engines::MachineParameters *p = _ResManager->GetMachineParameters((*iter).first.c_str()); int nbproc = p->nb_node * p->nb_proc_per_node; @@ -148,7 +151,7 @@ int main (int argc, char * argv[]) } } } - string msg; + std::string msg; if( ((cmax-cmin) <= 1) && (fmax == 10/nbpmax) && !error ){ if(bestImplemented) msg = "TEST OK"; @@ -160,7 +163,7 @@ int main (int argc, char * argv[]) msg ="TEST KO"; status=1; } - cout << msg << endl; + std::cout << msg << std::endl; return status; }