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