From d1a07f9db977a39b65e99f24f25e933de36621b5 Mon Sep 17 00:00:00 2001 From: caremoli Date: Wed, 7 Jul 2010 14:34:15 +0000 Subject: [PATCH] CCAR: various optimisations and synchronize with V5_1_main branch --- bin/launchConfigureParser.py | 14 ++++++ bin/runSalome.py | 9 ++++ idl/SALOMEDS.idl | 2 +- salome_adm/cmake_files/am2cmake.py | 50 ++++++++++++++----- src/KERNEL_PY/import_hook.py | 4 +- src/SALOMEDS/SALOMEDS_Study.cxx | 4 +- src/SALOMEDS/SALOMEDS_Study.hxx | 2 +- src/SALOMEDS/SALOMEDS_Study_i.cxx | 34 ++++++------- src/SALOMEDS/SALOMEDS_Study_i.hxx | 2 +- src/SALOMEDSClient/SALOMEDSClient_Study.hxx | 2 +- .../SALOMEDSImpl_GenericAttribute.cxx | 2 +- src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx | 4 +- .../SALOMEDSImpl_StudyBuilder.cxx | 4 +- 13 files changed, 91 insertions(+), 42 deletions(-) diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 7fde55b79..b807edad5 100755 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -59,6 +59,7 @@ test_nam = "test" play_nam = "play" gdb_session_nam = "gdb_session" ddd_session_nam = "ddd_session" +valgrind_session_nam = "valgrind_session" shutdown_servers_nam = "shutdown_servers" # values in XML configuration file giving specific module parameters ( section) @@ -638,6 +639,14 @@ def CreateOptionParser (theAdditionalOptions=[]): dest="ddd_session", default=False, help=help_str) + + # valgrind session + help_str = "Launch session with valgrind $VALGRIND_OPTIONS" + o_valgrind = optparse.Option("--valgrind-session", + action="store_true", + dest="valgrind_session", default=False, + help=help_str) + # shutdown-servers. Default: False. help_str = "1 to shutdown standalone servers when leaving python interpreter, " help_str += "0 to keep the standalone servers as daemon [default]. " @@ -675,6 +684,7 @@ def CreateOptionParser (theAdditionalOptions=[]): o_play, # Reproducing test script with help of TestRecorder o_gdb, o_ddd, + o_valgrind, o_shutdown, ] @@ -969,6 +979,10 @@ def get_env(theAdditionalOptions=[], appname="SalomeApp"): if cmd_opts.ddd_session is not None: args[ddd_session_nam] = cmd_opts.ddd_session + # valgrind session + if cmd_opts.valgrind_session is not None: + args[valgrind_session_nam] = cmd_opts.valgrind_session + # Shutdown servers if cmd_opts.shutdown_servers is None: args[shutdown_servers_nam] = 0 diff --git a/bin/runSalome.py b/bin/runSalome.py index d03a67d6e..f0bed272d 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -323,6 +323,15 @@ class SessionServer(Server): pass pass + if self.args["valgrind_session"]: + l = ["valgrind"] + val = os.getenv("VALGRIND_OPTIONS") + if val: + l += val.split() + pass + self.CMD = l + self.CMD + pass + # --- class LauncherServer(Server): diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index ace331d1a..0699b8985 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -553,7 +553,7 @@ during each working session. \param theObserver */ - void attach(in SALOME::Observer theObserver); + void attach(in SALOME::Observer theObserver, in boolean modify); }; //========================================================================== diff --git a/salome_adm/cmake_files/am2cmake.py b/salome_adm/cmake_files/am2cmake.py index 19ced5ac6..b2c757193 100644 --- a/salome_adm/cmake_files/am2cmake.py +++ b/salome_adm/cmake_files/am2cmake.py @@ -750,6 +750,23 @@ class CMakeFile(object): ENDIF(KERNEL_ROOT_DIR) ''') pass + if self.module == "hxx2salome": + key = "_SRC" + if self.the_root[-len(key):] != key: + msg = "Source dir must finished with %s !"%(key) + raise Exception(msg) + hxxmodule = self.the_root[:-len(key)] + from os.path import basename + hxxmodule = basename(hxxmodule) + hxxmodule = hxxmodule.lower() + self.hxxmodule = hxxmodule + newlines.append(r''' + SET(HXXCPP_ROOT_DIR $ENV{%sCPP_ROOT_DIR}) + SET(AM_CPPFLAGS ${AM_CPPFLAGS} -I${HXXCPP_ROOT_DIR}/include) + SET(AM_CXXFLAGS ${AM_CXXFLAGS} -I${HXXCPP_ROOT_DIR}/include) + SET(LDADD ${LDADD} -L${HXXCPP_ROOT_DIR}/lib) + '''%(hxxmodule.upper())) + pass pass # -- return @@ -1242,6 +1259,10 @@ class CMakeFile(object): # -- # Treat the install targets # -- + resdir = self.module + if resdir == "hxx2salome": + resdir = self.hxxmodule + pass d = { "salomeadmux_DATA" : "salome_adm/unix", "dist_salomeadmux_DATA" : "salome_adm/unix", @@ -1252,9 +1273,9 @@ class CMakeFile(object): "dist_admlocal_cmake_DATA" : "adm_local/cmake_files", "salomeinclude_DATA" : "include/salome", "salomeinclude_HEADERS" : "include/salome", - "dist_salomeres_DATA" : "share/salome/resources/%s"%(self.module), - "nodist_salomeres_DATA" : "share/salome/resources/%s"%(self.module), - "nodist_salomeres_SCRIPTS" : "share/salome/resources/%s"%(self.module), + "dist_salomeres_DATA" : "share/salome/resources/%s"%(resdir), + "nodist_salomeres_DATA" : "share/salome/resources/%s"%(resdir), + "nodist_salomeres_SCRIPTS" : "share/salome/resources/%s"%(resdir), "dist_salomescript_SCRIPTS" : "bin/salome", "dist_salomescript_DATA" : "bin/salome", "dist_salomescript_PYTHON" : "bin/salome", @@ -1311,18 +1332,13 @@ class CMakeFile(object): ''') # -- newlines.append(r''' - SET(libs ${PLATFORM_LIBADD} ${PLATFORM_LDFLAGS} ${${amname}_LIBADD} ${${amname}_LDADD} ${${amname}_LDFLAGS}) + SET(libs ${PLATFORM_LIBADD} ${PLATFORM_LDFLAGS} ${LDADD} ${${amname}_LIBADD} ${${amname}_LDADD} ${${amname}_LDFLAGS}) FOREACH(lib SALOMEBasics SalomeBatch) IF(name STREQUAL lib) SET(libs ${libs} ${PTHREAD_LIBS}) ENDIF(name STREQUAL lib) ENDFOREACH(lib SALOMEBasics SalomeBatch) ''') - if key == "bin_PROGRAMS": - newlines.append(r''' - SET(libs ${libs} ${LDADD}) - ''') - pass # -- newlines.append(r''' FOREACH(lib ${libs}) @@ -1933,6 +1949,8 @@ if __name__ == "__main__": from os import getcwd the_root = getcwd() # + nok = 0 + # from os import walk for root, dirs, files in walk(the_root): # -- @@ -1954,12 +1972,20 @@ if __name__ == "__main__": from sys import stdout for f in files: if f in ["Makefile.am", "Makefile.am.cmake"]: - stdout.write("Scanning %s %s ..."%(root, f)) - stdout.flush() convertAmFile(the_root, root, dirs, files, f, module) - stdout.write(" done.\n") + nok += 1 pass pass pass # + if nok: + if nok == 1: + msg = "%s file has been converted to cmake"%(nok) + else: + msg = "%s files have been converted to cmake"%(nok) + pass + stdout.write(msg) + stdout.write("\n") + stdout.flush() + pass pass diff --git a/src/KERNEL_PY/import_hook.py b/src/KERNEL_PY/import_hook.py index 54c5f1313..3d628ecab 100755 --- a/src/KERNEL_PY/import_hook.py +++ b/src/KERNEL_PY/import_hook.py @@ -151,14 +151,14 @@ def ensure_fromlist(m, fromlist, recursive=0): l.append((subname,submod)) return l -def import_hook(name, globals=None, locals=None, fromlist=None, *args): +def import_hook(name, globals=None, locals=None, fromlist=None, *args, **kwds): """ Import replacement for sharing modules among multiple interpreters Mostly update sys.modules before doing real import """ #print "import_hook",name,fromlist m=get_shared_imported(name,fromlist) - module= original_import(name, globals, locals, fromlist, *args) + module= original_import(name, globals, locals, fromlist, *args, **kwds) if fromlist: #when fromlist is specified, module is the real module diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index 43c7932a1..da6093f87 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -1000,9 +1000,9 @@ _PTR(AttributeParameter) SALOMEDS_Study::GetModuleParameters(const std::string& return _PTR(AttributeParameter)(AP); } -void SALOMEDS_Study::attach(SALOME::Observer_ptr theObserver) +void SALOMEDS_Study::attach(SALOME::Observer_ptr theObserver,bool modify) { if(CORBA::is_nil(_corba_impl)) GetStudy(); //If CORBA implementation is null then retrieve it - _corba_impl->attach(theObserver); + _corba_impl->attach(theObserver,modify); } diff --git a/src/SALOMEDS/SALOMEDS_Study.hxx b/src/SALOMEDS/SALOMEDS_Study.hxx index 4f17c4d86..1f5eae6b6 100644 --- a/src/SALOMEDS/SALOMEDS_Study.hxx +++ b/src/SALOMEDS/SALOMEDS_Study.hxx @@ -122,7 +122,7 @@ public: virtual bool RenameVariable(const std::string& theVarName, const std::string& theNewVarName); virtual bool IsVariableUsed(const std::string& theVarName); virtual std::vector< std::vector > ParseVariables(const std::string& theVars); - virtual void attach(SALOME::Observer_ptr theObserver); + virtual void attach(SALOME::Observer_ptr theObserver,bool modify); std::string ConvertObjectToIOR(CORBA::Object_ptr theObject); CORBA::Object_ptr ConvertIORToObject(const std::string& theIOR); diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 0bb71eb4f..ed9a6b14a 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -67,12 +67,11 @@ public: virtual bool addSO_Notification(const SALOMEDSImpl_SObject& theSObject) { - //MESSAGE("Notification ADD called") - CORBA::String_var event="ADD"; - CORBA::String_var anID=theSObject.GetID().c_str(); + std::string anID=theSObject.GetID(); + const char* cID=anID.c_str(); for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it) { - (*it)->notifyObserver(anID,event); + it->first->notifyObserver(cID,"ADD"); } return true; // NGE return always true but can be modified if needed } @@ -85,12 +84,11 @@ public: virtual bool removeSO_Notification(const SALOMEDSImpl_SObject& theSObject) { - //MESSAGE("Notification REMOVE called") - CORBA::String_var event="REMOVE"; - CORBA::String_var anID=theSObject.GetID().c_str(); + std::string anID=theSObject.GetID(); + const char* cID=anID.c_str(); for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it) { - (*it)->notifyObserver(anID,event); + it->first->notifyObserver(cID,"REMOVE"); } return true; // NGE return always true but can be modified if needed } @@ -103,12 +101,14 @@ public: virtual bool modifySO_Notification(const SALOMEDSImpl_SObject& theSObject) { - //MESSAGE("Notification MODIFY called") - CORBA::String_var event="MODIFY"; - CORBA::String_var anID=theSObject.GetID().c_str(); for (ObsListIter it (myObservers.begin()); it != myObservers.end(); ++it) { - (*it)->notifyObserver(anID,event); + if(it->second) + { + std::string anID=theSObject.GetID(); + const char* cID=anID.c_str(); + it->first->notifyObserver(cID,"MODIFY"); + } } return true; // NGE return always true but can be modified if needed } @@ -119,13 +119,13 @@ public: */ //============================================================================ - virtual void attach(SALOME::Observer_ptr theObs) + virtual void attach(SALOME::Observer_ptr theObs, bool modify) { - myObservers.push_back(SALOME::Observer::_duplicate(theObs)); + myObservers.push_back(std::pair< SALOME::Observer_var, bool > (SALOME::Observer::_duplicate(theObs),modify)); } private: - typedef std::list ObsList; + typedef std::list< std::pair< SALOME::Observer_var, bool > > ObsList; typedef ObsList::iterator ObsListIter; ObsList myObservers; }; @@ -1232,9 +1232,9 @@ void SALOMEDS_Study_i::EnableUseCaseAutoFilling(CORBA::Boolean isEnabled) * Purpose : This function attach an observer to the study */ //============================================================================ -void SALOMEDS_Study_i::attach(SALOME::Observer_ptr theObs) +void SALOMEDS_Study_i::attach(SALOME::Observer_ptr theObs,CORBA::Boolean modify) { - _notifier->attach(theObs); + _notifier->attach(theObs,modify); } //=========================================================================== diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index b2df91f87..9e3651ccd 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -349,7 +349,7 @@ public: virtual CORBA::LongLong GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal); - virtual void attach(SALOME::Observer_ptr theObs); + virtual void attach(SALOME::Observer_ptr theObs, CORBA::Boolean modify); }; #endif diff --git a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx index 920104048..53f906994 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx @@ -123,7 +123,7 @@ public: virtual std::vector< std::vector > ParseVariables(const std::string& theVars) = 0; - virtual void attach(SALOME::Observer_ptr theObserver) = 0; + virtual void attach(SALOME::Observer_ptr theObserver,bool modify) = 0; }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.cxx index afa1b1c5c..7f3544df1 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_GenericAttribute.cxx @@ -85,7 +85,7 @@ void SALOMEDSImpl_GenericAttribute::SetModifyFlag() if(aLabel.IsNull()) return; SALOMEDSImpl_Study* aStudy = SALOMEDSImpl_Study::GetStudy(aLabel); - //if(aStudy) aStudy->modifySO_Notification(GetSObject()); + if(aStudy) aStudy->modifySO_Notification(GetSObject()); if(aStudy) aStudy->Modify(); } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index 3c10982e2..c4acb241e 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -2000,9 +2000,9 @@ std::vector SALOMEDSImpl_Study::GetIORs() //============================================================================ bool SALOMEDSImpl_Study::addSO_Notification (const SALOMEDSImpl_SObject& theSObject) { - START_TIMING; + //START_TIMING; bool ret= _notifier->addSO_Notification(theSObject); - END_TIMING(100); + //END_TIMING(100); return ret; } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx index 3139b2fa0..b62004ecb 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyBuilder.cxx @@ -87,13 +87,13 @@ SALOMEDSImpl_SComponent SALOMEDSImpl_StudyBuilder::NewComponent(const std::strin DF_Label NL = L.NewChild(); - SALOMEDSImpl_AttributeComment::Set(NL, DataType); - SALOMEDSImpl_SComponent so = _study->GetSComponent (NL); if(_callbackOnAdd) _callbackOnAdd->OnAddSObject(so); _study->addSO_Notification(so); + SALOMEDSImpl_AttributeComment::Set(NL, DataType); + _doc->SetModified(true); return so; -- 2.39.2