2 #ifndef _PYTHONPORTS_HXX_
3 #define _PYTHONPORTS_HXX_
7 #include "InputPort.hxx"
8 #include "OutputPort.hxx"
14 class InterpreterUnlocker
17 InterpreterUnlocker() {
18 gstate_ = PyGILState_Ensure();
20 ~InterpreterUnlocker() {
21 PyGILState_Release(gstate_);
24 PyGILState_STATE gstate_;
27 typedef PyObject PyObj;
29 /*! \brief Class for Python Ports
35 class InputPyPort : public InputPort
38 InputPyPort(const std::string& name, Node * node, TypeCode * type);
39 InputPyPort(const InputPyPort& other, Node *newHelder);
41 bool edIsManuallyInitialized() const;
42 void edRemoveManInit();
43 virtual void put(const void *data) throw(ConversionException);
44 void put(PyObject *data) throw(ConversionException);
45 InputPort *clone(Node *newHelder) const;
46 virtual PyObj * getPyObj() const;
47 void *get() const throw(Exception);
48 virtual bool isEmpty();
49 virtual void exSaveInit();
50 virtual void exRestoreInit();
51 virtual std::string dump();
52 virtual std::string typeName() {return "YACS__ENGINE__InputPyPort";}
58 class OutputPyPort : public OutputPort
61 OutputPyPort(const std::string& name, Node * node, TypeCode * type);
62 OutputPyPort(const OutputPyPort& other, Node *newHelder);
64 virtual void put(const void *data) throw(ConversionException);
65 void put(PyObject *data) throw(ConversionException);
66 OutputPort *clone(Node *newHelder) const;
67 virtual PyObject * get() const;
68 virtual PyObj * getPyObj() const;
69 virtual std::string dump();
70 virtual std::string typeName() {return "YACS__ENGINE__OutputPyPort";}