From 838d68e1231ee75bcc08dbd3bf1a83f9ff61733a Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 19 Nov 2009 05:44:40 +0000 Subject: [PATCH] Base implementation of Notebook --- idl/SALOMEDS.idl | 10 ++++ idl/SALOME_Component.idl | 8 ++- idl/SALOME_Notebook.idl | 74 +++++++++++++++++++++++----- src/Container/Component_i.cxx | 9 ++++ src/Container/SALOME_Component_i.hxx | 2 + src/Makefile.am | 4 +- src/SALOMEDS/Makefile.am | 2 + src/SALOMEDS/SALOMEDS_Study_i.cxx | 32 ++++++++++++ src/SALOMEDS/SALOMEDS_Study_i.hxx | 7 +++ 9 files changed, 132 insertions(+), 16 deletions(-) diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index 98899e4d3..6f9710864 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -32,6 +32,7 @@ #include "SALOME_Exception.idl" #include "SALOME_GenericObj.idl" +#include "SALOME_Notebook.idl" /*! \brief This package contains the interfaces used for creation, management @@ -403,6 +404,15 @@ during each working session. /*! \brief Get the list of IDs of the Study's lockers. */ ListOfStrings GetLockerID(); + +/*! \brief Access to notebook instance +*/ + SALOME::Notebook GetNotebook(); + +/*! \brief Find an object by its component and entry (usually internal entry not available on high level) + even if object is not published yet in study +*/ + SALOME::GenericObj FindObjectByInternalEntry( in string theComponent, in string theEntry ); }; //========================================================================== diff --git a/idl/SALOME_Component.idl b/idl/SALOME_Component.idl index fc555dc34..238c39f31 100644 --- a/idl/SALOME_Component.idl +++ b/idl/SALOME_Component.idl @@ -27,6 +27,7 @@ #define _SALOME_COMPONENT_IDL_ #include "SALOMEDS.idl" +#include "SALOME_GenericObj.idl" #include "SALOME_Exception.idl" #include "SALOME_PyNode.idl" @@ -417,6 +418,12 @@ module Engines \return an information about the given object. */ string getObjectInfo(in long studyId, in string entry); + + //! Find object by its internal entry (OCAF or other) even it is not published in the study + /*! + \param theEntry object entry + */ + SALOME::GenericObj FindObjectByInternalEntry( in string theEntry ); } ; //! A block of binary data used for file transfer. The maximum size of the block is defined on server side. @@ -465,7 +472,6 @@ module Engines \param block a data block to copy into the file identified by fileId */ void putBlock(in long fileId, in fileBlock block); - }; //! A file managed by a Salome_file. diff --git a/idl/SALOME_Notebook.idl b/idl/SALOME_Notebook.idl index 6c20aef2c..7181b7218 100644 --- a/idl/SALOME_Notebook.idl +++ b/idl/SALOME_Notebook.idl @@ -30,7 +30,6 @@ #ifndef _NOTEBOOK_IDL_ #define _NOTEBOOK_IDL_ -#include "SALOME_Exception.idl" #include "SALOME_GenericObj.idl" /*! \brief @@ -42,39 +41,88 @@ module SALOME //! This interface describes parameterized object interface ParameterizedObject : GenericObj { - //return object's entry + //! return object's entry string GetEntry(); - //validity status + //! return object's component + string GetComponent(); + + //! validity status boolean IsValid(); - //update management - void SetToUpdate(); + //! update management void Update(); }; //! This enumeration describes data types supported by notebook functionality - enum ParamType { TBoolean, TInteger, TReal, TExpression, TString }; + enum ParamType { TUnknown, TBoolean, TInteger, TReal, TString }; + + //! This interface describes parameter object interface Parameter : ParameterizedObject { - void SetValue( in string expr ); + //! change expression of the parameter + void SetExpr( in string expr ); + + //! change value of the parameter + void SetReal( in double value ); + + //! return type of parameter ParamType GetType(); - string AsString() raises(SALOME_Exception); - long AsInteger() raises(SALOME_Exception); - double AsDouble() raises(SALOME_Exception); - boolean AsBoolean() raises(SALOME_Exception); + //! convert parameter into string + string AsString(); + + //! convert parameter into integer + long AsInteger(); + + //! convert parameter into real + double AsReal(); + + //! convert parameter into boolean + boolean AsBoolean(); }; + + //! This interface describes parameters container: Notebook interface Notebook : GenericObj { //dependency management - void AddDependency( in ParameterizedObject obj, in ParameterizedObject dep ); + + //! add new dependency between objects + boolean AddDependency( in ParameterizedObject obj, in ParameterizedObject dep ); + + //! remove dependency between objects void RemoveDependency( in ParameterizedObject obj, in ParameterizedObject dep ); + + //! remove all dependencies of the object void ClearDependencies( in ParameterizedObject obj ); - void Update( in ParameterizedObject obj ); + + //! set internal flags of update: it means that this object and all objects depending on it will be updated + void SetToUpdate( in ParameterizedObject obj ); + + //! update all objects marked as "need to update" + void Update(); + + + + //parameters management + + //! add new parameter (expression) into notebook + boolean AddExpr( in string expr ); + + //! add new parameter (named expression) into notebook + boolean AddNameExpr( in string name, in string expr ); + + //! add new parameter (value) into notebook + boolean AddValue( in string name, in double value ); + + //! remove parameter from notebook + void Remove( in string name ); + + //! access to parameter from notebook + Parameter Param( in string name ); }; }; diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index 66d3cd22a..e6c194b59 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -556,6 +556,15 @@ CORBA::Long Engines_Component_i::CpuUsed_impl() return cpu ; } +//============================================================================= +/*! + * CORBA method: + */ +//============================================================================= +SALOME::GenericObj_ptr Engines_Component_i::FindObjectByInternalEntry( const char* theEntry ) +{ + return SALOME::GenericObj_ptr(); +} //============================================================================= /*! diff --git a/src/Container/SALOME_Component_i.hxx b/src/Container/SALOME_Component_i.hxx index 652f637a7..470c607ae 100644 --- a/src/Container/SALOME_Component_i.hxx +++ b/src/Container/SALOME_Component_i.hxx @@ -114,6 +114,8 @@ public: // Object information virtual bool hasObjectInfo() { return false; } virtual char* getObjectInfo(CORBA::Long studyId, const char* entry) { return CORBA::string_dup(""); } + + SALOME::GenericObj_ptr FindObjectByInternalEntry( const char* theEntry ); // --- local C++ methods diff --git a/src/Makefile.am b/src/Makefile.am index f9f92b6e5..ba83ba54b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -47,6 +47,7 @@ SUBDIR_CORBA = \ Launcher \ LifeCycleCORBA \ LifeCycleCORBA_SWIG \ + Notebook \ SALOMEDSClient \ TOOLSDS \ SALOMEDSImpl \ @@ -54,8 +55,7 @@ SUBDIR_CORBA = \ ModuleGenerator \ Communication \ Communication_SWIG \ - DSC \ - Notebook + DSC SUBDIR_CPPUNIT_BASE= \ Basics/Test \ diff --git a/src/SALOMEDS/Makefile.am b/src/SALOMEDS/Makefile.am index 8ee8a7fa0..e10fa9095 100644 --- a/src/SALOMEDS/Makefile.am +++ b/src/SALOMEDS/Makefile.am @@ -69,6 +69,7 @@ COMMON_CPPFLAGS=\ -I$(srcdir)/../GenericObj \ -I$(srcdir)/../SALOMEDSClient \ -I$(srcdir)/../LifeCycleCORBA \ + -I$(srcdir)/../Notebook \ -I$(top_builddir)/idl \ @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ @@ -84,6 +85,7 @@ COMMON_LIBS =\ ../SALOMEDSImpl/libSalomeDSImpl.la \ ../GenericObj/libSalomeGenericObj.la \ ../LifeCycleCORBA/libSalomeLifeCycleCORBA.la \ + ../Notebook/libSalomeNotebook.la \ $(top_builddir)/idl/libSalomeIDLKernel.la\ @HDF5_LIBS@ diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 8a01c0d95..37e85b706 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -32,6 +32,7 @@ #include "SALOMEDS_AttributeParameter_i.hxx" #include "SALOMEDS_ChildIterator_i.hxx" #include "SALOMEDS_Driver_i.hxx" +#include "SALOMEDS_StudyBuilder.hxx" #include "SALOMEDS.hxx" #include "SALOMEDSImpl_SObject.hxx" @@ -929,3 +930,34 @@ CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::L isLocal = (strcmp(theHostname, Kernel_Utils::GetHostname().c_str()) == 0 && pid == thePID)?1:0; return reinterpret_cast(_impl); } + +SALOME::GenericObj_ptr SALOMEDS_Study_i::FindObjectByInternalEntry( const char* theComponent, const char* theEntry ) +{ + SALOME::GenericObj_ptr aRes; + SALOMEDS::StudyBuilder_ptr aBuilder = NewBuilder(); + SALOMEDS::SComponent_ptr aSComponent = FindComponent( theComponent ); + + if( !CORBA::is_nil( aSComponent ) ) + { + SALOMEDS::GenericAttribute_ptr anAttr; + if( aBuilder->FindAttribute( aSComponent, anAttr, "AttributeIOR" ) ) + { + SALOMEDS::AttributeIOR_ptr anAttrIOR = SALOMEDS::AttributeIOR::_narrow( anAttr ); + CORBA::Object_var aCompObj = _orb->string_to_object( anAttrIOR->Value() ); + Engines::Component_var aComponent = Engines::Component::_narrow( aCompObj ); + aRes = aComponent->FindObjectByInternalEntry( theEntry ); + } + } + return aRes; +} + +SALOME::Notebook_ptr SALOMEDS_Study_i::GetNotebook() +{ + if( CORBA::is_nil( myNotebook ) ) + { + SALOME_Notebook* aNb = new SALOME_Notebook( _this() ); + myNotebook = aNb->_this(); + } + + return myNotebook._retn(); +} diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index 49b971a7d..b2b87933a 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -32,6 +32,7 @@ // IDL headers #include #include CORBA_SERVER_HEADER(SALOME_GenericObj) +#include CORBA_SERVER_HEADER(SALOME_Notebook) #include CORBA_SERVER_HEADER(SALOMEDS) #include @@ -44,6 +45,7 @@ #include "SALOMEDSImpl_Study.hxx" #include "SALOMEDSImpl_AttributeIOR.hxx" +#include "SALOME_Notebook.hxx" class Standard_EXPORT SALOMEDS_Study_i: public POA_SALOMEDS::Study { @@ -52,6 +54,7 @@ private: SALOMEDSImpl_Study* _impl; SALOMEDS_StudyBuilder_i* _builder; static std::map _mapOfStudies; + SALOME::Notebook_var myNotebook; public: @@ -305,5 +308,9 @@ public: virtual SALOMEDSImpl_Study* GetImpl() { return _impl; } virtual CORBA::LongLong GetLocalImpl(const char* theHostname, CORBA::Long thePID, CORBA::Boolean& isLocal); + + virtual SALOME::GenericObj_ptr FindObjectByInternalEntry( const char* theComponent, const char* theEntry ); + + virtual SALOME::Notebook_ptr GetNotebook(); }; #endif -- 2.39.2