Salome HOME
27779192d6196fcd5e561bf2ed432461d61c2716
[modules/med.git] / src / MEDCalc / cmp / MED_Session.cxx
1 // Copyright (C) 2015-2023  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 #include "MED_Session.hxx"
21
22 MED_Session::MED_Session(CORBA::ORB_ptr orb,
23                         PortableServer::POA_ptr poa,
24                         PortableServer::ObjectId *contId,
25                         const char *instanceName,
26                         const char *interfaceName):MED(orb,poa,contId,instanceName,interfaceName, true)
27 {
28   name_service = new SALOME_NamingService(_orb);
29 }
30
31 MED_Session::~MED_Session()
32 {
33
34 }
35
36 SALOMEDS::Study_var MED_Session::getStudyServant()
37 {
38   static SALOMEDS::Study_var aStudy;
39   if(CORBA::is_nil(aStudy))
40   {
41     CORBA::Object_ptr anObject = name_service->Resolve("/Study");
42     aStudy = SALOMEDS::Study::_narrow(anObject);
43   }
44   return aStudy;
45 }
46
47 #include "MED_No_Session.hxx"
48
49 extern "C"
50 {
51   /*!
52     \brief Exportable factory function: create an instance of the MED component engine
53     \param orb reference to the ORB
54     \param poa reference to the POA
55     \param contId CORBA object ID, pointing to the owner SALOME container
56     \param instanceName SALOME component instance name
57     \param interfaceName SALOME component interface name
58     \return CORBA object identifier of the registered servant
59   */
60   PortableServer::ObjectId* FIELDSEngine_factory(CORBA::ORB_ptr orb,
61                                               PortableServer::POA_ptr poa,
62                                               PortableServer::ObjectId* contId,
63                                               const char* instanceName,
64                                               const char* interfaceName)
65   {
66     CORBA::Object_var o = poa->id_to_reference(*contId);
67                 Engines::Container_var cont = Engines::Container::_narrow(o);
68                 if(cont->is_SSL_mode())
69                 {
70       MED_No_Session* component = new MED_No_Session(orb, poa, contId, instanceName, interfaceName);
71       return component->getId();
72     }
73     else
74     {
75       MED* component = new MED_Session(orb, poa, contId, instanceName, interfaceName);
76       return component->getId();
77     }
78   }
79 }