From dfaf0a133266bcb9bdac90f65c9238daeb64bfe5 Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 25 Nov 2009 08:46:56 +0000 Subject: [PATCH] GetParameters() is implemented: returns list of parameter names separated by comma, that the object depends on --- idl/SALOME_Notebook.idl | 3 +++ src/Notebook/SALOME_Notebook.cxx | 31 +++++++++++++++++++++++++++++-- src/Notebook/SALOME_Notebook.hxx | 2 ++ 3 files changed, 34 insertions(+), 2 deletions(-) diff --git a/idl/SALOME_Notebook.idl b/idl/SALOME_Notebook.idl index 199d2a430..647b6dc72 100644 --- a/idl/SALOME_Notebook.idl +++ b/idl/SALOME_Notebook.idl @@ -216,6 +216,9 @@ module SALOME //! Dump of Notebook internal data structure for debug purposes string Dump(); + + //! Return string containing information about parameters used by object with given component and entry + string GetParameters( in string theComponent, in string theEntry ); }; }; diff --git a/src/Notebook/SALOME_Notebook.cxx b/src/Notebook/SALOME_Notebook.cxx index e9eb7ee62..8f8c08f55 100644 --- a/src/Notebook/SALOME_Notebook.cxx +++ b/src/Notebook/SALOME_Notebook.cxx @@ -561,12 +561,17 @@ void SALOME_Notebook::ClearDependencies( const std::string& theObjKey, SALOME::D std::string SALOME_Notebook::GetKey( SALOME::ParameterizedObject_ptr theObj ) { - return arg( "%1#%2", theObj->GetComponent(), theObj->GetEntry() ); + return GetKey( theObj->GetComponent(), theObj->GetEntry() ); +} + +std::string SALOME_Notebook::GetKey( const std::string& theComponent, const std::string& theEntry ) +{ + return arg( "%1#%2", theComponent, theEntry ); } std::string SALOME_Notebook::GetKey( const std::string& theParamName ) { - return arg( "%1#%2", PARAM_COMPONENT, theParamName ); + return GetKey( PARAM_COMPONENT, theParamName ); } std::list SALOME_Notebook::GetAllDependingOn( const std::string& theKey ) @@ -913,3 +918,25 @@ void SALOME_Notebook::throwError( const std::string& theErrorMsg ) anError.Reason = CORBA::string_dup( theErrorMsg.c_str() ); throw anError; } + +char* SALOME_Notebook::GetParameters( const char* theComponent, const char* theEntry ) +{ + std::string aRes, aKey = GetKey( theComponent, theEntry ), aComponent, aName; + std::map< std::string, std::list >::const_iterator it = myDependencies.find( aKey ); + if( it!=myDependencies.end() ) + { + std::list::const_iterator dit = it->second.begin(), dlast = it->second.end(); + for( ; dit!=dlast; dit++ ) + { + aComponent = GetComponent( *dit, aName ); + if( aComponent==PARAM_COMPONENT ) + { + if( aRes.length() > 0 ) + aRes += ", "; + aRes += aName; + } + } + } + + return CORBA::string_dup( aRes.c_str() ); +} diff --git a/src/Notebook/SALOME_Notebook.hxx b/src/Notebook/SALOME_Notebook.hxx index 0213650c2..8feeba931 100644 --- a/src/Notebook/SALOME_Notebook.hxx +++ b/src/Notebook/SALOME_Notebook.hxx @@ -65,6 +65,7 @@ public: virtual CORBA::Boolean Load( const char* theFileName ); virtual char* DumpPython(); virtual char* Dump(); + virtual char* GetParameters( const char* theComponent, const char* theEntry ); SALOME_Parameter* GetParameterPtr( const char* theParamName ) const; void UpdateAnonymous( const std::string& theOldName, const std::string& theNewName ); @@ -83,6 +84,7 @@ protected: private: std::string GetKey( SALOME::ParameterizedObject_ptr theObj ); + std::string GetKey( const std::string& theComponent, const std::string& theParamName ); std::string GetKey( const std::string& theParamName ); std::list GetAllDependingOn( const std::string& theKey ); SALOME::ParameterizedObject_ptr FindObject( const std::string& theKey ); -- 2.39.2