Salome HOME
PR: merge from BR_DATACONV_PR tag "mergeto_trunk_25oct06"
[modules/yacs.git] / src / runtime / RuntimeSALOME.hxx
1
2 #ifndef _RUNTIMESALOME_HXX_
3 #define _RUNTIMESALOME_HXX_
4
5 #include "Runtime.hxx"
6 #include "CORBAPorts.hxx"
7 #include "PythonPorts.hxx"
8 #include "XMLPorts.hxx"
9 #include "CORBAXMLConv.hxx"
10
11 #include<string>
12 #include<set>
13
14 namespace YACS
15 {
16   namespace ENGINE
17   {
18
19     //--- from omniORBpy.h (not present on Debian Sarge packages)
20     
21     struct omniORBpyAPI
22     {
23       
24       PyObject* (*cxxObjRefToPyObjRef)(const CORBA::Object_ptr cxx_obj,
25                                        CORBA::Boolean hold_lock);
26       // Convert a C++ object reference to a Python object reference.
27       // If <hold_lock> is true, caller holds the Python interpreter lock.
28       
29       CORBA::Object_ptr (*pyObjRefToCxxObjRef)(PyObject* py_obj,
30                                                CORBA::Boolean hold_lock);
31       // Convert a Python object reference to a C++ object reference.
32       // Raises BAD_PARAM if the Python object is not an object reference.
33       // If <hold_lock> is true, caller holds the Python interpreter lock.
34       
35       
36       omniORBpyAPI();
37       // Constructor for the singleton. Sets up the function pointers.
38     };
39     class RuntimeSALOME;
40     RuntimeSALOME* getSALOMERuntime();
41
42     class RuntimeSALOME: public Runtime
43     {
44     public:
45       
46       static void setRuntime(); // singleton creation
47       
48       friend RuntimeSALOME* getSALOMERuntime();
49
50       virtual void init();
51       virtual void fini();
52
53       virtual InputPort* createInputPort(const std::string& name,
54                                          const std::string& impl,
55                                          Node * node,
56                                          TypeCode * type);
57
58       virtual OutputPort* createOutputPort(const std::string& name,
59                                            const std::string& impl,
60                                            Node * node,
61                                            TypeCode * type);
62
63       virtual ElementaryNode* createNode(std::string implementation,
64                                          std::string name ) throw(Exception);
65
66       virtual InputPort* adapt(const std::string& imp_source,
67                                InputPort* source,
68                                const std::string& impl,
69                                TypeCode * type) throw (ConversionException);
70
71       virtual InputPort* adapt(InputCorbaPort* source,
72                                const std::string& impl,
73                                TypeCode * type) throw (ConversionException);
74
75       virtual InputPort* adaptCorbaToCorba(InputCorbaPort* source,
76                                            TypeCode * type) throw (ConversionException);
77
78       virtual InputPort* adaptCorbaToPython(InputCorbaPort* source,
79                                             TypeCode * type) throw (ConversionException);
80
81       virtual InputPort* adaptCorbaToCpp(InputCorbaPort* source,
82                                          TypeCode * type) throw (ConversionException);
83
84       virtual InputPort* adaptCorbaToXml(InputCorbaPort* source,
85                                          TypeCode * type) throw (ConversionException);
86
87       virtual InputPort* adapt(InputPyPort* source,
88                                const std::string& impl,
89                                TypeCode * type) throw (ConversionException);
90
91       virtual InputPort* adaptPythonToCorba(InputPyPort* source,
92                                             TypeCode * type) throw (ConversionException);
93       
94       virtual InputPort* adaptPythonToPython(InputPyPort* source,
95                                              TypeCode * type) throw (ConversionException);
96       
97       virtual InputPort* adaptPythonToCpp(InputPyPort* source,
98                                           TypeCode * type) throw (ConversionException);
99
100       virtual InputPort* adapt(InputXmlPort* source,
101                                const std::string& impl,
102                                TypeCode * type) throw (ConversionException);
103
104       virtual InputPort* adaptXmlToCorba(InputXmlPort* source,
105                                          TypeCode * type) throw (ConversionException);
106
107       CORBA::ORB_ptr getOrb();
108       PyObject * getPyOrb();
109       PyObject * getBuiltins();
110       DynamicAny::DynAnyFactory_ptr getDynFactory();
111       omniORBpyAPI* getApi();
112
113     protected:
114       RuntimeSALOME();  // singleton
115       CORBA::ORB_var _orb;
116       PyObject * _pyorb;
117       PyObject * _bltins;
118       DynamicAny::DynAnyFactory_var _dynFactory;
119       omniORBpyAPI* _api;
120     };
121   }
122 }
123
124 #endif