Salome HOME
Rewrite local function ModifySurface of BlockFix_SphereSpaceModifier
[modules/geom.git] / src / GEOM_I / GEOM_Gen_Session_i.cc
1 // Copyright (C) 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 #include "GEOM_Gen_Session_i.hh"
21
22 GEOM_Gen_Session_i::GEOM_Gen_Session_i(CORBA::ORB_ptr orb,
23                         PortableServer::POA_ptr poa,
24                         PortableServer::ObjectId *contId,
25                         const char *instanceName,
26                         const char *interfaceName):GEOM_Gen_i(orb,poa,contId,instanceName,interfaceName,true)
27 {
28     name_service = new SALOME_NamingService(_orb);
29 }
30
31 GEOM_Gen_Session_i::~GEOM_Gen_Session_i()
32 {
33   delete name_service;
34 }
35
36 void GEOM_Gen_Session_i::register_name(char * name)
37 {
38   GEOM::GEOM_Gen_var g = _this();
39   name_service->Register(g, name);
40 }
41
42 SALOMEDS::Study_var GEOM_Gen_Session_i::getStudyServant()
43 {
44   static SALOMEDS::Study_var aStudy;
45   if(CORBA::is_nil(aStudy))
46   {
47     CORBA::Object_ptr anObject = name_service->Resolve("/Study");
48     aStudy = SALOMEDS::Study::_narrow(anObject);
49   }
50   return aStudy;
51 }
52
53 extern "C"
54 {
55   GEOM_I_EXPORT  PortableServer::ObjectId* GEOMEngine_factory(CORBA::ORB_ptr orb,
56                                                PortableServer::POA_ptr       poa,
57                                                PortableServer::ObjectId*     contId,
58                                                const char*                   instanceName,
59                                                const char*                   interfaceName)
60   {
61     GEOM_Gen_Session_i* myGEOM_Gen_i = new GEOM_Gen_Session_i(orb, poa, contId, instanceName, interfaceName);
62     return myGEOM_Gen_i->getId();
63   }
64 }