From fc62656d119a7301ab340d2b5a84f4db48c5581f Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Mon, 27 Oct 2014 13:39:19 +0100 Subject: [PATCH] First version before plugging. --- idl/CMakeLists.txt | 1 + idl/SALOME_SDS.idl | 54 +++++++++++ src/CMakeLists.txt | 1 + src/SALOMESDS/CMakeLists.txt | 47 ++++++++++ src/SALOMESDS/SALOMESDS_AnyDataServer.cxx | 44 +++++++++ src/SALOMESDS/SALOMESDS_AnyDataServer.hxx | 42 +++++++++ src/SALOMESDS/SALOMESDS_AutoRefCountPtr.hxx | 78 ++++++++++++++++ src/SALOMESDS/SALOMESDS_BasicDataServer.cxx | 35 +++++++ src/SALOMESDS/SALOMESDS_BasicDataServer.hxx | 46 ++++++++++ src/SALOMESDS/SALOMESDS_DataScopeServer.cxx | 91 +++++++++++++++++++ src/SALOMESDS/SALOMESDS_DataScopeServer.hxx | 53 +++++++++++ src/SALOMESDS/SALOMESDS_DataServerManager.cxx | 45 +++++++++ src/SALOMESDS/SALOMESDS_DataServerManager.hxx | 51 +++++++++++ src/SALOMESDS/SALOMESDS_Exception.cxx | 34 +++++++ src/SALOMESDS/SALOMESDS_Exception.hxx | 40 ++++++++ src/SALOMESDS/SALOMESDS_RefCountServ.cxx | 52 +++++++++++ src/SALOMESDS/SALOMESDS_RefCountServ.hxx | 42 +++++++++ src/SALOMESDS/SALOMESDS_StringDataServer.cxx | 43 +++++++++ src/SALOMESDS/SALOMESDS_StringDataServer.hxx | 42 +++++++++ 19 files changed, 841 insertions(+) create mode 100644 idl/SALOME_SDS.idl create mode 100644 src/SALOMESDS/CMakeLists.txt create mode 100644 src/SALOMESDS/SALOMESDS_AnyDataServer.cxx create mode 100644 src/SALOMESDS/SALOMESDS_AnyDataServer.hxx create mode 100644 src/SALOMESDS/SALOMESDS_AutoRefCountPtr.hxx create mode 100644 src/SALOMESDS/SALOMESDS_BasicDataServer.cxx create mode 100644 src/SALOMESDS/SALOMESDS_BasicDataServer.hxx create mode 100644 src/SALOMESDS/SALOMESDS_DataScopeServer.cxx create mode 100644 src/SALOMESDS/SALOMESDS_DataScopeServer.hxx create mode 100644 src/SALOMESDS/SALOMESDS_DataServerManager.cxx create mode 100644 src/SALOMESDS/SALOMESDS_DataServerManager.hxx create mode 100644 src/SALOMESDS/SALOMESDS_Exception.cxx create mode 100644 src/SALOMESDS/SALOMESDS_Exception.hxx create mode 100644 src/SALOMESDS/SALOMESDS_RefCountServ.cxx create mode 100644 src/SALOMESDS/SALOMESDS_RefCountServ.hxx create mode 100644 src/SALOMESDS/SALOMESDS_StringDataServer.cxx create mode 100644 src/SALOMESDS/SALOMESDS_StringDataServer.hxx diff --git a/idl/CMakeLists.txt b/idl/CMakeLists.txt index 894de4afa..b69a9bd1e 100755 --- a/idl/CMakeLists.txt +++ b/idl/CMakeLists.txt @@ -36,6 +36,7 @@ SET(SalomeIDLKernel_IDLSOURCES SALOMEDS_Attributes.idl SALOME_Component.idl SALOME_ContainerManager.idl + SALOME_SDS.idl SALOME_Registry.idl Logger.idl SALOME_GenericObj.idl diff --git a/idl/SALOME_SDS.idl b/idl/SALOME_SDS.idl new file mode 100644 index 000000000..a9bcab6c9 --- /dev/null +++ b/idl/SALOME_SDS.idl @@ -0,0 +1,54 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, or (at your option) any later version. +// +// 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 +// +// Author : Anthony GEAY (EDF R&D) + +module SALOME +{ + interface BasicDataServer + { + string getVarName(); + }; + + interface StringDataServer : BasicDataServer + { + void setValueOf(in string newValue); + string getValueOf(); + }; + + interface AnyDataServer : BasicDataServer + { + void setValueOf(in any newValue); + any getValueOf(); + }; + + interface DataScopeServer + { + string getScopeName(); + StringDataServer createGlobalStringVar(in string varName); + AnyDataServer createGlobalAnyVar(in string varName); + }; + + interface DataServerManager + { + DataScopeServer getDefaultScope(); + DataScopeServer createDataScope(in string scopeName); + DataScopeServer retriveDataScope(in string scopeName); + DataScopeServer removeDataScope(in string scopeName); + }; +}; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8ea2b8ca1..e6d0a1c34 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -37,6 +37,7 @@ SET(SUBDIR_CORBA Notification NOTIFICATION_SWIG Container + SALOMESDS TestContainer Launcher LifeCycleCORBA diff --git a/src/SALOMESDS/CMakeLists.txt b/src/SALOMESDS/CMakeLists.txt new file mode 100644 index 000000000..fa3169c1e --- /dev/null +++ b/src/SALOMESDS/CMakeLists.txt @@ -0,0 +1,47 @@ +# Copyright (C) 2012-2014 CEA/DEN, EDF R&D, OPEN CASCADE +# +# 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, or (at your option) any later version. +# +# 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 +# +# + +INCLUDE_DIRECTORIES( + ${OMNIORB_INCLUDE_DIR} + ${PTHREAD_INCLUDE_DIR} + ${PROJECT_BINARY_DIR}/idl +) + +ADD_DEFINITIONS(${OMNIORB_DEFINITIONS}) + +SET(COMMON_LIBS SalomeIDLKernel ${OMNIORB_LIBRARIES}) + +SET(SalomeSDS_SOURCES + SALOMESDS_Exception.cxx + SALOMESDS_RefCountServ.cxx + SALOMESDS_AnyDataServer.cxx + SALOMESDS_BasicDataServer.cxx + SALOMESDS_DataScopeServer.cxx + SALOMESDS_DataServerManager.cxx + SALOMESDS_StringDataServer.cxx + ) + +ADD_LIBRARY(SalomeSDS ${SalomeSDS_SOURCES}) +TARGET_LINK_LIBRARIES(SalomeSDS ${COMMON_LIBS} ${PTHREAD_LIBRARIES}) +INSTALL(TARGETS SalomeSDS EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +FILE(GLOB COMMON_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx") + +INSTALL(FILES ${COMMON_HEADERS_HXX} DESTINATION ${SALOME_INSTALL_HEADERS}) diff --git a/src/SALOMESDS/SALOMESDS_AnyDataServer.cxx b/src/SALOMESDS/SALOMESDS_AnyDataServer.cxx new file mode 100644 index 000000000..0cc049f2e --- /dev/null +++ b/src/SALOMESDS/SALOMESDS_AnyDataServer.cxx @@ -0,0 +1,44 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, or (at your option) any later version. +// +// 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 +// +// Author : Anthony GEAY (EDF R&D) + +#include "SALOMESDS_AnyDataServer.hxx" + +using namespace SALOMESDS; + +AnyDataServer::AnyDataServer(const std::string& varName):BasicDataServer(varName),_data(new CORBA::Any) +{ +} + +/*! + * Called remotely -> to protect against throw + */ +void AnyDataServer::setValueOf(const CORBA::Any& newValue) +{ + delete _data; + _data=new CORBA::Any(newValue); +} + +/*! + * Called remotely -> to protect against throw + */ +CORBA::Any *AnyDataServer::getValueOf() +{ + return new CORBA::Any(*_data); +} diff --git a/src/SALOMESDS/SALOMESDS_AnyDataServer.hxx b/src/SALOMESDS/SALOMESDS_AnyDataServer.hxx new file mode 100644 index 000000000..c535357af --- /dev/null +++ b/src/SALOMESDS/SALOMESDS_AnyDataServer.hxx @@ -0,0 +1,42 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, or (at your option) any later version. +// +// 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 +// +// Author : Anthony GEAY (EDF R&D) + +#ifndef __SALOMESDS_ANYDATASERVER_HXX__ +#define __SALOMESDS_ANYDATASERVER_HXX__ + +#include "SALOMESDS_BasicDataServer.hxx" + +#include "SALOME_SDS.hh" +//#include CORBA_SERVER_HEADER(SALOME_SDS) + +namespace SALOMESDS +{ + class AnyDataServer : public BasicDataServer, public virtual POA_SALOME::AnyDataServer + { + public: + AnyDataServer(const std::string& varName); + void setValueOf(const CORBA::Any& newValue); + CORBA::Any *getValueOf(); + private: + CORBA::Any *_data; + }; +} + +#endif diff --git a/src/SALOMESDS/SALOMESDS_AutoRefCountPtr.hxx b/src/SALOMESDS/SALOMESDS_AutoRefCountPtr.hxx new file mode 100644 index 000000000..021b115dd --- /dev/null +++ b/src/SALOMESDS/SALOMESDS_AutoRefCountPtr.hxx @@ -0,0 +1,78 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D +// +// 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, or (at your option) any later version. +// +// 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 +// +// Author : Anthony Geay (EDF R&D) + +#ifndef __SALOMESDS_AUTOREFCOUNTPTR_HXX__ +#define __SALOMESDS_AUTOREFCOUNTPTR_HXX__ + +#include "SALOMESDS_Exception.hxx" + +namespace SALOMESDS +{ + template + class AutoRefCountPtr + { + public: + AutoRefCountPtr(const AutoRefCountPtr& other):_ptr(0) { referPtr(other._ptr); } + AutoRefCountPtr(T *ptr=0):_ptr(ptr) { } + ~AutoRefCountPtr() { destroyPtr(); } + bool operator==(const AutoRefCountPtr& other) const { return _ptr==other._ptr; } + bool operator==(const T *other) const { return _ptr==other; } + AutoRefCountPtr &operator=(const AutoRefCountPtr& other) { if(_ptr!=other._ptr) { destroyPtr(); referPtr(other._ptr); } return *this; } + AutoRefCountPtr &operator=(T *ptr) { if(_ptr!=ptr) { destroyPtr(); _ptr=ptr; } return *this; } + T *operator->() { return _ptr ; } + const T *operator->() const { return _ptr; } + T& operator*() { return *_ptr; } + const T& operator*() const { return *_ptr; } + operator T *() { return _ptr; } + operator const T *() const { return _ptr; } + T *retn() { if(_ptr) _ptr->incrRef(); return _ptr; } + private: + void referPtr(T *ptr) { _ptr=ptr; if(_ptr) _ptr->incrRef(); } + void destroyPtr() { if(_ptr) _ptr->decrRef(); } + private: + T *_ptr; + }; + + template + typename SALOMESDS::AutoRefCountPtr DynamicCast(typename SALOMESDS::AutoRefCountPtr& autoSubPtr) throw() + { + T *subPtr(autoSubPtr); + U *ptr(dynamic_cast(subPtr)); + typename SALOMESDS::AutoRefCountPtr ret(ptr); + if(ptr) + ptr->incrRef(); + return ret; + } + + template + typename SALOMESDS::AutoRefCountPtr DynamicCastSafe(typename SALOMESDS::AutoRefCountPtr& autoSubPtr) + { + T *subPtr(autoSubPtr); + U *ptr(dynamic_cast(subPtr)); + if(subPtr && !ptr) + throw Exception("DynamicCastSafe : U is not a subtype of T !"); + typename SALOMESDS::AutoRefCountPtr ret(ptr); + if(ptr) + ptr->incrRef(); + return ret; + } +} + +#endif diff --git a/src/SALOMESDS/SALOMESDS_BasicDataServer.cxx b/src/SALOMESDS/SALOMESDS_BasicDataServer.cxx new file mode 100644 index 000000000..1477629f8 --- /dev/null +++ b/src/SALOMESDS/SALOMESDS_BasicDataServer.cxx @@ -0,0 +1,35 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, or (at your option) any later version. +// +// 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 +// +// Author : Anthony GEAY (EDF R&D) + +#include "SALOMESDS_BasicDataServer.hxx" +#include "SALOMESDS_Exception.hxx" + +#include + +using namespace SALOMESDS; + +BasicDataServer::BasicDataServer(const std::string& varName):_var_name(varName) +{ +} + +char *BasicDataServer::getVarName() +{ + return CORBA::string_dup(_var_name.c_str()); +} diff --git a/src/SALOMESDS/SALOMESDS_BasicDataServer.hxx b/src/SALOMESDS/SALOMESDS_BasicDataServer.hxx new file mode 100644 index 000000000..6ff19db73 --- /dev/null +++ b/src/SALOMESDS/SALOMESDS_BasicDataServer.hxx @@ -0,0 +1,46 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, or (at your option) any later version. +// +// 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 +// +// Author : Anthony GEAY (EDF R&D) + +#ifndef __SALOMESDS_BASICDATASERVER_HXX__ +#define __SALOMESDS_BASICDATASERVER_HXX__ + +#include "SALOMESDS_AutoRefCountPtr.hxx" + +#include "SALOME_SDS.hh" +//#include CORBA_SERVER_HEADER(SALOME_SDS) + +#include "SALOMESDS_RefCountServ.hxx" + +#include + +namespace SALOMESDS +{ + class BasicDataServer : public RefCountServ, public virtual POA_SALOME::BasicDataServer + { + public: + BasicDataServer(const std::string& varName); + char *getVarName(); + std::string getVarNameCpp() const { return _var_name; } + private: + std::string _var_name; + }; +} + +#endif diff --git a/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx b/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx new file mode 100644 index 000000000..969501947 --- /dev/null +++ b/src/SALOMESDS/SALOMESDS_DataScopeServer.cxx @@ -0,0 +1,91 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, or (at your option) any later version. +// +// 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 +// +// Author : Anthony GEAY (EDF R&D) + +#include "SALOMESDS_DataScopeServer.hxx" +#include "SALOMESDS_StringDataServer.hxx" +#include "SALOMESDS_AnyDataServer.hxx" +#include "SALOMESDS_Exception.hxx" + +#include +#include + +using namespace SALOMESDS; + +DataScopeServer::DataScopeServer(const std::string& scopeName):_name(scopeName) +{ +} + +DataScopeServer::DataScopeServer(const DataScopeServer& other):RefCountServ(other),_name(other._name),_vars(other._vars) +{ +} + +/*! + * Called remotely -> to protect against throw + */ +char *DataScopeServer::getScopeName() +{ + return CORBA::string_dup(_name.c_str()); +} + +/*! + * Called remotely -> to protect against throw + */ +SALOME::StringDataServer_ptr DataScopeServer::createGlobalStringVar(const char *varName) +{ + std::string varNameCpp(varName); + std::vector allNames(getAllVarNames()); + std::vector::iterator it(std::find(allNames.begin(),allNames.end(),varNameCpp)); + if(it!=allNames.end()) + { + std::ostringstream oss; oss << "DataScopeServer::createGlobalStringVar : name \"" << varNameCpp << "\" already exists !"; + throw Exception(oss.str()); + } + AutoRefCountPtr tmp(new StringDataServer(varNameCpp)); + _vars.push_back(DynamicCastSafe(tmp)); + return tmp->_this(); +} + +/*! + * Called remotely -> to protect against throw + */ +SALOME::AnyDataServer_ptr DataScopeServer::createGlobalAnyVar(const char *varName) +{ + std::string varNameCpp(varName); + std::vector allNames(getAllVarNames()); + std::vector::iterator it(std::find(allNames.begin(),allNames.end(),varNameCpp)); + if(it!=allNames.end()) + { + std::ostringstream oss; oss << "DataScopeServer::createGlobalAnyVar : name \"" << varNameCpp << "\" already exists !"; + throw Exception(oss.str()); + } + AutoRefCountPtr tmp(new AnyDataServer(varNameCpp)); + _vars.push_back(DynamicCastSafe(tmp)); + return tmp->_this(); +} + +std::vector< std::string > DataScopeServer::getAllVarNames() const +{ + std::size_t sz(_vars.size()); + std::vector ret(sz); + std::list< AutoRefCountPtr >::const_iterator it(_vars.begin()); + for(std::size_t i=0;igetVarNameCpp(); + return ret; +} diff --git a/src/SALOMESDS/SALOMESDS_DataScopeServer.hxx b/src/SALOMESDS/SALOMESDS_DataScopeServer.hxx new file mode 100644 index 000000000..030b17989 --- /dev/null +++ b/src/SALOMESDS/SALOMESDS_DataScopeServer.hxx @@ -0,0 +1,53 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, or (at your option) any later version. +// +// 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 +// +// Author : Anthony GEAY (EDF R&D) + +#ifndef __SALOMESDS_DATASCOPEERVER_HXX__ +#define __SALOMESDS_DATASCOPEERVER_HXX__ + +#include "SALOME_SDS.hh" +//#include CORBA_SERVER_HEADER(SALOME_SDS) + +#include "SALOMESDS_AutoRefCountPtr.hxx" +#include "SALOMESDS_RefCountServ.hxx" +#include "SALOMESDS_BasicDataServer.hxx" + +#include +#include +#include + +namespace SALOMESDS +{ + class DataScopeServer : public RefCountServ, public virtual POA_SALOME::DataScopeServer + { + public: + DataScopeServer(const std::string& scopeName); + DataScopeServer(const DataScopeServer& other); + char *getScopeName(); + SALOME::StringDataServer_ptr createGlobalStringVar(const char *varName); + SALOME::AnyDataServer_ptr createGlobalAnyVar(const char *varName); + private: + std::vector< std::string> getAllVarNames() const; + private: + std::string _name; + std::list< AutoRefCountPtr > _vars; + }; +} + +#endif diff --git a/src/SALOMESDS/SALOMESDS_DataServerManager.cxx b/src/SALOMESDS/SALOMESDS_DataServerManager.cxx new file mode 100644 index 000000000..993158969 --- /dev/null +++ b/src/SALOMESDS/SALOMESDS_DataServerManager.cxx @@ -0,0 +1,45 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, or (at your option) any later version. +// +// 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 +// +// Author : Anthony GEAY (EDF R&D) + +#include "SALOMESDS_DataServerManager.hxx" +#include "SALOMESDS_Exception.hxx" + +using namespace SALOMESDS; + +DataServerManager::DataServerManager():_dft_scope(new DataScopeServer("")) +{ +} + +SALOME::DataScopeServer_ptr DataServerManager::getDefaultScope() +{ + +} + +SALOME::DataScopeServer_ptr DataServerManager::createDataScope(const char *scopeName) +{ +} + +SALOME::DataScopeServer_ptr DataServerManager::retriveDataScope(const char *scopeName) +{ +} + +SALOME::DataScopeServer_ptr DataServerManager::removeDataScope(const char *scopeName) +{ +} diff --git a/src/SALOMESDS/SALOMESDS_DataServerManager.hxx b/src/SALOMESDS/SALOMESDS_DataServerManager.hxx new file mode 100644 index 000000000..d0629c75b --- /dev/null +++ b/src/SALOMESDS/SALOMESDS_DataServerManager.hxx @@ -0,0 +1,51 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, or (at your option) any later version. +// +// 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 +// +// Author : Anthony GEAY (EDF R&D) + +#ifndef __SALOMESDS_DATASERVERMANAGER_HXX__ +#define __SALOMESDS_DATASERVERMANAGER_HXX__ + +#include "SALOME_SDS.hh" +//#include CORBA_SERVER_HEADER(SALOME_SDS) + +#include "SALOMESDS_AutoRefCountPtr.hxx" +#include "SALOMESDS_DataScopeServer.hxx" + +#include +#include + +namespace SALOMESDS +{ + class DataScopeServer; + + class DataServerManager : public virtual POA_SALOME::DataServerManager + { + public: + DataServerManager(); + SALOME::DataScopeServer_ptr getDefaultScope(); + SALOME::DataScopeServer_ptr createDataScope(const char *scopeName); + SALOME::DataScopeServer_ptr retriveDataScope(const char *scopeName); + SALOME::DataScopeServer_ptr removeDataScope(const char *scopeName); + private: + AutoRefCountPtr _dft_scope; + std::list< AutoRefCountPtr > _scopes; + }; +} + +#endif diff --git a/src/SALOMESDS/SALOMESDS_Exception.cxx b/src/SALOMESDS/SALOMESDS_Exception.cxx new file mode 100644 index 000000000..fd3d8e199 --- /dev/null +++ b/src/SALOMESDS/SALOMESDS_Exception.cxx @@ -0,0 +1,34 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, or (at your option) any later version. +// +// 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 +// +// Author : Anthony GEAY (EDF R&D) + +#include "SALOMESDS_Exception.hxx" + +SALOMESDS::Exception::Exception(const std::string& reason):_reason(reason) +{ +} + +SALOMESDS::Exception::~Exception() throw () +{ +} + +const char *SALOMESDS::Exception::what() const throw() +{ + return _reason.c_str(); +} diff --git a/src/SALOMESDS/SALOMESDS_Exception.hxx b/src/SALOMESDS/SALOMESDS_Exception.hxx new file mode 100644 index 000000000..2299c2233 --- /dev/null +++ b/src/SALOMESDS/SALOMESDS_Exception.hxx @@ -0,0 +1,40 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, or (at your option) any later version. +// +// 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 +// +// Author : Anthony GEAY (EDF R&D) + +#ifndef __SALOMESDS_EXCEPTION_HXX__ +#define __SALOMESDS_EXCEPTION_HXX__ + +#include +#include + +namespace SALOMESDS +{ + class Exception : public std::exception + { + public: + Exception(const std::string& reason); + ~Exception() throw (); + const char *what() const throw(); + protected: + std::string _reason; + }; +} + +#endif diff --git a/src/SALOMESDS/SALOMESDS_RefCountServ.cxx b/src/SALOMESDS/SALOMESDS_RefCountServ.cxx new file mode 100644 index 000000000..ca572817f --- /dev/null +++ b/src/SALOMESDS/SALOMESDS_RefCountServ.cxx @@ -0,0 +1,52 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, or (at your option) any later version. +// +// 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 +// +// Author : Anthony GEAY (EDF R&D) + +#include "SALOMESDS_RefCountServ.hxx" + +using namespace SALOMESDS; + +void RefCountServ::incrRef() const +{ + _cnt++; +} + +bool RefCountServ::decrRef() const +{ + bool ret((--_cnt)==0); + if(ret) + { + PortableServer::ObjectId_var oid = (const_cast(this))->_default_POA()->servant_to_id(const_cast(this)); + (const_cast(this))->_default_POA()->deactivate_object(oid); + (const_cast(this))->_remove_ref(); + } + return ret; +} + +RefCountServ::RefCountServ():_cnt(1) +{ +} + +RefCountServ::RefCountServ(const RefCountServ& other):_cnt(1) +{ +} + +RefCountServ::~RefCountServ() +{ +} diff --git a/src/SALOMESDS/SALOMESDS_RefCountServ.hxx b/src/SALOMESDS/SALOMESDS_RefCountServ.hxx new file mode 100644 index 000000000..56582e3ad --- /dev/null +++ b/src/SALOMESDS/SALOMESDS_RefCountServ.hxx @@ -0,0 +1,42 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, or (at your option) any later version. +// +// 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 +// +// Author : Anthony GEAY (EDF R&D) + +#ifndef __SALOMESDS_REFCOUNTSERV_HXX__ +#define __SALOMESDS_REFCOUNTSERV_HXX__ + +#include + +namespace SALOMESDS +{ + class RefCountServ : public virtual PortableServer::ServantBase + { + public: + void incrRef() const; + bool decrRef() const; + protected: + RefCountServ(); + RefCountServ(const RefCountServ& other); + virtual ~RefCountServ(); + private: + mutable unsigned int _cnt; + }; +} + +#endif diff --git a/src/SALOMESDS/SALOMESDS_StringDataServer.cxx b/src/SALOMESDS/SALOMESDS_StringDataServer.cxx new file mode 100644 index 000000000..9583d7677 --- /dev/null +++ b/src/SALOMESDS/SALOMESDS_StringDataServer.cxx @@ -0,0 +1,43 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, or (at your option) any later version. +// +// 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 +// +// Author : Anthony GEAY (EDF R&D) + +#include "SALOMESDS_StringDataServer.hxx" + +using namespace SALOMESDS; + +StringDataServer::StringDataServer(const std::string& varName):BasicDataServer(varName) +{ +} + +/*! + * Called remotely -> to protect against throw + */ +void StringDataServer::setValueOf(const char *newValue) +{ + _data=newValue; +} + +/*! + * Called remotely -> to protect against throw + */ +char *StringDataServer::getValueOf() +{ + return CORBA::string_dup(_data.c_str()); +} diff --git a/src/SALOMESDS/SALOMESDS_StringDataServer.hxx b/src/SALOMESDS/SALOMESDS_StringDataServer.hxx new file mode 100644 index 000000000..7b054f4a0 --- /dev/null +++ b/src/SALOMESDS/SALOMESDS_StringDataServer.hxx @@ -0,0 +1,42 @@ +// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +// +// 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, or (at your option) any later version. +// +// 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 +// +// Author : Anthony GEAY (EDF R&D) + +#ifndef __SALOMESDS_STRINGDATASERVER_HXX__ +#define __SALOMESDS_STRINGDATASERVER_HXX__ + +#include "SALOMESDS_BasicDataServer.hxx" + +#include "SALOME_SDS.hh" +//#include CORBA_SERVER_HEADER(SALOME_SDS) + +namespace SALOMESDS +{ + class StringDataServer : public BasicDataServer, public virtual POA_SALOME::StringDataServer + { + public: + StringDataServer(const std::string& varName); + void setValueOf(const char *newValue); + char *getValueOf(); + private: + std::string _data; + }; +} + +#endif -- 2.39.2