1 // Copyright (C) 2007-2021 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // Author : Guillaume Boulant (EDF)
22 #include <SALOME_KernelServices.hxx>
24 #include "MEDFactoryClient.hxx"
25 #include "MEDFactory_Component_Generator.hxx"
27 namespace MEDFactoryClient {
30 * This returns a singleton (static) instance of the XMED engine.
32 MEDCALC::MEDFactory_ptr getFactory() {
33 static MEDCALC::MEDFactory_ptr engine;
34 if(CORBA::is_nil(engine)){
35 SALOME_NamingService_Abstract *ns = KERNEL::getNamingService();
36 if (dynamic_cast<SALOME_NamingService *>(ns)) {
37 Engines::EngineComponent_var component =
38 KERNEL::getLifeCycleCORBA()->FindOrLoad_Component( "FactoryServer","MEDFactory" );
39 engine = MEDCALC::MEDFactory::_narrow(component);
42 Engines::EngineComponent_var component = RetrieveMEDFactoryInstance();
43 CORBA::Object_var comp2 = CORBA::Object::_narrow(component);
44 KERNEL::RegisterCompo("MEDFactory", comp2);
45 engine = MEDCALC::MEDFactory::_narrow(component);
52 * This returns a singleton (static) instance of the XMED data manager.
54 MEDCALC::MEDDataManager_ptr getDataManager() {
55 static MEDCALC::MEDDataManager_ptr dataManager;
56 if(CORBA::is_nil(dataManager)){
57 dataManager = getFactory()->getDataManager();
63 * This returns a singleton (static) instance of the XMED calculator.
65 MEDCALC::MEDCalculator_ptr getCalculator() {
66 static MEDCALC::MEDCalculator_ptr calculator;
67 if(CORBA::is_nil(calculator)){
68 calculator = getFactory()->getCalculator();
74 * This returns a singleton (static) instance of the MED presentation manager.
76 MEDCALC::MEDPresentationManager_ptr getPresentationManager() {
77 static MEDCALC::MEDPresentationManager_ptr presentationManager;
78 if(CORBA::is_nil(presentationManager)){
79 presentationManager = getFactory()->getPresentationManager();
81 return presentationManager;
85 * This returns a singleton (static) instance of the MED commands history.
87 MEDCALC::MEDCommandsHistoryManager_ptr getCommandsHistoryManager() {
88 static MEDCALC::MEDCommandsHistoryManager_ptr commandsHistoryManager;
89 if(CORBA::is_nil(commandsHistoryManager)){
90 commandsHistoryManager = getFactory()->getCommandsHistoryManager();
92 return commandsHistoryManager;