From: asl Date: Wed, 11 Nov 2009 07:54:31 +0000 (+0000) Subject: Notebook initial version X-Git-Tag: PHASE_17_Part1_V1~53 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6401d6733647f3738e88da204a6f69edaefd7014;p=modules%2Fkernel.git Notebook initial version --- diff --git a/configure.ac b/configure.ac index f6439a26b..27b246832 100644 --- a/configure.ac +++ b/configure.ac @@ -559,6 +559,7 @@ AC_OUTPUT([ \ src/MPIContainer/Makefile \ src/NamingService/Makefile \ src/NamingService/Test/Makefile \ + src/Notebook/Makefile \ src/Notification/Makefile \ src/NOTIFICATION_SWIG/Makefile \ src/Registry/Makefile \ diff --git a/idl/Makefile.am b/idl/Makefile.am index 744d555d5..580ea93e1 100644 --- a/idl/Makefile.am +++ b/idl/Makefile.am @@ -49,7 +49,8 @@ BASEIDL_FILES = \ SALOME_PyNode.idl \ Palm_Ports.idl \ SALOME_PACOExtension.idl \ - SALOME_ParamPorts.idl + SALOME_ParamPorts.idl \ + SALOME_Notebook.idl MPIIDL_FILES = \ SALOME_MPIObject.idl \ @@ -100,7 +101,8 @@ BASEIDL_SOURCES =\ Calcium_PortsSK.cc \ Palm_PortsSK.cc \ SALOME_PACOExtensionSK.cc \ - SALOME_ParamPortsSK.cc + SALOME_ParamPortsSK.cc \ + SALOME_NotebookSK.cc DYNIDL_SRCS = \ SALOME_PortsDynSK.cc Calcium_PortsDynSK.cc SALOME_ContainerManagerDynSK.cc \ @@ -108,7 +110,8 @@ DYNIDL_SRCS = \ SALOMEDSDynSK.cc SALOME_SessionDynSK.cc SALOME_RessourcesCatalogDynSK.cc \ DSC_EnginesDynSK.cc SALOME_ComponentDynSK.cc SALOME_GenericObjDynSK.cc \ Palm_PortsDynSK.cc SALOME_ExceptionDynSK.cc SALOMEDS_AttributesDynSK.cc \ - LoggerDynSK.cc SALOME_PACOExtensionDynSK.cc SALOME_ParamPortsDynSK.cc SALOME_PyNodeDynSK.cc + LoggerDynSK.cc SALOME_PACOExtensionDynSK.cc SALOME_ParamPortsDynSK.cc SALOME_PyNodeDynSK.cc \ + SALOME_NotebookDynSK.cc MPIIDL_SOURCES = \ SALOME_MPIObjectSK.cc \ diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index 4325a3875..98899e4d3 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -403,142 +403,6 @@ during each working session. /*! \brief Get the list of IDs of the Study's lockers. */ ListOfStrings GetLockerID(); - -/*! \brief Create real variable with Name theVarName and value theValue - - (or set if variable value into theValue already exists) - \param theVarName is a name of the variable - \param theVarName is a value of the variable. -*/ - void SetReal( in string theVarName, in double theValue ); - -/*! \brief Create integer variable with Name theVarName and value theValue - - (or set if variable value into theValue already exists) - \param theVarName is a name of the variable - \param theVarName is a value of the variable. -*/ - void SetInteger( in string theVarName, in long theValue ); -/*! \brief Create boolean variable with Name theVarName and value theValue - - (or set if variable value into theValue already exists) - \param theVarName is a name of the variable - \param theVarName is a value of the variable. -*/ - void SetBoolean( in string theVarName, in boolean theValue ); - -/*! \brief Create string variable with Name theVarName and value theValue - - (or set if variable value into theValue already exists) - \param theVarName is a name of the variable - \param theVarName is a value of the variable. -*/ - void SetString( in string theVarName, in string theValue ); - -/*! \brief Set current value as double for string variable -*/ - void SetStringAsDouble( in string theVarName, in double theValue ); - -/*! \brief Get value of a real variable - - \param theVarName is a name of the variable. -*/ - double GetReal( in string theVarName ); - -/*! \brief Get value of an integer variable - - \param theVarName is a name of the variable. -*/ - long GetInteger( in string theVarName ); - -/*! \brief Get value of a boolean variable - - \param theVarName is a name of the variable. -*/ - boolean GetBoolean( in string theVarName ); - -/*! \brief Get value of a string variable - - \param theVarName is a name of the variable. -*/ - string GetString( in string theVarName ); - - -/*! \brief Indicate if a variable is real - - Return true if variable is real otherwise return false. - \param theVarName is a name of the variable. -*/ - boolean IsReal( in string theVarName ); - -/*! \brief Indicate if a variable is integer - - Return true if variable is integer otherwise return false. - \param theVarName is a name of the variable. -*/ - boolean IsInteger( in string theVarName ); - -/*! \brief Indicate if a variable is boolean - - Return true if variable is boolean otherwise return false. - \param theVarName is a name of the variable. -*/ - boolean IsBoolean( in string theVarName ); - -/*! \brief Indicate if a variable is string - - Return true if variable is string otherwise return false. - \param theVarName is a name of the variable. -*/ - boolean IsString( in string theVarName ); - -/*! \brief Indicate if a variable exists in the study - - Return true if variable exists in the study, - otherwise return false. - \param theVarName is a name of the variable. -*/ - boolean IsVariable( in string theVarName ); - -/*! \brief Get names of all variables from the study. -*/ - ListOfStrings GetVariableNames(); - -/*! \brief Remove a variable - - Remove variable with the specified name from the study with substitution of its value. - - \param theVarName Name of the variable. - \return Status of operation. -*/ - boolean RemoveVariable( in string theVarName ); - -/*! \brief Rename a variable - - Rename variable with the specified name within the study. - - \param theVarName Name of the variable. - \param theNewVarName New name for the variable. - \return Status of operation. -*/ - boolean RenameVariable( in string theVarName, in string theNewVarName ); - -/*! \brief Indicate whether variable is used - - Check that variable is used in the study. - - \param theVarName Name of the variable. - \return Variable usage. -*/ - boolean IsVariableUsed( in string theVarName ); - -/*! \brief Parse variables used for object creation - - \param string with variables, separated by special symbol. - \return Variables list. -*/ - ListOfListOfStrings ParseVariables( in string theVars ); - }; //========================================================================== diff --git a/idl/SALOME_Notebook.idl b/idl/SALOME_Notebook.idl new file mode 100644 index 000000000..6c20aef2c --- /dev/null +++ b/idl/SALOME_Notebook.idl @@ -0,0 +1,81 @@ +// 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 : Notebook.idl +// Author : Alexandre SOLOVYOV +// $Header$ +// +/*! \file Notebook.idl \brief This file contains a set of interfaces used for notebook + (model parametrization) functionality +*/ + +#ifndef _NOTEBOOK_IDL_ +#define _NOTEBOOK_IDL_ + +#include "SALOME_Exception.idl" +#include "SALOME_GenericObj.idl" + +/*! \brief + This package contains the interfaces used for notebook + (model parametrization) functionality +*/ +module SALOME +{ + //! This interface describes parameterized object + interface ParameterizedObject : GenericObj + { + //return object's entry + string GetEntry(); + + //validity status + boolean IsValid(); + + //update management + void SetToUpdate(); + void Update(); + }; + + //! This enumeration describes data types supported by notebook functionality + enum ParamType { TBoolean, TInteger, TReal, TExpression, TString }; + + //! This interface describes parameter object + interface Parameter : ParameterizedObject + { + void SetValue( in string expr ); + ParamType GetType(); + + string AsString() raises(SALOME_Exception); + long AsInteger() raises(SALOME_Exception); + double AsDouble() raises(SALOME_Exception); + boolean AsBoolean() raises(SALOME_Exception); + }; + + interface Notebook : GenericObj + { + //dependency management + void AddDependency( in ParameterizedObject obj, in ParameterizedObject dep ); + void RemoveDependency( in ParameterizedObject obj, in ParameterizedObject dep ); + void ClearDependencies( in ParameterizedObject obj ); + void Update( in ParameterizedObject obj ); + }; +}; + +#endif diff --git a/src/Makefile.am b/src/Makefile.am index 44deb4332..feed604c0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -54,7 +54,8 @@ SUBDIR_CORBA = \ ModuleGenerator \ Communication \ Communication_SWIG \ - DSC + DSC \ + Notebook SUBDIR_CPPUNIT_BASE= \ Basics/Test \ diff --git a/src/Notebook/Makefile.am b/src/Notebook/Makefile.am new file mode 100644 index 000000000..bc521c199 --- /dev/null +++ b/src/Notebook/Makefile.am @@ -0,0 +1,75 @@ +# 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 : Makefile.am +# Author : Alexandre SOLOVYOV +# Module : KERNEL +# +include $(top_srcdir)/salome_adm/unix/make_common_starter.am + +# +# =============================================================== +# Files to be installed +# =============================================================== +# +# header files +salomeinclude_HEADERS = SALOME_ParameterizedObject.hxx \ + SALOME_Parameter.hxx \ + SALOME_Notebook.hxx \ + SALOME_IndexMap.hxx + +# Scripts to be installed +dist_salomescript_PYTHON= + +# +# =============================================================== +# Local definitions +# =============================================================== +# + +# This local variable defines the list of CPPFLAGS common to all target in this package. +COMMON_CPPFLAGS = \ + -I$(srcdir)/../GenericObj \ + -I$(srcdir)/../SALOMELocalTrace \ + -I$(srcdir)/../Basics \ + -I$(srcdir)/../Utils \ + -I$(top_builddir)/idl \ + @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ + +# This local variable defines the list of dependant libraries common to all target in this package. +COMMON_LIBS = + + +#LDFLAGS+= -lSalomeGenericObj -lSalomeLifeCycleCORBA + +# +# =============================================================== +# Libraries targets +# =============================================================== +# +lib_LTLIBRARIES = libSalomeNotebook.la +libSalomeNotebook_la_SOURCES = SALOME_ParameterizedObject.cxx \ + SALOME_Parameter.cxx \ + SALOME_Notebook.cxx + +libSalomeNotebook_la_CPPFLAGS = $(COMMON_CPPFLAGS) +libSalomeNotebook_la_LDFLAGS = -Wl,-E -no-undefined -version-info=0:0:0 @LDEXPDYNFLAGS@ +libSalomeNotebook_la_LIBADD = $(COMMON_LIBS) diff --git a/src/Notebook/SALOME_Notebook.cxx b/src/Notebook/SALOME_Notebook.cxx new file mode 100644 index 000000000..2cbd52cc8 --- /dev/null +++ b/src/Notebook/SALOME_Notebook.cxx @@ -0,0 +1,56 @@ +// 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_Notebook.cxx +// Author : Alexandre SOLOVYOV +// Module : SALOME +// + +#include + +SALOME_Notebook::SALOME_Notebook() +{ +} + +void SALOME_Notebook::AddDependency( SALOME::ParameterizedObject_ptr obj, SALOME::ParameterizedObject_ptr ref ) +{ + std::string anObjEntry = obj->GetEntry(), aRefEntry = ref->GetEntry(); + std::list& aList = myDependencies[anObjEntry]; + if( find( aList.begin(), aList.end(), aRefEntry ) == aList.end() ) + aList.push_back( aRefEntry ); +} + +void SALOME_Notebook::RemoveDependency( SALOME::ParameterizedObject_ptr obj, SALOME::ParameterizedObject_ptr ref ) +{ + std::string anObjEntry = obj->GetEntry(), aRefEntry = ref->GetEntry(); + std::map< std::string, std::list >::iterator it = myDependencies.find( anObjEntry ); + if( it!=myDependencies.end() ) + it->second.remove( aRefEntry ); +} + +void SALOME_Notebook::ClearDependencies( SALOME::ParameterizedObject_ptr obj ) +{ + myDependencies.erase( obj->GetEntry() ); +} + +void SALOME_Notebook::Update( SALOME::ParameterizedObject_ptr obj ) +{ +} diff --git a/src/Notebook/SALOME_Notebook.hxx b/src/Notebook/SALOME_Notebook.hxx new file mode 100644 index 000000000..8350092a0 --- /dev/null +++ b/src/Notebook/SALOME_Notebook.hxx @@ -0,0 +1,50 @@ +// 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_Notebook.hxx +// Author : Alexandre SOLOVYOV +// Module : SALOME +// +#ifndef __SALOME_NOTEBOOK_H__ +#define __SALOME_NOTEBOOK_H__ + +#include +#include CORBA_SERVER_HEADER(SALOME_Notebook) +#include +#include +#include +#include + +class SALOME_Notebook: public POA_SALOME::Notebook, public SALOME::GenericObj_i +{ +public: + SALOME_Notebook(); + + virtual void AddDependency( SALOME::ParameterizedObject_ptr obj, SALOME::ParameterizedObject_ptr ref ); + virtual void RemoveDependency( SALOME::ParameterizedObject_ptr obj, SALOME::ParameterizedObject_ptr ref ); + virtual void ClearDependencies( SALOME::ParameterizedObject_ptr obj ); + virtual void Update( SALOME::ParameterizedObject_ptr obj ); + +private: + std::map< std::string, std::list > myDependencies; +}; + +#endif diff --git a/src/Notebook/SALOME_Parameter.cxx b/src/Notebook/SALOME_Parameter.cxx new file mode 100644 index 000000000..878843824 --- /dev/null +++ b/src/Notebook/SALOME_Parameter.cxx @@ -0,0 +1,254 @@ +// 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_Parameter.cxx +// Author : Alexandre SOLOVYOV +// Module : SALOME +// + +#include +#include +#include +#include + +SALOME_Parameter::SALOME_Parameter( bool val ) +{ + myStr = 0; + myBool = val; + myType = SALOME::TBoolean; +} + +SALOME_Parameter::SALOME_Parameter( int val ) +{ + myStr = 0; + myInt = val; + myType = SALOME::TInteger; +} + +SALOME_Parameter::SALOME_Parameter( double val ) +{ + myStr = 0; + myDouble = val; + myType = SALOME::TReal; +} + +SALOME_Parameter::SALOME_Parameter( const char* val ) +{ + SetValue( val ); +} + +SALOME_Parameter::~SALOME_Parameter() +{ + free( myStr ); +} + +bool SALOME_Parameter::GetBoolean( const char* expr, bool& val ) +{ + bool res = true; + if( strcmp( expr, "true" )==0 || strcmp( expr, "TRUE" )==0 ) + val = true; + + else if( strcmp( expr, "false" )==0 || strcmp( expr, "FALSE" )==0 ) + val = false; + + else + res = false; + + return res; +} + +void SALOME_Parameter::SetValue( const char* expr ) +{ + if( sscanf( expr, "%lf", &myDouble ) == 1 ) + myType = SALOME::TReal; + + else if( sscanf( expr, "%i", &myInt ) == 1 ) + myType = SALOME::TInteger; + + else if( GetBoolean( expr, myBool ) ) + myType = SALOME::TBoolean; + + else if( true /* Expression check */ ) + { + myType = SALOME::TExpression; + myStr = strdup( expr ); + } + + else + { + myType = SALOME::TString; + myStr = strdup( expr ); + } + + SetIsValid( true ); +} + +SALOME::ParamType SALOME_Parameter::GetType() +{ + return myType; +} + +char* SALOME_Parameter::AsString() +{ + if( !IsValid() ) + throw SALOME_Exception( LOCALIZED( "Parameter is invalid" ) ); + + char buf[256]; const char* res; + switch( myType ) + { + case SALOME::TBoolean: + res = myBool ? "true" : "false"; + break; + + case SALOME::TInteger: + sprintf( buf, "%i", myInt ); + res = buf; + break; + + case SALOME::TReal: + sprintf( buf, "%lf", myInt ); + res = buf; + break; + + case SALOME::TExpression: + case SALOME::TString: + res = myStr; + break; + } + + return strdup( res ); +} + +CORBA::Long SALOME_Parameter::AsInteger() +{ + if( !IsValid() ) + throw SALOME_Exception( LOCALIZED( "Parameter is invalid" ) ); + + CORBA::Long res = 0; + switch( myType ) + { + case SALOME::TBoolean: + res = (int)myBool; + break; + + case SALOME::TInteger: + res = myInt; + break; + + case SALOME::TReal: + res = (int)myDouble; + break; + + case SALOME::TExpression: + res = Calculate()->AsInteger(); + break; + + case SALOME::TString: + { + int val; + if( sscanf( myStr, "%i", &val ) == 0 ) + throw SALOME_Exception( LOCALIZED( "Parameter can not be converted into Integer" ) ); + res = val; + break; + } + } + + return res; +} + +CORBA::Double SALOME_Parameter::AsDouble() +{ + if( !IsValid() ) + throw SALOME_Exception( LOCALIZED( "Parameter is invalid" ) ); + + CORBA::Double res = 0; + switch( myType ) + { + case SALOME::TBoolean: + res = (double)myBool; + break; + + case SALOME::TInteger: + res = (double)myInt; + break; + + case SALOME::TReal: + res = myDouble; + break; + + case SALOME::TExpression: + res = Calculate()->AsDouble(); + break; + + case SALOME::TString: + { + double val; + if( sscanf( myStr, "%lf", &val ) == 0 ) + throw SALOME_Exception( LOCALIZED( "Parameter can not be converted into Real" ) ); + res = val; + break; + } + } + + return res; +} + +CORBA::Boolean SALOME_Parameter::AsBoolean() +{ + bool res; + switch( myType ) + { + case SALOME::TBoolean: + res = myBool; + break; + + case SALOME::TInteger: + res = (bool)myInt; + break; + + case SALOME::TReal: + res = (bool)myDouble; + break; + + case SALOME::TExpression: + res = Calculate()->AsBoolean(); + break; + + case SALOME::TString: + { + if( !GetBoolean( myStr, res ) ) + throw SALOME_Exception( LOCALIZED( "Parameter can not be converted into Boolean" ) ); + + break; + } + } + return res; +} + +SALOME_Parameter* SALOME_Parameter::Calculate() +{ + return myType == SALOME::TExpression ? this : this; +} + +char* SALOME_Parameter::GetEntry() +{ + return ""; +} diff --git a/src/Notebook/SALOME_Parameter.hxx b/src/Notebook/SALOME_Parameter.hxx new file mode 100644 index 000000000..f27c6fd84 --- /dev/null +++ b/src/Notebook/SALOME_Parameter.hxx @@ -0,0 +1,66 @@ +// 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_Parameter.hxx +// Author : Alexandre SOLOVYOV +// Module : SALOME +// +#ifndef __SALOME_PARAMETER_H__ +#define __SALOME_PARAMETER_H__ + +#include + +class SALOME_Parameter: public POA_SALOME::Parameter, public SALOME_ParameterizedObject +{ +public: + //! standard constructor + SALOME_Parameter( bool val ); + SALOME_Parameter( int val ); + SALOME_Parameter( double val ); + SALOME_Parameter( const char* val ); + + //! standard destructor + virtual ~SALOME_Parameter(); + + virtual char* GetEntry(); + + virtual void SetValue( const char* expr ); + + virtual SALOME::ParamType GetType(); + + virtual char* AsString(); + virtual CORBA::Long AsInteger(); + virtual CORBA::Double AsDouble(); + virtual CORBA::Boolean AsBoolean(); + +protected: + virtual SALOME_Parameter* Calculate(); + virtual bool GetBoolean( const char* expr, bool& val ); + +private: + int myInt; + double myDouble; + char* myStr; + bool myBool; + SALOME::ParamType myType; +}; + +#endif diff --git a/src/Notebook/SALOME_ParameterizedObject.cxx b/src/Notebook/SALOME_ParameterizedObject.cxx new file mode 100644 index 000000000..2a54b86f6 --- /dev/null +++ b/src/Notebook/SALOME_ParameterizedObject.cxx @@ -0,0 +1,66 @@ +// 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 new file mode 100644 index 000000000..ca27ced9f --- /dev/null +++ b/src/Notebook/SALOME_ParameterizedObject.hxx @@ -0,0 +1,63 @@ +// 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 POA_SALOME::ParameterizedObject, public 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 diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index d25086e27..70022ddd9 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -44,7 +44,6 @@ #include "SALOMEDSImpl_SComponentIterator.hxx" #include "SALOMEDSImpl_AttributeStudyProperties.hxx" #include "SALOMEDSImpl_AttributeParameter.hxx" -#include "SALOMEDSImpl_GenericVariable.hxx" #include "SALOMEDSImpl_UseCaseBuilder.hxx" #include "SALOMEDS_Driver_i.hxx" @@ -680,252 +679,6 @@ vector SALOMEDS_Study::GetLockerID() return aVector; } - -void SALOMEDS_Study::SetReal(const string& theVarName, const double theValue) -{ - if (_isLocal) { - SALOMEDS::Locker lock; - _local_impl->SetVariable(theVarName, - theValue, - SALOMEDSImpl_GenericVariable::REAL_VAR); - } - else - _corba_impl->SetReal((char*)theVarName.c_str(),theValue); -} - -void SALOMEDS_Study::SetInteger(const string& theVarName, const int theValue) -{ - if (_isLocal) { - SALOMEDS::Locker lock; - _local_impl->SetVariable(theVarName, - theValue, - SALOMEDSImpl_GenericVariable::INTEGER_VAR); - } - else - _corba_impl->SetInteger((char*)theVarName.c_str(),theValue); -} - -void SALOMEDS_Study::SetBoolean(const string& theVarName, const bool theValue) -{ - if (_isLocal) { - SALOMEDS::Locker lock; - _local_impl->SetVariable(theVarName, - theValue, - SALOMEDSImpl_GenericVariable::BOOLEAN_VAR); - } - else - _corba_impl->SetBoolean((char*)theVarName.c_str(),theValue); -} - -void SALOMEDS_Study::SetString(const string& theVarName, const string& theValue) -{ - if (_isLocal) { - SALOMEDS::Locker lock; - _local_impl->SetStringVariable(theVarName, - theValue, - SALOMEDSImpl_GenericVariable::STRING_VAR); - } - else - _corba_impl->SetString((char*)theVarName.c_str(),(char*)theValue.c_str()); -} - -void SALOMEDS_Study::SetStringAsDouble(const string& theVarName, const double theValue) -{ - if (_isLocal) { - SALOMEDS::Locker lock; - _local_impl->SetStringVariableAsDouble(theVarName, - theValue, - SALOMEDSImpl_GenericVariable::STRING_VAR); - } - else - _corba_impl->SetStringAsDouble((char*)theVarName.c_str(),theValue); -} - -double SALOMEDS_Study::GetReal(const string& theVarName) -{ - double aResult; - if (_isLocal) { - SALOMEDS::Locker lock; - aResult = _local_impl->GetVariableValue(theVarName); - } - else - aResult = _corba_impl->GetReal((char*)theVarName.c_str()); - return aResult; -} - -int SALOMEDS_Study::GetInteger(const string& theVarName) -{ - int aResult; - if (_isLocal) { - SALOMEDS::Locker lock; - aResult = (int) _local_impl->GetVariableValue(theVarName); - } - else - aResult = _corba_impl->GetInteger((char*)theVarName.c_str()); - return aResult; -} - -bool SALOMEDS_Study::GetBoolean(const string& theVarName) -{ - bool aResult; - if (_isLocal) { - SALOMEDS::Locker lock; - aResult = (bool) _local_impl->GetVariableValue(theVarName); - } - else - aResult = _corba_impl->GetBoolean((char*)theVarName.c_str()); - return aResult; -} - -std::string SALOMEDS_Study::GetString(const string& theVarName) -{ - std::string aResult; - if (_isLocal) { - SALOMEDS::Locker lock; - aResult = _local_impl->GetStringVariableValue(theVarName); - } - else - aResult = _corba_impl->GetString((char*)theVarName.c_str()); - return aResult; -} - -bool SALOMEDS_Study::IsReal(const string& theVarName) -{ - bool aResult; - if (_isLocal) { - SALOMEDS::Locker lock; - aResult = _local_impl->IsTypeOf(theVarName, - SALOMEDSImpl_GenericVariable::REAL_VAR); - } - else - aResult = _corba_impl->IsReal((char*)theVarName.c_str()); - return aResult; -} - -bool SALOMEDS_Study::IsInteger(const string& theVarName) -{ - bool aResult; - if (_isLocal) { - SALOMEDS::Locker lock; - aResult = _local_impl->IsTypeOf(theVarName, - SALOMEDSImpl_GenericVariable::INTEGER_VAR); - } - else - aResult = _corba_impl->IsInteger((char*)theVarName.c_str()); - return aResult; -} - -bool SALOMEDS_Study::IsBoolean(const string& theVarName) -{ - bool aResult; - if (_isLocal) { - SALOMEDS::Locker lock; - aResult = _local_impl->IsTypeOf(theVarName, - SALOMEDSImpl_GenericVariable::BOOLEAN_VAR); - } - else - aResult = _corba_impl->IsBoolean((char*)theVarName.c_str()); - return aResult; -} - -bool SALOMEDS_Study::IsString(const string& theVarName) -{ - bool aResult; - if (_isLocal) { - SALOMEDS::Locker lock; - aResult = _local_impl->IsTypeOf(theVarName, - SALOMEDSImpl_GenericVariable::STRING_VAR); - } - else - aResult = _corba_impl->IsString((char*)theVarName.c_str()); - return aResult; -} - -bool SALOMEDS_Study::IsVariable(const string& theVarName) -{ - bool aResult; - if (_isLocal) { - SALOMEDS::Locker lock; - aResult = _local_impl->IsVariable(theVarName); - } - else - aResult = _corba_impl->IsVariable((char*)theVarName.c_str()); - return aResult; -} - -vector SALOMEDS_Study::GetVariableNames() -{ - vector aVector; - if (_isLocal) { - SALOMEDS::Locker lock; - aVector = _local_impl->GetVariableNames(); - } - else { - SALOMEDS::ListOfStrings_var aSeq = _corba_impl->GetVariableNames(); - int aLength = aSeq->length(); - for (int i = 0; i < aLength; i++) - aVector.push_back( string(aSeq[i].in()) ); - } - return aVector; -} - -bool SALOMEDS_Study::RemoveVariable(const string& theVarName) -{ - bool aResult; - if (_isLocal) { - SALOMEDS::Locker lock; - aResult = _local_impl->RemoveVariable(theVarName); - } - else - aResult = _corba_impl->RemoveVariable((char*)theVarName.c_str()); - return aResult; -} - -bool SALOMEDS_Study::RenameVariable(const string& theVarName, const string& theNewVarName) -{ - bool aResult; - if (_isLocal) { - SALOMEDS::Locker lock; - aResult = _local_impl->RenameVariable(theVarName, theNewVarName); - } - else - aResult = _corba_impl->RenameVariable((char*)theVarName.c_str(), (char*)theNewVarName.c_str()); - return aResult; -} - -bool SALOMEDS_Study::IsVariableUsed(const string& theVarName) -{ - bool aResult; - if (_isLocal) { - SALOMEDS::Locker lock; - aResult = _local_impl->IsVariableUsed(theVarName); - } - else - aResult = _corba_impl->IsVariableUsed((char*)theVarName.c_str()); - return aResult; -} - -vector< vector > SALOMEDS_Study::ParseVariables(const string& theVars) -{ - vector< vector > aResult; - if (_isLocal) { - SALOMEDS::Locker lock; - aResult = _local_impl->ParseVariables(theVars); - } - else { - SALOMEDS::ListOfListOfStrings_var aSeq = _corba_impl->ParseVariables(theVars.c_str()); - for (int i = 0, n = aSeq->length(); i < n; i++) { - vector aVector; - SALOMEDS::ListOfStrings aSection = aSeq[i]; - for (int j = 0, m = aSection.length(); j < m; j++) { - aVector.push_back( string(aSection[j].in()) ); - } - aResult.push_back( aVector ); - } - } - return aResult; -} - std::string SALOMEDS_Study::ConvertObjectToIOR(CORBA::Object_ptr theObject) { return _orb->object_to_string(theObject); diff --git a/src/SALOMEDS/SALOMEDS_Study.hxx b/src/SALOMEDS/SALOMEDS_Study.hxx index 91ae9d64c..65b29cd22 100644 --- a/src/SALOMEDS/SALOMEDS_Study.hxx +++ b/src/SALOMEDS/SALOMEDS_Study.hxx @@ -98,30 +98,6 @@ public: virtual void UnLockStudy(const std::string& theLockerID); virtual std::vector GetLockerID(); - virtual void SetReal(const std::string& theVarName, const double theValue); - virtual void SetInteger(const std::string& theVarName, const int theValue); - virtual void SetBoolean(const std::string& theVarName, const bool theValue); - virtual void SetString(const std::string& theVarName, const std::string& theValue); - virtual void SetStringAsDouble(const std::string& theVarName, const double theValue); - - virtual double GetReal(const std::string& theVarName); - virtual int GetInteger(const std::string& theVarName); - virtual bool GetBoolean(const std::string& theVarName); - virtual std::string GetString(const std::string& theVarName); - - virtual bool IsReal(const std::string& theVarName); - virtual bool IsInteger(const std::string& theVarName); - virtual bool IsBoolean(const std::string& theVarName); - virtual bool IsString(const std::string& theVarName); - - virtual bool IsVariable(const std::string& theVarName); - virtual std::vector GetVariableNames(); - - virtual bool RemoveVariable(const std::string& theVarName); - 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); - 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 bbb4855a6..8a01c0d95 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -881,240 +881,6 @@ SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetLockerID() } return aResult._retn(); } -//============================================================================ -/*! Function : SetReal - * Purpose : - */ -//============================================================================ -void SALOMEDS_Study_i::SetReal(const char* theVarName, CORBA::Double theValue) -{ - _impl->SetVariable(string(theVarName), - theValue, - SALOMEDSImpl_GenericVariable::REAL_VAR); -} - -//============================================================================ -/*! Function : SetInteger - * Purpose : - */ -//============================================================================ -void SALOMEDS_Study_i::SetInteger(const char* theVarName, CORBA::Long theValue) -{ - _impl->SetVariable(string(theVarName), - theValue, - SALOMEDSImpl_GenericVariable::INTEGER_VAR); -} - -//============================================================================ -/*! Function : SetBoolean - * Purpose : - */ -//============================================================================ -void SALOMEDS_Study_i::SetBoolean(const char* theVarName, CORBA::Boolean theValue) -{ - _impl->SetVariable(string(theVarName), - theValue, - SALOMEDSImpl_GenericVariable::BOOLEAN_VAR); -} - -//============================================================================ -/*! Function : SetString - * Purpose : - */ -//============================================================================ -void SALOMEDS_Study_i::SetString(const char* theVarName, const char* theValue) -{ - _impl->SetStringVariable(string(theVarName), - theValue, - SALOMEDSImpl_GenericVariable::STRING_VAR); -} - -//============================================================================ -/*! Function : SetStringAsDouble - * Purpose : - */ -//============================================================================ -void SALOMEDS_Study_i::SetStringAsDouble(const char* theVarName, CORBA::Double theValue) -{ - _impl->SetStringVariableAsDouble(string(theVarName), - theValue, - SALOMEDSImpl_GenericVariable::STRING_VAR); -} - -//============================================================================ -/*! Function : GetReal - * Purpose : - */ -//============================================================================ -CORBA::Double SALOMEDS_Study_i::GetReal(const char* theVarName) -{ - return _impl->GetVariableValue(string(theVarName)); -} - -//============================================================================ -/*! Function : GetInteger - * Purpose : - */ -//============================================================================ -CORBA::Long SALOMEDS_Study_i::GetInteger(const char* theVarName) -{ - return (int)_impl->GetVariableValue(string(theVarName)); -} - -//============================================================================ -/*! Function : GetBoolean - * Purpose : - */ -//============================================================================ -CORBA::Boolean SALOMEDS_Study_i::GetBoolean(const char* theVarName) -{ - return (bool)_impl->GetVariableValue(string(theVarName)); -} - -//============================================================================ -/*! Function : GetString - * Purpose : - */ -//============================================================================ -char* SALOMEDS_Study_i::GetString(const char* theVarName) -{ - return CORBA::string_dup(_impl->GetStringVariableValue(string(theVarName)).c_str()); -} - -//============================================================================ -/*! Function : IsReal - * Purpose : - */ -//============================================================================ -CORBA::Boolean SALOMEDS_Study_i::IsReal(const char* theVarName) -{ - return _impl->IsTypeOf(string(theVarName), - SALOMEDSImpl_GenericVariable::REAL_VAR); -} - -//============================================================================ -/*! Function : IsInteger - * Purpose : - */ -//============================================================================ -CORBA::Boolean SALOMEDS_Study_i::IsInteger(const char* theVarName) -{ - return _impl->IsTypeOf(string(theVarName), - SALOMEDSImpl_GenericVariable::INTEGER_VAR); -} - -//============================================================================ -/*! Function : IsBoolean - * Purpose : - */ -//============================================================================ -CORBA::Boolean SALOMEDS_Study_i::IsBoolean(const char* theVarName) -{ - return _impl->IsTypeOf(string(theVarName), - SALOMEDSImpl_GenericVariable::BOOLEAN_VAR); -} - -//============================================================================ -/*! Function : IsString - * Purpose : - */ -//============================================================================ -CORBA::Boolean SALOMEDS_Study_i::IsString(const char* theVarName) -{ - return _impl->IsTypeOf(string(theVarName), - SALOMEDSImpl_GenericVariable::STRING_VAR); -} - -//============================================================================ -/*! Function : IsVariable - * Purpose : - */ -//============================================================================ -CORBA::Boolean SALOMEDS_Study_i::IsVariable(const char* theVarName) -{ - return _impl->IsVariable(string(theVarName)); -} - -//============================================================================ -/*! Function : GetVariableNames - * Purpose : - */ -//============================================================================ -SALOMEDS::ListOfStrings* SALOMEDS_Study_i::GetVariableNames() -{ - vector aVarNames = _impl->GetVariableNames(); - SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings; - - int aLen = aVarNames.size(); - aResult->length(aLen); - - for (int anInd = 0; anInd < aLen; anInd++) - aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str()); - - return aResult._retn(); -} - -//============================================================================ -/*! Function : RemoveVariable - * Purpose : - */ -//============================================================================ -CORBA::Boolean SALOMEDS_Study_i::RemoveVariable(const char* theVarName) -{ - return _impl->RemoveVariable(string(theVarName)); -} - -//============================================================================ -/*! Function : RenameVariable - * Purpose : - */ -//============================================================================ -CORBA::Boolean SALOMEDS_Study_i::RenameVariable(const char* theVarName, const char* theNewVarName) -{ - return _impl->RenameVariable(string(theVarName), string(theNewVarName)); -} - -//============================================================================ -/*! Function : IsVariableUsed - * Purpose : - */ -//============================================================================ -CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName) -{ - return _impl->IsVariableUsed(string(theVarName)); -} - - -//============================================================================ -/*! Function : ParseVariables - * Purpose : - */ -//============================================================================ -SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName) -{ - vector< vector > aSections = _impl->ParseVariables(string(theVarName)); - - SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings; - - int aSectionsLen = aSections.size(); - aResult->length(aSectionsLen); - - for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) { - vector aVarNames = aSections[aSectionInd]; - - SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings; - - int aLen = aVarNames.size(); - aList->length(aLen); - - for (int anInd = 0; anInd < aLen; anInd++) - aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str()); - - aResult[aSectionInd] = aList; - } - - return aResult._retn(); -} //============================================================================ /*! Function : GetDefaultScript diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index bd8fd2b5a..49b971a7d 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -298,44 +298,6 @@ public: virtual SALOMEDS::ListOfStrings* GetLockerID(); - virtual void SetReal(const char* theVarName, CORBA::Double theValue); - - virtual void SetInteger(const char* theVarName, CORBA::Long theValue); - - virtual void SetBoolean(const char* theVarName, CORBA::Boolean theValue); - - virtual void SetString(const char* theVarName, const char* theValue); - - virtual void SetStringAsDouble(const char* theVarName, CORBA::Double theValue); - - virtual CORBA::Double GetReal(const char* theVarName); - - virtual CORBA::Long GetInteger(const char* theVarName); - - virtual CORBA::Boolean GetBoolean(const char* theVarName); - - virtual char* GetString(const char* theVarName); - - virtual CORBA::Boolean IsReal(const char* theVarName); - - virtual CORBA::Boolean IsInteger(const char* theVarName); - - virtual CORBA::Boolean IsBoolean(const char* theVarName); - - virtual CORBA::Boolean IsString(const char* theVarName); - - virtual CORBA::Boolean IsVariable(const char* theVarName); - - virtual SALOMEDS::ListOfStrings* GetVariableNames(); - - virtual CORBA::Boolean RemoveVariable(const char* theVarName); - - virtual CORBA::Boolean RenameVariable(const char* theVarName, const char* theNewVarName); - - virtual CORBA::Boolean IsVariableUsed(const char* theVarName); - - virtual SALOMEDS::ListOfListOfStrings* ParseVariables(const char* theVars); - virtual char* GetDefaultScript(const char* theModuleName, const char* theShift); virtual CORBA::Boolean DumpStudy(const char* thePath, const char* theBaseName, CORBA::Boolean isPublished); diff --git a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx index c63e258c9..a1bc4aa4f 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx @@ -93,33 +93,6 @@ public: virtual bool IsStudyLocked() = 0; virtual void UnLockStudy(const std::string& theLockerID) = 0; virtual std::vector GetLockerID() = 0; - - virtual void SetReal(const std::string& theVarName, const double theValue) = 0; - virtual void SetInteger(const std::string& theVarName, const int theValue) = 0; - virtual void SetBoolean(const std::string& theVarName, const bool theValue) = 0; - virtual void SetString(const std::string& theVarName, const std::string& theValue) = 0; - virtual void SetStringAsDouble(const std::string& theVarName, const double theValue) = 0; - - virtual double GetReal(const std::string& theVarName) = 0; - virtual int GetInteger(const std::string& theVarName) = 0; - virtual bool GetBoolean(const std::string& theVarName) = 0; - virtual std::string GetString(const std::string& theVarName) = 0; - - virtual bool IsReal(const std::string& theVarName) = 0; - virtual bool IsInteger(const std::string& theVarName) = 0; - virtual bool IsBoolean(const std::string& theVarName) = 0; - virtual bool IsString(const std::string& theVarName) = 0; - - virtual bool IsVariable(const std::string& theVarName) = 0; - virtual std::vector GetVariableNames() = 0; - - virtual bool RemoveVariable(const std::string& theVarName) = 0; - virtual bool RenameVariable(const std::string& theVarName, - const std::string& theNewVarName) = 0; - virtual bool IsVariableUsed(const std::string& theVarName) = 0; - - virtual std::vector< std::vector > ParseVariables(const std::string& theVars) = 0; - }; diff --git a/src/SALOMEDSImpl/Makefile.am b/src/SALOMEDSImpl/Makefile.am index 731cf625a..fcbf0869c 100644 --- a/src/SALOMEDSImpl/Makefile.am +++ b/src/SALOMEDSImpl/Makefile.am @@ -79,9 +79,7 @@ salomeinclude_HEADERS= \ SALOMEDSImpl_ChildNodeIterator.hxx \ SALOMEDSImpl_Defines.hxx \ SALOMEDSImpl_IParameters.hxx \ - SALOMEDSImpl_TMPFile.hxx \ - SALOMEDSImpl_GenericVariable.hxx \ - SALOMEDSImpl_ScalarVariable.hxx + SALOMEDSImpl_TMPFile.hxx # # =============================================================== @@ -162,8 +160,6 @@ libSalomeDSImpl_la_SOURCES =\ SALOMEDSImpl_StudyManager.cxx \ SALOMEDSImpl_IParameters.cxx \ SALOMEDSImpl_TMPFile.cxx \ - SALOMEDSImpl_GenericVariable.cxx \ - SALOMEDSImpl_ScalarVariable.cxx \ \ SALOMEDSImpl_AttributeComment.hxx \ SALOMEDSImpl_AttributeDrawable.hxx \ @@ -212,10 +208,8 @@ libSalomeDSImpl_la_SOURCES =\ SALOMEDSImpl_StudyManager.hxx \ SALOMEDSImpl_Tool.hxx \ SALOMEDSImpl_UseCaseBuilder.hxx \ - SALOMEDSImpl_UseCaseIterator.hxx \ - SALOMEDSImpl_GenericVariable.hxx \ - SALOMEDSImpl_ScalarVariable.hxx - + SALOMEDSImpl_UseCaseIterator.hxx + libSalomeDSImpl_la_CPPFLAGS = $(COMMON_CPPFLAGS) libSalomeDSImpl_la_LDFLAGS = -no-undefined -version-info=0:0:0 libSalomeDSImpl_la_LIBADD = $(COMMON_LIBS) $(CORBA_LIBS) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_GenericVariable.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_GenericVariable.cxx deleted file mode 100644 index 7de967c2c..000000000 --- a/src/SALOMEDSImpl/SALOMEDSImpl_GenericVariable.cxx +++ /dev/null @@ -1,148 +0,0 @@ -// Copyright (C) 2008 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 : SALOMEDSImpl_GenericVariable.cxx -// Author : Roman NIKOLAEV, Open CASCADE S.A.S. -// Module : SALOME - -#include "SALOMEDSImpl_GenericVariable.hxx" -#include "SALOMEDSImpl_Attributes.hxx" -#include "SALOMEDSImpl_Study.hxx" - -#include - - -using namespace std; - -//============================================================================ -/*! Function : SALOMEDSImpl_GenericVariable - * Purpose : - */ -//============================================================================ -SALOMEDSImpl_GenericVariable:: -SALOMEDSImpl_GenericVariable(SALOMEDSImpl_GenericVariable::VariableTypes theType, - const string& theName): - _type(theType), - _name(theName) -{} - -//============================================================================ -/*! Function : ~SALOMEDSImpl_GenericVariable - * Purpose : - */ -//============================================================================ -SALOMEDSImpl_GenericVariable::~SALOMEDSImpl_GenericVariable() -{} - -//============================================================================ -/*! Function : Type - * Purpose : - */ -//============================================================================ -SALOMEDSImpl_GenericVariable::VariableTypes SALOMEDSImpl_GenericVariable::Type() const -{ - return _type; -} - -//============================================================================ -/*! Function : Name - * Purpose : - */ -//============================================================================ -string SALOMEDSImpl_GenericVariable::Name() const -{ - return _name; -} - -//============================================================================ -/*! Function : setType - * Purpose : - */ -//============================================================================ -bool SALOMEDSImpl_GenericVariable::setType(const SALOMEDSImpl_GenericVariable::VariableTypes theType) -{ - if(_type == theType) - return false; - - _type = theType; - return true; -} - -//============================================================================ -/*! Function : setName - * Purpose : - */ -//============================================================================ -bool SALOMEDSImpl_GenericVariable::setName(const std::string& theName) -{ - if(_name.compare(theName) == 0) - return false; - - _name = theName; - return true; -} - -//============================================================================ -/*! Function : String2VariableType - * Purpose : - */ -//============================================================================ -SALOMEDSImpl_GenericVariable::VariableTypes SALOMEDSImpl_GenericVariable::String2VariableType(const string& theStrType) -{ - return(SALOMEDSImpl_GenericVariable::VariableTypes)atoi((char*)theStrType.c_str()); -} - -//============================================================================ -/*! Function : Save - * Purpose : - */ -//============================================================================ -string SALOMEDSImpl_GenericVariable::Save() const -{ - return string(); -} - - -//============================================================================ -/*! Function : SaveToScript - * Purpose : - */ -//============================================================================ -string SALOMEDSImpl_GenericVariable::SaveToScript() const -{ - return string(); -} -//============================================================================ -/*! Function : SaveType - * Purpose : - */ -//============================================================================ -string SALOMEDSImpl_GenericVariable::SaveType() const -{ - return string(); -} - -//============================================================================ -/*! Function : Load - * Purpose : - */ -//============================================================================ -void SALOMEDSImpl_GenericVariable::Load(const string& theStrValue) -{ -} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_GenericVariable.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_GenericVariable.hxx deleted file mode 100644 index 3e74897a3..000000000 --- a/src/SALOMEDSImpl/SALOMEDSImpl_GenericVariable.hxx +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2008 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 : SALOMEDSImpl_GenericVariable.hxx -// Author : Roman NIKOLAEV, Open CASCADE S.A.S. -// Module : SALOME - -#ifndef _GENERICIMPL_VARIABLE_HXX_ -#define _GENERICIMPL_VARIABLE_HXX_ - -#include "SALOMEDSImpl_Defines.hxx" - -#include - -//This is base class for all variable of the Salome notebook - -class SALOMEDSIMPL_EXPORT SALOMEDSImpl_GenericVariable -{ - public: - - //Supported types of the nootebook variables - enum VariableTypes{REAL_VAR, INTEGER_VAR, BOOLEAN_VAR, STRING_VAR}; - - SALOMEDSImpl_GenericVariable(VariableTypes theType, const std::string& theName); - ~SALOMEDSImpl_GenericVariable(); - - VariableTypes Type() const; - - std::string Name() const; - - static VariableTypes String2VariableType(const std::string& theStrType); - - bool setType(const VariableTypes theType); - - bool setName(const std::string& theName); - - virtual std::string Save() const; - virtual std::string SaveToScript() const; - virtual std::string SaveType() const; - - virtual void Load(const std::string& theStrValue); - - private: - VariableTypes _type; - std::string _name; -}; - -#endif //_GENERICIMPL_VARIABLE_HXX_ diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx deleted file mode 100644 index d40db227c..000000000 --- a/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright (C) 2008 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 : SALOMEDSImpl_ScalarVariable.cxx -// Author : Roman NIKOLAEV, Open CASCADE S.A.S. -// Module : SALOME - -#include "SALOMEDSImpl_ScalarVariable.hxx" -#include "SALOMEDSImpl_GenericVariable.hxx" -#include -#include - -using namespace std; - -//============================================================================ -/*! Function : SALOMEDSImpl_ScalarVariable - * Purpose : - */ -//============================================================================ -SALOMEDSImpl_ScalarVariable:: -SALOMEDSImpl_ScalarVariable(SALOMEDSImpl_GenericVariable::VariableTypes type, - const string& theName): - SALOMEDSImpl_GenericVariable(type,theName) -{} - -//============================================================================ -/*! Function : ~SALOMEDSImpl_ScalarVariable() - * Purpose : - */ -//============================================================================ -SALOMEDSImpl_ScalarVariable::~SALOMEDSImpl_ScalarVariable(){} - -//============================================================================ -/*! Function : - * Purpose : - */ -//============================================================================ -bool SALOMEDSImpl_ScalarVariable::setValue(const double theValue) -{ - - if(myValue == theValue) - return false; - - myValue = theValue; - return true; -} - -//============================================================================ -/*! Function : - * Purpose : - */ -//============================================================================ -bool SALOMEDSImpl_ScalarVariable::setStringValue(const string& theValue) -{ - - if(myStrValue == theValue) - return false; - - myStrValue = theValue; - return true; -} - -//============================================================================ -/*! Function : getValue() - * Purpose : - */ -//============================================================================ -double SALOMEDSImpl_ScalarVariable::getValue() const -{ - return myValue; -} - -//============================================================================ -/*! Function : getStringValue() - * Purpose : - */ -//============================================================================ -string SALOMEDSImpl_ScalarVariable::getStringValue() const -{ - return myStrValue; -} - -//============================================================================ -/*! Function : Save() - * Purpose : - */ -//============================================================================ -string SALOMEDSImpl_ScalarVariable::Save() const{ - char buffer[255]; - switch(Type()) - { - case SALOMEDSImpl_GenericVariable::REAL_VAR: - { - sprintf(buffer, "%.64e", myValue); - break; - } - case SALOMEDSImpl_GenericVariable::BOOLEAN_VAR: - case SALOMEDSImpl_GenericVariable::INTEGER_VAR: - { - sprintf(buffer, "%d", (int)myValue); - break; - } - case SALOMEDSImpl_GenericVariable::STRING_VAR: - { - sprintf(buffer, "\"%s\"", myStrValue.c_str()); - break; - } - default:break; - } - return string(buffer); -} - -//============================================================================ -/*! Function : SaveToScript() - * Purpose : - */ -//============================================================================ -string SALOMEDSImpl_ScalarVariable::SaveToScript() const -{ - char buffer[255]; - switch(Type()) - { - case SALOMEDSImpl_GenericVariable::REAL_VAR: - { - sprintf(buffer, "%g", myValue); - break; - } - case SALOMEDSImpl_GenericVariable::INTEGER_VAR: - { - sprintf(buffer, "%d", (int)myValue); - break; - } - case SALOMEDSImpl_GenericVariable::BOOLEAN_VAR: - { - if((bool)myValue) - sprintf(buffer, "%s", "True"); - else - sprintf(buffer, "%s", "False"); - break; - } - case SALOMEDSImpl_GenericVariable::STRING_VAR: - { - sprintf(buffer, "\"%s\"", myStrValue.c_str()); - break; - } - default:break; - } - return string(buffer); -} - -//============================================================================ -/*! Function : SaveType() - * Purpose : - */ -//============================================================================ -string SALOMEDSImpl_ScalarVariable::SaveType() const{ - char buffer[255]; - sprintf(buffer, "%d", (int)Type()); - return string(buffer); -} - -//============================================================================ -/*! Function : Load() - * Purpose : - */ -//============================================================================ -void SALOMEDSImpl_ScalarVariable::Load(const string& theStrValue) -{ - double aValue = atof(theStrValue.c_str()); - setValue(aValue); -} diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.hxx deleted file mode 100644 index acb897156..000000000 --- a/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.hxx +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2008 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 : SALOMEDSImpl_ScalarVariable.hxx -// Author : Roman NIKOLAEV, Open CASCADE S.A.S. -// Module : SALOME - -#ifndef _SALOMEDSImpl_ScalarVariable_HeaderFile -#define _SALOMEDSImpl_ScalarVariable_HeaderFile - -#include "SALOMEDSImpl_Defines.hxx" -#include "SALOMEDSImpl_GenericVariable.hxx" - -class SALOMEDSIMPL_EXPORT SALOMEDSImpl_ScalarVariable : - public SALOMEDSImpl_GenericVariable -{ -public: - SALOMEDSImpl_ScalarVariable(SALOMEDSImpl_GenericVariable::VariableTypes theType, - const std::string& theName); - ~SALOMEDSImpl_ScalarVariable(); - - bool setValue(const double theValue); - double getValue() const; - - bool setStringValue(const std::string& theValue); - std::string getStringValue() const; - - virtual std::string Save() const; - virtual std::string SaveToScript() const; - virtual std::string SaveType() const; - - virtual void Load(const std::string& theStrValue); - -private: - double myValue; - std::string myStrValue; -}; - - -#endif //_SALOMEDSImpl_ScalarVariable_HeaderFile diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index 2b24641ad..caa4adafe 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -40,15 +40,12 @@ using namespace std; #include "SALOMEDSImpl_StudyHandle.hxx" #include "SALOMEDSImpl_Tool.hxx" #include "SALOMEDSImpl_IParameters.hxx" -#include "SALOMEDSImpl_ScalarVariable.hxx" #include #define DIRECTORYID 16661 #define FILELOCALID 26662 #define FILEID "FILE: " -#define VARIABLE_SEPARATOR ':' -#define OPERATION_SEPARATOR '|' //============================================================================ /*! Function : SALOMEDSImpl_Study @@ -886,62 +883,6 @@ SALOMEDSImpl_Study::_FindObjectIOR(const SALOMEDSImpl_SObject& SO, return RefSO; } -//============================================================================ -/*! Function : _GetNoteBookAccessor - * Purpose : Find an Object with SALOMEDSImpl_IOR = anObjectIOR - */ -//============================================================================ -string SALOMEDSImpl_Study::_GetNoteBookAccessor(){ - return string("notebook"); -} - -//============================================================================ -/*! Function : _GetStudyVariablesScript - * Purpose : - */ -//============================================================================ -string SALOMEDSImpl_Study::_GetStudyVariablesScript() -{ - string dump(""); - - if(myNoteBookVars.empty()) - return dump; - - Kernel_Utils::Localizer loc; - - dump += "####################################################\n"; - dump += "## Begin of NoteBook variables section ##\n"; - dump += "####################################################\n"; - - string set_method = _GetNoteBookAccessor()+".set("; - string varName; - string varValue; - for(int i = 0 ; i < myNoteBookVars.size();i++ ) { - varName = myNoteBookVars[i]->Name(); - varValue = myNoteBookVars[i]->SaveToScript(); - dump+=set_method+"\""+varName+"\", "+varValue+")\n"; - } - - dump += "####################################################\n"; - dump += "## End of NoteBook variables section ##\n"; - dump += "####################################################\n"; - - return dump; -} - -//============================================================================ -/*! Function : _GetNoteBookAccess - * Purpose : - */ -//============================================================================ -string SALOMEDSImpl_Study::_GetNoteBookAccess() -{ - string accessor = _GetNoteBookAccessor(); - string notebook = "import salome_notebook\n"; - notebook += accessor+" = salome_notebook."+accessor + "\n"; - return notebook; -} - bool SALOMEDSImpl_Study::IsLocked() { _errorCode = ""; @@ -1232,12 +1173,12 @@ bool SALOMEDSImpl_Study::DumpStudy(const string& thePath, fp << aBatchModeScript << ".salome_init()" << endl << endl; - fp << _GetNoteBookAccess(); + //ASL: fp << _GetNoteBookAccess(); fp << "sys.path.insert( 0, r\'" << thePath << "\')" << endl << endl; //Dump NoteBook Variables - fp << _GetStudyVariablesScript(); + //ASL: fp << _GetStudyVariablesScript(); //Check if it's necessary to dump visual parameters bool isDumpVisuals = SALOMEDSImpl_IParameters::isDumpPython(this); @@ -1248,7 +1189,6 @@ bool SALOMEDSImpl_Study::DumpStudy(const string& thePath, fp << SALOMEDSImpl_IParameters::getStudyScript(this, lastSavePoint) << endl << endl; } } - vector aSeqOfFileNames; @@ -1566,379 +1506,6 @@ vector SALOMEDSImpl_Study::GetLockerID() return _lockers; } -//============================================================================ -/*! Function : SetVariable - * Purpose : - */ -//============================================================================ -void SALOMEDSImpl_Study::SetVariable(const string& theVarName, - const double theValue, - const SALOMEDSImpl_GenericVariable::VariableTypes theType) -{ - bool modified = false; - SALOMEDSImpl_GenericVariable* aGVar = GetVariable(theVarName); - - if( aGVar == NULL ) { - - SALOMEDSImpl_ScalarVariable* aSVar = new SALOMEDSImpl_ScalarVariable(theType, theVarName); - - aSVar->setValue(theValue); - myNoteBookVars.push_back(aSVar); - modified = true; - } - else { - if(SALOMEDSImpl_ScalarVariable* aSVar = dynamic_cast(aGVar)) { - modified = aSVar->setValue(theValue) || modified; - modified = aSVar->setType(theType) || modified; - } - } - if(modified) - Modify(); -} - -//============================================================================ -/*! Function : SetStringVariable - * Purpose : - */ -//============================================================================ -void SALOMEDSImpl_Study::SetStringVariable(const string& theVarName, - const string& theValue, - const SALOMEDSImpl_GenericVariable::VariableTypes theType) -{ - bool modified = false; - SALOMEDSImpl_GenericVariable* aGVar = GetVariable(theVarName); - - if( aGVar == NULL ) { - - SALOMEDSImpl_ScalarVariable* aSVar = new SALOMEDSImpl_ScalarVariable(theType, theVarName); - - aSVar->setStringValue(theValue); - myNoteBookVars.push_back(aSVar); - modified = true; - } - else { - if(SALOMEDSImpl_ScalarVariable* aSVar = dynamic_cast(aGVar)) { - modified = aSVar->setStringValue(theValue) || modified; - modified = aSVar->setType(theType) || modified; - } - } - if(modified) - Modify(); -} - -//============================================================================ -/*! Function : SetStringVariableAsDouble - * Purpose : - */ -//============================================================================ -void SALOMEDSImpl_Study::SetStringVariableAsDouble(const string& theVarName, - const double theValue, - const SALOMEDSImpl_GenericVariable::VariableTypes theType) -{ - SALOMEDSImpl_GenericVariable* aGVar = GetVariable(theVarName); - if(SALOMEDSImpl_ScalarVariable* aSVar = dynamic_cast(aGVar)) - aSVar->setValue(theValue); -} - -//============================================================================ -/*! Function : GetReal - * Purpose : - */ -//============================================================================ -double SALOMEDSImpl_Study::GetVariableValue(const string& theVarName) -{ - SALOMEDSImpl_GenericVariable* aGVar = GetVariable(theVarName); - - if(aGVar != NULL ) - if(SALOMEDSImpl_ScalarVariable* aSVar = dynamic_cast(aGVar)) - return aSVar->getValue(); - - return 0; -} - -//============================================================================ -/*! Function : GetString - * Purpose : - */ -//============================================================================ -string SALOMEDSImpl_Study::GetStringVariableValue(const string& theVarName) -{ - SALOMEDSImpl_GenericVariable* aGVar = GetVariable(theVarName); - - if(aGVar != NULL ) - if(SALOMEDSImpl_ScalarVariable* aSVar = dynamic_cast(aGVar)) - return aSVar->getStringValue(); - - return 0; -} - -//============================================================================ -/*! Function : IsTypeOf - * Purpose : - */ -//============================================================================ -bool SALOMEDSImpl_Study::IsTypeOf(const string& theVarName, - SALOMEDSImpl_GenericVariable:: - VariableTypes theType) const -{ - SALOMEDSImpl_GenericVariable* aGVar = GetVariable(theVarName); - - if(aGVar != NULL ) - return aGVar->Type() == theType; - - return false; -} - -//============================================================================ -/*! Function : IsVariable - * Purpose : - */ -//============================================================================ -bool SALOMEDSImpl_Study::IsVariable(const string& theVarName) const -{ - SALOMEDSImpl_GenericVariable* aGVar = GetVariable(theVarName); - return (aGVar != NULL); -} - -//============================================================================ -/*! Function : GetVariableNames - * Purpose : - */ -//============================================================================ -vector SALOMEDSImpl_Study::GetVariableNames() const -{ - vector aResult; - - for(int i = 0; i < myNoteBookVars.size(); i++) - aResult.push_back(myNoteBookVars[i]->Name()); - - return aResult; -} - -//============================================================================ -/*! Function : AddVariable - * Purpose : - */ -//============================================================================ -void SALOMEDSImpl_Study::AddVariable(SALOMEDSImpl_GenericVariable* theVariable) -{ - myNoteBookVars.push_back(theVariable); -} - -//============================================================================ -/*! Function : AddVariable - * Purpose : - */ -//============================================================================ -SALOMEDSImpl_GenericVariable* SALOMEDSImpl_Study::GetVariable(const std::string& theName) const -{ - SALOMEDSImpl_GenericVariable* aResult = NULL; - for(int i = 0; i < myNoteBookVars.size();i++) { - if(theName.compare(myNoteBookVars[i]->Name()) == 0) { - aResult = myNoteBookVars[i]; - break; - } - } - return aResult; -} - -//============================================================================ -/*! Function : RemoveVariable - * Purpose : - */ -//============================================================================ -bool SALOMEDSImpl_Study::RemoveVariable(const string& theVarName) -{ - SALOMEDSImpl_GenericVariable* aVariable = GetVariable( theVarName ); - if( !aVariable ) - return false; - - string aValue = aVariable->SaveToScript(); - ReplaceVariableAttribute( theVarName, aValue ); - - std::vector::iterator it = myNoteBookVars.begin(), itEnd = myNoteBookVars.end(); - for( ; it != itEnd; it++ ) - { - SALOMEDSImpl_GenericVariable* aVariableRef = *it; - if( aVariableRef && theVarName.compare( aVariableRef->Name() ) == 0 ) - { - myNoteBookVars.erase( it ); - Modify(); - break; - } - } - - return true; -} - -//============================================================================ -/*! Function : RenameVariable - * Purpose : - */ -//============================================================================ -bool SALOMEDSImpl_Study::RenameVariable(const string& theVarName, const string& theNewVarName) -{ - SALOMEDSImpl_GenericVariable* aVariable = GetVariable( theVarName ); - if( !aVariable ) - return false; - - ReplaceVariableAttribute( theVarName, theNewVarName ); - - std::vector::iterator it = myNoteBookVars.begin(), itEnd = myNoteBookVars.end(); - for( ; it != itEnd; it++ ) - { - SALOMEDSImpl_GenericVariable* aVariableRef = *it; - if( aVariableRef && theVarName.compare( aVariableRef->Name() ) == 0 ) - { - aVariableRef->setName( theNewVarName ); - Modify(); - break; - } - } - - return true; -} - -//============================================================================ -/*! Function : IsVariableUsed - * Purpose : - */ -//============================================================================ -bool SALOMEDSImpl_Study::IsVariableUsed(const string& theVarName) -{ - return FindVariableAttribute( theVarName ); -} - -//============================================================================ -/*! Function : FindVariableAttribute - * Purpose : - */ -//============================================================================ -bool SALOMEDSImpl_Study::FindVariableAttribute(SALOMEDSImpl_StudyBuilder* theStudyBuilder, - SALOMEDSImpl_SObject theSObject, - const std::string& theName) -{ - SALOMEDSImpl_ChildIterator anIter = NewChildIterator( theSObject ); - for( ; anIter.More(); anIter.Next() ) - if( FindVariableAttribute( theStudyBuilder, anIter.Value(), theName ) ) - return true; - - DF_Attribute* anAttr; - if( theStudyBuilder->FindAttribute( theSObject, anAttr, "AttributeString" ) ) - { - if( SALOMEDSImpl_AttributeString* aStringAttr = ( SALOMEDSImpl_AttributeString* )anAttr ) - { - string aString = aStringAttr->Value(); - - vector< vector > aSections = ParseVariables( aString ); - for( int i = 0, n = aSections.size(); i < n; i++ ) - { - vector aVector = aSections[i]; - for( int j = 0, m = aVector.size(); j < m; j++ ) - { - string aStr = aVector[j]; - if( aStr.compare( theName ) == 0 ) - return true; - } - } - } - } - return false; -} - -//============================================================================ -/*! Function : FindVariableAttribute - * Purpose : - */ -//============================================================================ -bool SALOMEDSImpl_Study::FindVariableAttribute(const std::string& theName) -{ - SALOMEDSImpl_StudyBuilder* aStudyBuilder = NewBuilder(); - SALOMEDSImpl_SComponentIterator aCompIter = NewComponentIterator(); - for( ; aCompIter.More(); aCompIter.Next() ) - { - SALOMEDSImpl_SObject aComp = aCompIter.Value(); - if( FindVariableAttribute( aStudyBuilder, aComp, theName ) ) - return true; - } - return false; -} - -//============================================================================ -/*! Function : ReplaceVariableAttribute - * Purpose : - */ -//============================================================================ -void SALOMEDSImpl_Study::ReplaceVariableAttribute(SALOMEDSImpl_StudyBuilder* theStudyBuilder, - SALOMEDSImpl_SObject theSObject, - const std::string& theSource, - const std::string& theDest) -{ - SALOMEDSImpl_ChildIterator anIter = NewChildIterator( theSObject ); - for( ; anIter.More(); anIter.Next() ) - ReplaceVariableAttribute( theStudyBuilder, anIter.Value(), theSource, theDest ); - - DF_Attribute* anAttr; - if( theStudyBuilder->FindAttribute( theSObject, anAttr, "AttributeString" ) ) - { - if( SALOMEDSImpl_AttributeString* aStringAttr = ( SALOMEDSImpl_AttributeString* )anAttr ) - { - bool isChanged = false; - string aNewString, aCurrentString = aStringAttr->Value(); - - vector< vector > aSections = ParseVariables( aCurrentString ); - for( int i = 0, n = aSections.size(); i < n; i++ ) - { - vector aVector = aSections[i]; - for( int j = 0, m = aVector.size(); j < m; j++ ) - { - string aStr = aVector[j]; - if( aStr.compare( theSource ) == 0 ) - { - isChanged = true; - aStr = theDest; - } - - aNewString.append( aStr ); - if( j != m - 1 ) - aNewString.append( ":" ); - } - if( i != n - 1 ) - aNewString.append( "|" ); - } - - if( isChanged ) - aStringAttr->SetValue( aNewString ); - } - } -} - -//============================================================================ -/*! Function : ReplaceVariableAttribute - * Purpose : - */ -//============================================================================ -void SALOMEDSImpl_Study::ReplaceVariableAttribute(const std::string& theSource, const std::string& theDest) -{ - SALOMEDSImpl_StudyBuilder* aStudyBuilder = NewBuilder(); - SALOMEDSImpl_SComponentIterator aCompIter = NewComponentIterator(); - for( ; aCompIter.More(); aCompIter.Next() ) - { - SALOMEDSImpl_SObject aComp = aCompIter.Value(); - ReplaceVariableAttribute( aStudyBuilder, aComp, theSource, theDest ); - } -} - -//============================================================================ -/*! Function : ParseVariables - * Purpose : - */ -//============================================================================ -vector< vector< string > > SALOMEDSImpl_Study::ParseVariables(const string& theVariables) const -{ - return SALOMEDSImpl_Tool::splitStringWithEmpty( theVariables, OPERATION_SEPARATOR, VARIABLE_SEPARATOR ); -} - //============================================================================ /*! Function : EnableUseCaseAutoFilling * Purpose : diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx index f9833cb23..7714d6be1 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx @@ -48,7 +48,6 @@ #include "SALOMEDSImpl_Callback.hxx" #include "SALOMEDSImpl_Driver.hxx" #include "SALOMEDSImpl_ChildIterator.hxx" -#include "SALOMEDSImpl_GenericVariable.hxx" class SALOMEDSImpl_StudyManager; class SALOMEDSImpl_GenericAttribute; @@ -73,7 +72,6 @@ private: std::map _mapOfSO; std::map _mapOfSCO; std::map myIORLabels; - std::vector myNoteBookVars; SALOMEDSImpl_SObject _FindObject(const SALOMEDSImpl_SObject& SO, const std::string& anObjectName, @@ -83,10 +81,6 @@ private: const std::string& anObjectIOR, bool& _find); - std::string _GetStudyVariablesScript(); - std::string _GetNoteBookAccessor(); - std::string _GetNoteBookAccess(); - public: static SALOMEDSImpl_Study* GetStudy(const DF_Label& theLabel); @@ -258,54 +252,6 @@ public: //Returns an ID of the study locker std::vector GetLockerID(); - //Managing of variables - void SetVariable(const std::string& theVarName, - const double theValue, - const SALOMEDSImpl_GenericVariable::VariableTypes); - - void SetStringVariable(const std::string& theVarName, - const std::string& theValue, - const SALOMEDSImpl_GenericVariable::VariableTypes); - - void SetStringVariableAsDouble(const std::string& theVarName, - const double theValue, - const SALOMEDSImpl_GenericVariable::VariableTypes); - - double GetVariableValue(const std::string& theVarName); - - std::string GetStringVariableValue(const std::string& theVarName); - - bool IsTypeOf(const std::string& theVarName, - SALOMEDSImpl_GenericVariable::VariableTypes theType) const; - - bool IsVariable(const std::string& theVarName) const; - - - std::vector GetVariableNames() const; - - void AddVariable(SALOMEDSImpl_GenericVariable* theVariable); - - SALOMEDSImpl_GenericVariable* GetVariable(const std::string& theName) const; - - bool RemoveVariable(const std::string& theVarName); - - bool RenameVariable(const std::string& theVarName, const std::string& theNewVarName); - - bool IsVariableUsed(const std::string& theVarName); - - bool FindVariableAttribute(SALOMEDSImpl_StudyBuilder* theStudyBuilder, - SALOMEDSImpl_SObject theSObject, - const std::string& theName); - bool FindVariableAttribute(const std::string& theName); - - void ReplaceVariableAttribute(SALOMEDSImpl_StudyBuilder* theStudyBuilder, - SALOMEDSImpl_SObject theSObject, - const std::string& theSource, - const std::string& theDest); - void ReplaceVariableAttribute(const std::string& theSource, const std::string& theDest); - - std::vector< std::vector > ParseVariables(const std::string& theVariables) const; - //Returns a callback SALOMEDSImpl_Callback* GetCallback() { return _cb; } @@ -314,6 +260,5 @@ public: friend class SALOMEDSImpl_StudyManager; friend class SALOMEDSImpl_GenericAttribute; - friend class SALOMEDSImpl_GenericVariable; }; #endif diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx index cef6ad2b8..8dd76e205 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx @@ -32,7 +32,6 @@ #include "SALOMEDSImpl_Tool.hxx" #include "SALOMEDSImpl_SComponent.hxx" #include "SALOMEDSImpl_GenericAttribute.hxx" -#include "SALOMEDSImpl_ScalarVariable.hxx" #include #include "HDFOI.hxx" @@ -58,7 +57,9 @@ static void ReadAttributes(SALOMEDSImpl_Study*, const SALOMEDSImpl_SObject&, HDF static void BuildTree (SALOMEDSImpl_Study*, HDFgroup*); static void Translate_IOR_to_persistentID (const SALOMEDSImpl_SObject&, SALOMEDSImpl_Driver*, bool isMultiFile, bool isASCII); +/*ASL: static void ReadNoteBookVariables(SALOMEDSImpl_Study* theStudy, HDFgroup* theGroup); +*/ //============================================================================ /*! Function : SALOMEDSImpl_StudyManager @@ -126,7 +127,9 @@ SALOMEDSImpl_Study* SALOMEDSImpl_StudyManager::Open(const string& aUrl) // open the HDFFile HDFfile *hdf_file =0; HDFgroup *hdf_group_study_structure =0; +/*ASL: HDFgroup *hdf_notebook_vars = 0; +*/ char* aC_HDFUrl; string aHDFUrl; @@ -190,12 +193,14 @@ SALOMEDSImpl_Study* SALOMEDSImpl_StudyManager::Open(const string& aUrl) return NULL; } +/*ASL: //Read and create notebook variables if(hdf_file->ExistInternalObject("NOTEBOOK_VARIABLES")) { hdf_notebook_vars = new HDFgroup("NOTEBOOK_VARIABLES",hdf_file); ReadNoteBookVariables(Study,hdf_notebook_vars); hdf_notebook_vars =0; //will be deleted by hdf_sco_group destructor } +*/ hdf_file->CloseOnDisk(); hdf_group_study_structure = new HDFgroup("STUDY_STRUCTURE",hdf_file); @@ -473,8 +478,11 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const string& aStudyUrl, HDFgroup *hdf_group_study_structure =0; HDFgroup *hdf_sco_group =0; HDFgroup *hdf_sco_group2 =0; + + /*ASL: HDFgroup *hdf_notebook_vars =0; HDFgroup *hdf_notebook_var = 0; + */ HDFgroup *hdf_group_datacomponent =0; HDFdataset *hdf_dataset =0; @@ -654,6 +662,8 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const string& aStudyUrl, hdf_soo_group->CloseOnDisk(); hdf_soo_group=0; // will be deleted by hdf_group_study_structure destructor } + + /*ASL //----------------------------------------------------------------------- //5 - Write the NoteBook Variables //----------------------------------------------------------------------- @@ -709,6 +719,8 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const string& aStudyUrl, hdf_notebook_vars = 0; //will be deleted by hdf_sco_group destructor if (aLocked) aStudy->GetProperties()->SetLocked(true); + */ + //----------------------------------------------------------------------- //6 - Write the Study Properties //----------------------------------------------------------------------- @@ -1337,6 +1349,7 @@ static void Translate_IOR_to_persistentID (const SALOMEDSImpl_SObject& so, } } +/*ASL: void ReadNoteBookVariables(SALOMEDSImpl_Study* theStudy, HDFgroup* theGroup) { if(!theGroup) @@ -1419,3 +1432,4 @@ void ReadNoteBookVariables(SALOMEDSImpl_Study* theStudy, HDFgroup* theGroup) theGroup->CloseOnDisk(); } +*/