Salome HOME
Copyright update 2022
[modules/gui.git] / src / PVServerService / ENGINE / PVSERVER.py
1 # Copyright (C) 2015-2022  CEA/DEN, EDF R&D, OPEN CASCADE
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 # Author : Adrien BRUNETON (CEA)
20 #
21
22 import PVSERVER_ORB__POA
23 import SALOME_ComponentPy
24 import SALOME_Embedded_NamingService_ClientPy
25 from PVSERVER_impl import PVSERVER_impl, MESSAGE 
26     
27 class PVSERVER(PVSERVER_ORB__POA.PVSERVER_Gen,
28               PVSERVER_impl):
29     """
30     Construct an instance of PVSERVER *service*.
31     The class PVSERVER implements the CORBA interface PVSERVER_Gen (see PVSERVER_Gen.idl).
32     It is NOT inherited from the classes SALOME_ComponentPy_i, as we present
33     the class as a pure CORBA service, not as a standard SALOME component.
34     """
35     def __init__ ( self, orb, poa, contID, containerName, instanceName, 
36                    interfaceName ):
37         
38         
39         PVSERVER_impl.__init__(self)
40         
41         self._orb = orb
42         self._poa = poa
43         self._instanceName = instanceName
44 #         self._interfaceName = interfaceName
45         self._containerName = containerName
46 #         self._contId = contID
47         self._compo_o = None
48
49         emb_ns = contID.get_embedded_NS_if_ssl()
50         import CORBA
51         if CORBA.is_nil(emb_ns):
52             self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb )
53         else:
54             self._naming_service = SALOME_Embedded_NamingService_ClientPy.SALOME_Embedded_NamingService_ClientPy(emb_ns)
55
56         Component_path = self._containerName + "/" + self._instanceName
57         MESSAGE(  'SALOME_ComponentPy_i Register' + str( Component_path ) )
58         id_o = poa.activate_object(self)
59         self._compo_o = poa.id_to_reference(id_o)
60         
61         ## And launch registration
62         ##
63         self._naming_service.Register(self._compo_o, Component_path)
64
65     def getCorbaRef(self):
66         return self._compo_o
67
68     """ Override base class destroy to make sure we try to kill the pvserver
69         before leaving.
70     """
71     def destroy(self):
72         # TODO
73         self.StopPVServer()
74
75