From 2ea1a3f1f3622c6ad4c06d7d7e2a77db7b698489 Mon Sep 17 00:00:00 2001 From: mpa Date: Thu, 2 Feb 2017 10:43:51 +0300 Subject: [PATCH] code improvement --- src/KERNEL_PY/kernel/services.py | 7 ------- src/KERNEL_PY/kernel/studyedit.py | 3 --- src/KernelHelpers/KernelHelpersUseCases.cxx | 2 +- src/KernelHelpers/SALOME_KernelServices.cxx | 2 +- src/KernelHelpers/SALOME_KernelServices.hxx | 2 +- src/KernelHelpers/SALOME_StudyEditor.cxx | 6 +++--- src/KernelHelpers/Test/KernelHelpersUnitTests.cxx | 2 +- src/SALOMEDS/SALOMEDS_Client.cxx | 6 +++--- src/SALOMEDS/SALOMEDS_Driver_i.cxx | 4 ---- src/SALOMEDS/SALOMEDS_IParameters.cxx | 6 +++--- src/SALOMEDSImpl/SALOMEDSImpl_IParameters.cxx | 2 +- 11 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/KERNEL_PY/kernel/services.py b/src/KERNEL_PY/kernel/services.py index e7f3f33b2..b1b3db9c1 100644 --- a/src/KERNEL_PY/kernel/services.py +++ b/src/KERNEL_PY/kernel/services.py @@ -123,13 +123,6 @@ def getComponentList(): raise RuntimeError, "Can't accesss module catalog" return catalog.GetComponentList() -## Get a study -# \ingroup service -def getStudy(): - """Get a study""" - return salome.myStudy - - import SALOMEDS ## Get a study to create SALOME study. # \warning you should use instead the variable salome.myStudy. diff --git a/src/KERNEL_PY/kernel/studyedit.py b/src/KERNEL_PY/kernel/studyedit.py index be1941020..98aad6282 100644 --- a/src/KERNEL_PY/kernel/studyedit.py +++ b/src/KERNEL_PY/kernel/studyedit.py @@ -42,9 +42,6 @@ _DEFAULT_CONTAINER = "FactoryServer" # The codec to use for strings that are displayed in Salome study tree is Latin-1 ENCODING_FOR_SALOME_STUDY = "iso-8859-1" -def getStudy(): - return salome.myStudy - ## Return a \b StudyEditor instance to edit the study. # \ingroup studyedit def getStudyEditor(): diff --git a/src/KernelHelpers/KernelHelpersUseCases.cxx b/src/KernelHelpers/KernelHelpersUseCases.cxx index f408555f2..02341d11e 100644 --- a/src/KernelHelpers/KernelHelpersUseCases.cxx +++ b/src/KernelHelpers/KernelHelpersUseCases.cxx @@ -61,7 +61,7 @@ bool TEST_getLifeCycleCORBA() { } bool TEST_getStudy() { - SALOMEDS::Study_ptr myTestStudy = KERNEL::getStudy(); + SALOMEDS::Study_ptr myTestStudy = KERNEL::getStudyServant(); if ( CORBA::is_nil(myTestStudy) ) { return false; } diff --git a/src/KernelHelpers/SALOME_KernelServices.cxx b/src/KernelHelpers/SALOME_KernelServices.cxx index 4b3a07d70..71f945660 100644 --- a/src/KernelHelpers/SALOME_KernelServices.cxx +++ b/src/KernelHelpers/SALOME_KernelServices.cxx @@ -64,7 +64,7 @@ namespace KERNEL { * This returns a static reference to the SALOME study. The * study can be used to get informations about it. */ - SALOMEDS::Study_ptr getStudy() { + SALOMEDS::Study_ptr getStudyServant() { static SALOMEDS::Study_ptr aStudy; if(CORBA::is_nil(aStudy)){ SALOME_NamingService *aNamingService = getNamingService(); diff --git a/src/KernelHelpers/SALOME_KernelServices.hxx b/src/KernelHelpers/SALOME_KernelServices.hxx index 9496986b1..4353d44f1 100644 --- a/src/KernelHelpers/SALOME_KernelServices.hxx +++ b/src/KernelHelpers/SALOME_KernelServices.hxx @@ -41,7 +41,7 @@ namespace KERNEL { KERNELHELPERS_EXPORT SALOME_NamingService * getNamingService(); KERNELHELPERS_EXPORT SALOME_LifeCycleCORBA * getLifeCycleCORBA(); KERNELHELPERS_EXPORT SALOME::Session_ptr getSalomeSession(); - KERNELHELPERS_EXPORT SALOMEDS::Study_ptr getStudy(); + KERNELHELPERS_EXPORT SALOMEDS::Study_ptr getStudyServant(); KERNELHELPERS_EXPORT Engines::SalomeLauncher_ptr getSalomeLauncher(); KERNELHELPERS_EXPORT Engines::ResourcesManager_ptr getResourcesManager(); diff --git a/src/KernelHelpers/SALOME_StudyEditor.cxx b/src/KernelHelpers/SALOME_StudyEditor.cxx index 39199d4a9..908afb768 100644 --- a/src/KernelHelpers/SALOME_StudyEditor.cxx +++ b/src/KernelHelpers/SALOME_StudyEditor.cxx @@ -23,7 +23,7 @@ /** Canonic constructor. The object can't be used without a setStudy() */ SALOME_StudyEditor::SALOME_StudyEditor() { - _sbuilder = KERNEL::getStudy()->NewBuilder(); + _sbuilder = KERNEL::getStudyServant()->NewBuilder(); } SALOMEDS::SObject_ptr SALOME_StudyEditor::newObject(SALOMEDS::SObject_ptr parent) { @@ -31,7 +31,7 @@ SALOMEDS::SObject_ptr SALOME_StudyEditor::newObject(SALOMEDS::SObject_ptr parent } SALOMEDS::SObject_ptr SALOME_StudyEditor::findObject(const char * entry) { - SALOMEDS::SObject_var sobject = KERNEL::getStudy()->FindObjectID(entry); + SALOMEDS::SObject_var sobject = KERNEL::getStudyServant()->FindObjectID(entry); return sobject._retn(); } @@ -58,7 +58,7 @@ bool SALOME_StudyEditor::bindEngine(SALOMEDS::SComponent_var studyRoot, } SALOMEDS::SComponent_ptr SALOME_StudyEditor::findRoot(const char * moduleName) { - return KERNEL::getStudy()->FindComponent(moduleName); + return KERNEL::getStudyServant()->FindComponent(moduleName); } void SALOME_StudyEditor::setName(SALOMEDS::SObject_var sobject, const char * value) { diff --git a/src/KernelHelpers/Test/KernelHelpersUnitTests.cxx b/src/KernelHelpers/Test/KernelHelpersUnitTests.cxx index d34ef0332..7aa3bc436 100644 --- a/src/KernelHelpers/Test/KernelHelpersUnitTests.cxx +++ b/src/KernelHelpers/Test/KernelHelpersUnitTests.cxx @@ -78,7 +78,7 @@ void KernelHelpersUnitTests::TEST_getLifeCycleCORBA() { } void KernelHelpersUnitTests::TEST_getStudy() { - SALOMEDS::Study_ptr myTestStudy = KERNEL::getStudy(); + SALOMEDS::Study_ptr myTestStudy = KERNEL::getStudyServant(); CPPUNIT_ASSERT(!CORBA::is_nil(myTestStudy)); // One can use the study to store some general properties diff --git a/src/SALOMEDS/SALOMEDS_Client.cxx b/src/SALOMEDS/SALOMEDS_Client.cxx index 29f9ba1a2..12662b5f1 100644 --- a/src/SALOMEDS/SALOMEDS_Client.cxx +++ b/src/SALOMEDS/SALOMEDS_Client.cxx @@ -40,7 +40,7 @@ //============================================================================ static void DumpComponent(SALOMEDS::SObject_ptr SO, int offset) { SALOMEDS::SObject_var RefSO; - SALOMEDS::ChildIterator_var it = KERNEL::getStudy()->NewChildIterator(SO); + SALOMEDS::ChildIterator_var it = KERNEL::getStudyServant()->NewChildIterator(SO); for (; it->More();it->Next()){ SALOMEDS::SObject_var CSO= it->Value(); SALOMEDS::GenericAttribute_var anAttr; @@ -70,7 +70,7 @@ static void DumpStudy() { MESSAGE("Explore Study and Write name of each object if it exists"); char* name; - SALOMEDS::SComponentIterator_var itcomp = KERNEL::getStudy()->NewComponentIterator(); + SALOMEDS::SComponentIterator_var itcomp = KERNEL::getStudyServant()->NewComponentIterator(); int offset = 1; for (; itcomp->More(); itcomp->Next()) { SALOMEDS::SComponent_var SC = itcomp->Value(); @@ -90,7 +90,7 @@ static void Test() try { char* name; - SALOMEDS::Study_var myStudy = KERNEL::getStudy(); + SALOMEDS::Study_var myStudy = KERNEL::getStudyServant(); MESSAGE("Create Builder "); SALOMEDS::StudyBuilder_var StudyBuild = myStudy->NewBuilder(); diff --git a/src/SALOMEDS/SALOMEDS_Driver_i.cxx b/src/SALOMEDS/SALOMEDS_Driver_i.cxx index 04469f922..eecaaff4f 100644 --- a/src/SALOMEDS/SALOMEDS_Driver_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Driver_i.cxx @@ -322,10 +322,6 @@ SALOMEDSImpl_TMPFile* SALOMEDS_Driver_i::DumpPython(bool isPublished, bool& isValidScript, long& theStreamLength) { - SALOME_NamingService* namingService = KERNEL::getNamingService(); - CORBA::Object_var obj = namingService->Resolve("/Study"); - SALOMEDS::Study_var st = SALOMEDS::Study::_narrow(obj); - SALOMEDS::unlock(); Engines::TMPFile_var aStream; diff --git a/src/SALOMEDS/SALOMEDS_IParameters.cxx b/src/SALOMEDS/SALOMEDS_IParameters.cxx index 8439c8b0d..a7104f459 100644 --- a/src/SALOMEDS/SALOMEDS_IParameters.cxx +++ b/src/SALOMEDS/SALOMEDS_IParameters.cxx @@ -264,7 +264,7 @@ std::string SALOMEDS_IParameters::decodeEntry(const std::string& entry) std::string compName(entry, 0, pos), compID, tail(entry, pos+1, entry.length()-1); if(_compNames.find(compName) == _compNames.end()) { - _PTR(SObject) so = ClientFactory::Study(KERNEL::getStudy())->FindComponent(compName); + _PTR(SObject) so = ClientFactory::Study(KERNEL::getStudyServant())->FindComponent(compName); if(!so) return entry; compID = so->GetID(); _compNames[compName] = compID; @@ -283,7 +283,7 @@ void SALOMEDS_IParameters::setDumpPython(const std::string& theID) if(theID == "") anID = getDefaultVisualComponent(); else anID = theID; - _PTR(AttributeParameter) ap = ClientFactory::Study(KERNEL::getStudy())->GetCommonParameters(anID, 0); + _PTR(AttributeParameter) ap = ClientFactory::Study(KERNEL::getStudyServant())->GetCommonParameters(anID, 0); ap->SetBool(_AP_DUMP_PYTHON_, !isDumpPython(theID)); } @@ -293,7 +293,7 @@ bool SALOMEDS_IParameters::isDumpPython(const std::string& theID) if(theID == "") anID = getDefaultVisualComponent(); else anID = theID; - _PTR(AttributeParameter) ap = ClientFactory::Study(KERNEL::getStudy())->GetCommonParameters(anID, 0); + _PTR(AttributeParameter) ap = ClientFactory::Study(KERNEL::getStudyServant())->GetCommonParameters(anID, 0); if(!ap) return false; if(!ap->IsSet(_AP_DUMP_PYTHON_, PT_BOOLEAN)) return false; return (bool)ap->GetBool(_AP_DUMP_PYTHON_); diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.cxx index 749c112bb..ba8d24376 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_IParameters.cxx @@ -341,7 +341,7 @@ std::string SALOMEDSImpl_IParameters::getDefaultScript(SALOMEDSImpl_Study* study dump += shift +"import iparameters\n"; - dump += shift + "ipar = iparameters.IParameters(theStudy.GetModuleParameters(\""+anID+"\", \""+moduleName+"\", 1))\n\n"; + dump += shift + "ipar = iparameters.IParameters(salome.myStudy.GetModuleParameters(\""+anID+"\", \""+moduleName+"\", 1))\n\n"; std::vector v = ip.getProperties(); if(v.size() > 0) { -- 2.39.2