Salome HOME
updated copyright message
[modules/kernel.git] / src / KernelHelpers / KernelServices.i
1 // Copyright (C) 2021-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 %module KernelServices
21
22 %include "std_string.i"
23
24 %{
25 #include "KernelServices.hxx"
26 #include "Utils_SALOME_Exception.hxx"
27 %}
28
29 %exceptionclass SALOME_Exception;
30
31 class SALOME_Exception
32 {
33 public:
34   SALOME_Exception(const std::string& text);
35   ~SALOME_Exception() noexcept;
36   const char *what() const noexcept;
37   %extend
38   {
39     std::string __str__() const
40     {
41       return std::string(self->what());
42     }
43   }
44 };
45
46 %exception {
47   try {
48     $action
49   }
50   catch (SALOME_Exception& _e) {
51     // Reraise with SWIG_Python_Raise
52     SWIG_Python_Raise(SWIG_NewPointerObj((new SALOME_Exception(static_cast< const SALOME_Exception& >(_e))),SWIGTYPE_p_SALOME_Exception,SWIG_POINTER_OWN), "SALOME_Exception", SWIGTYPE_p_SALOME_Exception);
53     SWIG_fail;
54   }
55 }
56
57 %inline
58 {
59     void RegisterCompoInternal(const std::string& compoName, const std::string& compoIOR);
60     std::string RetrieveCompoInternal(const std::string& compoName);
61     void GenerateViolentMemoryFaultForTestPurpose();
62 }
63
64 %pythoncode %{
65 def RegisterCompo(compoName,compoRef):
66   import CORBA
67   orb=CORBA.ORB_init([''])
68   RegisterCompoInternal(compoName,orb.object_to_string(compoRef))
69
70 def RetrieveCompo(compoName):
71   import CORBA
72   orb=CORBA.ORB_init([''])
73   return orb.string_to_object(RetrieveCompoInternal(compoName))
74 %}