Salome HOME
Copyright update 2021
[modules/med.git] / src / MEDCalc / cmp / MEDFactoryClient.cxx
1 // Copyright (C) 2007-2021  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 // Author : Guillaume Boulant (EDF)
21
22 #include "MEDFactoryClient.hxx"
23 #include "SALOME_KernelServices.hxx"
24
25 namespace MEDFactoryClient {
26
27   /*!
28    * This returns a singleton (static) instance of the XMED engine.
29    */
30   MEDCALC::MEDFactory_ptr getFactory() {
31     static MEDCALC::MEDFactory_ptr engine;
32     if(CORBA::is_nil(engine)){
33       Engines::EngineComponent_var component =
34         KERNEL::getLifeCycleCORBA()->FindOrLoad_Component( "FactoryServer","MEDFactory" );
35       engine = MEDCALC::MEDFactory::_narrow(component);
36     }
37     return engine;
38   }
39
40   /*!
41    * This returns a singleton (static) instance of the XMED data manager.
42    */
43   MEDCALC::MEDDataManager_ptr getDataManager() {
44     static MEDCALC::MEDDataManager_ptr dataManager;
45     if(CORBA::is_nil(dataManager)){
46       dataManager = getFactory()->getDataManager();
47     }
48     return dataManager;
49   }
50
51   /*!
52    * This returns a singleton (static) instance of the XMED calculator.
53    */
54   MEDCALC::MEDCalculator_ptr getCalculator() {
55     static MEDCALC::MEDCalculator_ptr calculator;
56     if(CORBA::is_nil(calculator)){
57       calculator = getFactory()->getCalculator();
58     }
59     return calculator;
60   }
61
62   /*!
63    * This returns a singleton (static) instance of the MED presentation manager.
64    */
65   MEDCALC::MEDPresentationManager_ptr getPresentationManager() {
66     static MEDCALC::MEDPresentationManager_ptr presentationManager;
67     if(CORBA::is_nil(presentationManager)){
68       presentationManager = getFactory()->getPresentationManager();
69     }
70     return presentationManager;
71   }
72
73   /*!
74    * This returns a singleton (static) instance of the MED commands history.
75    */
76   MEDCALC::MEDCommandsHistoryManager_ptr getCommandsHistoryManager() {
77     static MEDCALC::MEDCommandsHistoryManager_ptr commandsHistoryManager;
78     if(CORBA::is_nil(commandsHistoryManager)){
79       commandsHistoryManager = getFactory()->getCommandsHistoryManager();
80     }
81     return commandsHistoryManager;
82   }
83
84 }