From fabe3f80a47bb1990820922b885e3eb20a34f673 Mon Sep 17 00:00:00 2001 From: asl Date: Fri, 20 Nov 2009 07:51:53 +0000 Subject: [PATCH] Implementation of update for objects --- idl/SALOME_Component.idl | 2 +- idl/SALOME_Notebook.idl | 4 +- src/Notebook/Makefile.am | 4 +- src/Notebook/SALOME_Notebook.cxx | 12 +++- src/Notebook/SALOME_Parameter.cxx | 8 +-- src/Notebook/SALOME_Parameter.hxx | 9 +-- src/Notebook/SALOME_ParameterizedObject.cxx | 66 --------------------- src/Notebook/SALOME_ParameterizedObject.hxx | 63 -------------------- 8 files changed, 23 insertions(+), 145 deletions(-) delete mode 100644 src/Notebook/SALOME_ParameterizedObject.cxx delete mode 100644 src/Notebook/SALOME_ParameterizedObject.hxx diff --git a/idl/SALOME_Component.idl b/idl/SALOME_Component.idl index 238c39f31..d3484d545 100644 --- a/idl/SALOME_Component.idl +++ b/idl/SALOME_Component.idl @@ -423,7 +423,7 @@ module Engines /*! \param theEntry object entry */ - SALOME::GenericObj FindObjectByInternalEntry( in string theEntry ); + SALOME::GenericObj FindObjectByInternalEntry( in long studyId, in string theEntry ); } ; //! A block of binary data used for file transfer. The maximum size of the block is defined on server side. diff --git a/idl/SALOME_Notebook.idl b/idl/SALOME_Notebook.idl index 7181b7218..135c0c5c8 100644 --- a/idl/SALOME_Notebook.idl +++ b/idl/SALOME_Notebook.idl @@ -38,6 +38,8 @@ */ module SALOME { + interface Notebook; + //! This interface describes parameterized object interface ParameterizedObject : GenericObj { @@ -51,7 +53,7 @@ module SALOME boolean IsValid(); //! update management - void Update(); + void Update( in Notebook nb ); }; //! This enumeration describes data types supported by notebook functionality diff --git a/src/Notebook/Makefile.am b/src/Notebook/Makefile.am index 8d002e0e0..36b4a145b 100644 --- a/src/Notebook/Makefile.am +++ b/src/Notebook/Makefile.am @@ -31,7 +31,7 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am # =============================================================== # # header files -salomeinclude_HEADERS = SALOME_ParameterizedObject.hxx \ +salomeinclude_HEADERS = \ SALOME_Parameter.hxx \ SALOME_Notebook.hxx \ SALOME_Eval.hxx \ @@ -70,7 +70,7 @@ COMMON_LIBS = # =============================================================== # lib_LTLIBRARIES = libSalomeNotebook.la -libSalomeNotebook_la_SOURCES = SALOME_ParameterizedObject.cxx \ +libSalomeNotebook_la_SOURCES = \ SALOME_Parameter.cxx \ SALOME_Notebook.cxx \ SALOME_EvalExpr.cxx \ diff --git a/src/Notebook/SALOME_Notebook.cxx b/src/Notebook/SALOME_Notebook.cxx index f050b5119..ddd36aa80 100644 --- a/src/Notebook/SALOME_Notebook.cxx +++ b/src/Notebook/SALOME_Notebook.cxx @@ -100,17 +100,18 @@ void SALOME_Notebook::SetToUpdate( SALOME::ParameterizedObject_ptr theObj ) void SALOME_Notebook::Update() { - //printf( "Update\n" ); + printf( "Update\n" ); std::list< KeyHelper > aPostponedUpdate; std::list::const_iterator it = myToUpdate.begin(), last = myToUpdate.end(); for( ; it!=last; it++ ) { std::string aKey = (*it).key(); + printf( "key = %s\n", aKey.c_str() ); SALOME::ParameterizedObject_ptr anObj = FindObject( aKey ); if( CORBA::is_nil( anObj ) ) aPostponedUpdate.push_back( *it ); else - anObj->Update(); + anObj->Update( _this() ); } myToUpdate = aPostponedUpdate; } @@ -141,7 +142,12 @@ void SALOME_Notebook::Remove( const char* theParamName ) SALOME::Parameter_ptr SALOME_Notebook::Param( const char* theParamName ) { //printf( "Param, name = %s\n", theParamName ); - return ParamPtr( theParamName )->_this(); + SALOME_Parameter* aParam = ParamPtr( theParamName ); + //printf( "Result = %i\n", (int)aParam ); + SALOME::Parameter_var aRes; + if( aParam ) + aRes = aParam->_this(); + return aRes._retn(); } SALOME_Parameter* SALOME_Notebook::ParamPtr( const char* theParamName ) const diff --git a/src/Notebook/SALOME_Parameter.cxx b/src/Notebook/SALOME_Parameter.cxx index 607101a52..41a5bf2e7 100644 --- a/src/Notebook/SALOME_Parameter.cxx +++ b/src/Notebook/SALOME_Parameter.cxx @@ -38,13 +38,13 @@ SALOME_Parameter::SALOME_Parameter( SALOME_Notebook* theNotebook, const std::str SALOME_Parameter::SALOME_Parameter( SALOME_Notebook* theNotebook, const std::string& theName, const std::string& theExpr ) : myNotebook( theNotebook ), myName( theName ), myExpr( theExpr ), myIsAnonimous( false ), myIsCalculable( true ) { - Update(); + Update( SALOME::Notebook_ptr() ); } SALOME_Parameter::SALOME_Parameter( SALOME_Notebook* theNotebook, const std::string& theExpr ) : myNotebook( theNotebook ), myName( theExpr ), myExpr( theExpr ), myIsAnonimous( true ), myIsCalculable( true ) { - Update(); + Update( SALOME::Notebook_ptr() ); } SALOME_Parameter::~SALOME_Parameter() @@ -66,7 +66,7 @@ CORBA::Boolean SALOME_Parameter::IsValid() return myResult.isValid(); } -void SALOME_Parameter::Update() +void SALOME_Parameter::Update( SALOME::Notebook_ptr /*theNotebook*/ ) { //printf( "Update of %s\n", GetEntry() ); if( myIsCalculable ) @@ -105,7 +105,6 @@ void SALOME_Parameter::SetExpr( const char* theExpr ) { myExpr.setExpression( theExpr ); myIsCalculable = true; - Update(); myNotebook->SetToUpdate( _this() ); } } @@ -119,7 +118,6 @@ void SALOME_Parameter::SetReal( CORBA::Double theValue ) { myResult = theValue; myIsCalculable = false; - Update(); myNotebook->SetToUpdate( _this() ); } } diff --git a/src/Notebook/SALOME_Parameter.hxx b/src/Notebook/SALOME_Parameter.hxx index 06ba90e36..6defd3f3d 100644 --- a/src/Notebook/SALOME_Parameter.hxx +++ b/src/Notebook/SALOME_Parameter.hxx @@ -26,16 +26,17 @@ #ifndef __SALOME_PARAMETER_H__ #define __SALOME_PARAMETER_H__ -#include +#include #include - +#include CORBA_SERVER_HEADER(SALOME_Notebook) +#include #include class SALOME_Notebook; const std::string PARAM_COMPONENT = ""; -class SALOME_Parameter : public virtual POA_SALOME::Parameter, public virtual SALOME_ParameterizedObject +class SALOME_Parameter : public virtual POA_SALOME::Parameter, public virtual SALOME::GenericObj_i { public: //! standard constructor @@ -52,7 +53,7 @@ public: virtual CORBA::Boolean IsValid(); - virtual void Update(); + virtual void Update( SALOME::Notebook_ptr theNotebook ); virtual void SetExpr( const char* theExpr ); diff --git a/src/Notebook/SALOME_ParameterizedObject.cxx b/src/Notebook/SALOME_ParameterizedObject.cxx deleted file mode 100644 index 2a54b86f6..000000000 --- a/src/Notebook/SALOME_ParameterizedObject.cxx +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File : SALOME_ParameterizedObject.cxx -// Author : Alexandre SOLOVYOV -// Module : SALOME -// - -#include -#include - -SALOME_ParameterizedObject::SALOME_ParameterizedObject() -: myIsValid( true ), myToUpdate( false ) -{ -} - -SALOME_ParameterizedObject::~SALOME_ParameterizedObject() -{ -} - -CORBA::Boolean SALOME_ParameterizedObject::IsValid() -{ - return myIsValid; -} - -void SALOME_ParameterizedObject::SetToUpdate() -{ - myToUpdate = true; -} - -void SALOME_ParameterizedObject::Update() -{ -} - -void SALOME_ParameterizedObject::SetIsValid( bool is_valid ) -{ - myIsValid = is_valid; -} - -bool SALOME_ParameterizedObject::IsToUpdate() -{ - return myToUpdate; -} - -void SALOME_ParameterizedObject::ClearToUpdate() -{ - myToUpdate = false; -} diff --git a/src/Notebook/SALOME_ParameterizedObject.hxx b/src/Notebook/SALOME_ParameterizedObject.hxx deleted file mode 100644 index 163fd8c7a..000000000 --- a/src/Notebook/SALOME_ParameterizedObject.hxx +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File : SALOME_ParameterizedObject.hxx -// Author : Alexandre SOLOVYOV -// Module : SALOME -// -#ifndef __SALOME_PARAMETERIZED_OBJECT_H__ -#define __SALOME_PARAMETERIZED_OBJECT_H__ - -#include -#include CORBA_SERVER_HEADER(SALOME_Notebook) -#include -#include - -class SALOME_ParameterizedObject: public virtual POA_SALOME::ParameterizedObject, public virtual SALOME::GenericObj_i -{ -public: - //! standard constructor - SALOME_ParameterizedObject(); - - //! standard destructor - virtual ~SALOME_ParameterizedObject(); - - - //return object's entry - virtual char* GetEntry() = 0; - - //validity status - virtual CORBA::Boolean IsValid(); - - //update management - virtual void SetToUpdate(); - virtual void Update(); - -protected: - void SetIsValid( bool is_valid ); - bool IsToUpdate(); - void ClearToUpdate(); - -private: - bool myIsValid, myToUpdate; -}; - -#endif -- 2.39.2