Salome HOME
integration modif occ pour ssl
[modules/eficas.git] / src / EFICAS / EFICAS.py
1 # Copyright (C) 2001-2019  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 # -*- coding: utf-8 -*-
20
21 import EFICAS_ORB__POA
22 import SALOMEDS__POA
23 import SALOME_ComponentPy
24 import SALOME_Embedded_NamingService_ClientPy
25
26 class SALOME_DriverPy_i(SALOMEDS__POA.Driver):
27     """
28     Python implementation of generic SALOMEDS driver.
29     Should be inherited by any Python module's engine
30     to provide persistence mechanism.
31     """
32     def __init__ (self, componentDataType):
33         print ("SALOME_DriverPy.__init__: ", componentDataType)
34         self._ComponentDataType = componentDataType
35
36     def IORToLocalPersistentID(self, theSObject, IORString, isMultiFile, isASCII):
37         return theSObject.GetID()
38
39     def LocalPersistentIDToIOR(self, theSObject, PersistentID, isMultiFile, isASCII):
40         return ""
41
42     def ComponentDataType(self):
43         return self._ComponentDataType
44
45     def Save(self, theComponent, theURL, isMultiFile):
46         return 'Rien'
47
48     def SaveASCII(self, theComponent, theURL, isMultiFile):
49         return self.Save(theComponent, theURL, isMultiFile)
50
51     def Load(self, theComponent, theStream, theURL, isMultiFile):
52         return 1
53
54     def LoadASCII(self, theComponent, theStream, theURL, isMultiFile):
55         return self.Load(theComponent, theStream, theURL, isMultiFile)
56
57     def Close(self, theComponent):
58         pass
59
60     def CanPublishInStudy(self, theIOR):
61         return 0
62
63     def PublishInStudy(self, theStudy, theSObject, theObject, theName):
64         return None
65
66     def CanCopy(self, theObject):
67         return 0
68
69
70
71 class EFICAS(EFICAS_ORB__POA.EFICAS_Gen,
72         SALOME_ComponentPy.SALOME_ComponentPy_i,
73         SALOME_DriverPy_i ):
74     """
75         Pour etre un composant SALOME cette classe Python
76         doit avoir le nom du composant et heriter de la
77         classe EFICAS_Gen issue de la compilation de l'idl
78         par omniidl et de la classe SALOME_ComponentPy_i
79         qui porte les services generaux d'un composant SALOME
80     """
81     def __init__ (self, orb, poa, contID, containerName, instanceName, 
82                   interfaceName):
83         print ("EFICAS.__init__: ", containerName,' ', instanceName)
84         SALOME_ComponentPy.SALOME_ComponentPy_i.__init__(self, orb, poa,
85                     contID, containerName,instanceName, interfaceName )
86         SALOME_DriverPy_i.__init__( self, 'OTHER' )                    
87         # On stocke dans l'attribut _naming_service, une reference sur
88         # le Naming Service CORBA
89         #
90         emb_ns = self._contId.get_embedded_NS_if_ssl()
91         import CORBA
92         if CORBA.is_nil(emb_ns):
93             self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb )
94         else:
95             self._naming_service = SALOME_Embedded_NamingService_ClientPy.SALOME_Embedded_NamingService_ClientPy(emb_ns)
96         #