From: Cédric Aguerre Date: Fri, 24 Jul 2015 17:13:43 +0000 (+0200) Subject: Convenience factory client X-Git-Tag: V8_0_0a1~5^2~36 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=afc69b25b04a2bb6210e92653169d66251369b1e;p=modules%2Fmed.git Convenience factory client --- diff --git a/src/MEDCalc/cmp/CMakeLists.txt b/src/MEDCalc/cmp/CMakeLists.txt index 5e5c8393e..57ed9e3e3 100644 --- a/src/MEDCalc/cmp/CMakeLists.txt +++ b/src/MEDCalc/cmp/CMakeLists.txt @@ -33,6 +33,7 @@ INCLUDE_DIRECTORIES( ) SET(MEDFactoryEngine_SOURCES + MEDFactoryClient.cxx MEDDataManager_i.cxx MEDCalculator_i.cxx MEDPresentationManager_i.cxx diff --git a/src/MEDCalc/cmp/MEDFactoryClient.cxx b/src/MEDCalc/cmp/MEDFactoryClient.cxx new file mode 100644 index 000000000..d417e5936 --- /dev/null +++ b/src/MEDCalc/cmp/MEDFactoryClient.cxx @@ -0,0 +1,61 @@ +// Copyright (C) 2007-2015 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 : Guillaume Boulant (EDF) + +#include "MEDFactoryClient.hxx" +#include "SALOME_KernelServices.hxx" + +namespace MEDFactoryClient { + + /*! + * This returns a singleton (static) instance of the XMED engine. + */ + MEDCALC::MEDFactory_ptr getFactory() { + static MEDCALC::MEDFactory_ptr engine; + if(CORBA::is_nil(engine)){ + Engines::EngineComponent_var component = + KERNEL::getLifeCycleCORBA()->FindOrLoad_Component( "FactoryServer","MEDFactory" ); + engine = MEDCALC::MEDFactory::_narrow(component); + } + return engine; + } + + /*! + * This returns a singleton (static) instance of the XMED data manager. + */ + MEDCALC::MEDDataManager_ptr getDataManager() { + static MEDCALC::MEDDataManager_ptr dataManager; + if(CORBA::is_nil(dataManager)){ + dataManager = getFactory()->getDataManager(); + } + return dataManager; + } + + /*! + * This returns a singleton (static) instance of the XMED calculator. + */ + MEDCALC::MEDCalculator_ptr getCalculator() { + static MEDCALC::MEDCalculator_ptr calculator; + if(CORBA::is_nil(calculator)){ + calculator = getFactory()->getCalculator(); + } + return calculator; + } +} diff --git a/src/MEDCalc/cmp/MEDFactoryClient.hxx b/src/MEDCalc/cmp/MEDFactoryClient.hxx new file mode 100644 index 000000000..054f869be --- /dev/null +++ b/src/MEDCalc/cmp/MEDFactoryClient.hxx @@ -0,0 +1,44 @@ +// Copyright (C) 2007-2015 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 : Guillaume Boulant (EDF) + +#ifndef _MEDFACTORY_CLIENT_HXX_ +#define _MEDFACTORY_CLIENT_HXX_ + + +#include +#include CORBA_CLIENT_HEADER(MEDFactory) +#include CORBA_CLIENT_HEADER(MEDDataManager) +#include CORBA_CLIENT_HEADER(MEDCalculator) + +#include "MEDCALC.hxx" + +// This helper manages static variables binded on main objects of the +// XMED context, so that they could be initialized once and shared in +// the whole gui context. It prevents to defined an attribute in each +// class while this instance are singleton instances. + +namespace MEDFactoryClient { + MEDCALC_EXPORT MEDCALC::MEDFactory_ptr getFactory(); + MEDCALC_EXPORT MEDCALC::MEDDataManager_ptr getDataManager(); + MEDCALC_EXPORT MEDCALC::MEDCalculator_ptr getCalculator(); +} + +#endif // _MEDFACTORY_CLIENT_HXX_ diff --git a/src/MEDCalc/cmp/MEDPresentationManager_i.cxx b/src/MEDCalc/cmp/MEDPresentationManager_i.cxx index 62ea2280d..eb0be04fd 100644 --- a/src/MEDCalc/cmp/MEDPresentationManager_i.cxx +++ b/src/MEDCalc/cmp/MEDPresentationManager_i.cxx @@ -18,6 +18,7 @@ // #include "MEDPresentationManager_i.hxx" +#include "MEDFactoryClient.hxx" MEDPresentationManager_i* MEDPresentationManager_i::_instance = NULL; @@ -50,4 +51,13 @@ void MEDPresentationManager_i::MakeScalarMap(const MEDCALC::ScalarMapParameters& params) { std::cout << "MEDPresentationManager_i::MakeScalarMap: Not implemented yet\n"; + + std::size_t fieldHandlerId = params.fieldHandlerId; + MEDCALC::MEDPresentationViewMode viewMode = params.viewMode; + + std::cout << "\tfieldHandlerId: " << fieldHandlerId << std::endl; + std::cout << "\tviewMode: " << viewMode << std::endl; + + MEDCALC::FieldHandler* fieldHandler = MEDFactoryClient::getDataManager()->getFieldHandler(fieldHandlerId); + } diff --git a/src/MEDCalc/gui/CMakeLists.txt b/src/MEDCalc/gui/CMakeLists.txt index 953911727..4b5cad36d 100644 --- a/src/MEDCalc/gui/CMakeLists.txt +++ b/src/MEDCalc/gui/CMakeLists.txt @@ -26,7 +26,6 @@ ADD_SUBDIRECTORY(dialogs) SET(MEDCALCGUI_SOURCES - MEDFactoryClient.cxx XmedConsoleDriver.cxx WorkspaceController.cxx XmedDataModel.cxx diff --git a/src/MEDCalc/gui/MEDFactoryClient.cxx b/src/MEDCalc/gui/MEDFactoryClient.cxx deleted file mode 100644 index d417e5936..000000000 --- a/src/MEDCalc/gui/MEDFactoryClient.cxx +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2007-2015 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 : Guillaume Boulant (EDF) - -#include "MEDFactoryClient.hxx" -#include "SALOME_KernelServices.hxx" - -namespace MEDFactoryClient { - - /*! - * This returns a singleton (static) instance of the XMED engine. - */ - MEDCALC::MEDFactory_ptr getFactory() { - static MEDCALC::MEDFactory_ptr engine; - if(CORBA::is_nil(engine)){ - Engines::EngineComponent_var component = - KERNEL::getLifeCycleCORBA()->FindOrLoad_Component( "FactoryServer","MEDFactory" ); - engine = MEDCALC::MEDFactory::_narrow(component); - } - return engine; - } - - /*! - * This returns a singleton (static) instance of the XMED data manager. - */ - MEDCALC::MEDDataManager_ptr getDataManager() { - static MEDCALC::MEDDataManager_ptr dataManager; - if(CORBA::is_nil(dataManager)){ - dataManager = getFactory()->getDataManager(); - } - return dataManager; - } - - /*! - * This returns a singleton (static) instance of the XMED calculator. - */ - MEDCALC::MEDCalculator_ptr getCalculator() { - static MEDCALC::MEDCalculator_ptr calculator; - if(CORBA::is_nil(calculator)){ - calculator = getFactory()->getCalculator(); - } - return calculator; - } -} diff --git a/src/MEDCalc/gui/MEDFactoryClient.hxx b/src/MEDCalc/gui/MEDFactoryClient.hxx deleted file mode 100644 index 62a6de5fb..000000000 --- a/src/MEDCalc/gui/MEDFactoryClient.hxx +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2007-2015 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 : Guillaume Boulant (EDF) - -#ifndef _MEDFACTORY_CLIENT_HXX_ -#define _MEDFACTORY_CLIENT_HXX_ - - -#include -#include CORBA_CLIENT_HEADER(MEDFactory) -#include CORBA_CLIENT_HEADER(MEDDataManager) -#include CORBA_CLIENT_HEADER(MEDCalculator) - -#include "MEDCALCGUI.hxx" - -// This helper manages static variables binded on main objects of the -// XMED context, so that they could be initialized once and shared in -// the whole gui context. It prevents to defined an attribute in each -// class while this instance are singleton instances. - -namespace MEDFactoryClient { - MEDCALCGUI_EXPORT MEDCALC::MEDFactory_ptr getFactory(); - MEDCALCGUI_EXPORT MEDCALC::MEDDataManager_ptr getDataManager(); - MEDCALCGUI_EXPORT MEDCALC::MEDCalculator_ptr getCalculator(); -} - -#endif // _MEDFACTORY_CLIENT_HXX_