00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef ARIA_wrapper_Functors_h
00028 #define ARIA_wrapper_Functors_h
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #include "ArFunctor.h"
00039
00040
00041
00042 #ifdef SWIGPYTHON
00043 class ArPyFunctor : public ArFunctor
00044 {
00045 protected:
00046 PyObject* pyFunction;
00047 public:
00048 ArPyFunctor(PyObject* _m) : pyFunction(_m) {
00049 Py_INCREF(pyFunction);
00050 }
00051
00052 virtual void invoke() {
00053 PyObject* r = PyObject_CallObject(pyFunction, NULL);
00054 if(!r) {
00055 fputs("** ArPyFunctor: Error calling Python function: ", stderr);
00056 PyErr_Print();
00057 }
00058 }
00059
00060 virtual ~ArPyFunctor() {
00061 Py_DECREF(pyFunction);
00062 }
00063
00064 virtual const char* getName() {
00065 return (const char*) PyString_AsString(PyObject_Str(pyFunction));
00066 }
00067 };
00068
00069
00070 class ArPyRetFunctor_Bool :
00071 public ArRetFunctor<bool>,
00072 public ArPyFunctor
00073 {
00074 public:
00075 ArPyRetFunctor_Bool(PyObject* _m) : ArRetFunctor<bool>(), ArPyFunctor(_m) {
00076 }
00077
00078 virtual bool invokeR() {
00079 PyObject* r = PyObject_CallObject(pyFunction, NULL);
00080 if(!r) {
00081 fputs("** ArPyRetFunctor_Bool: Error calling Python function: ", stderr);
00082 PyErr_Print();
00083 }
00084 return(r == Py_True);
00085 }
00086
00087 virtual const char* getName() {
00088 return (const char*) PyString_AsString(PyObject_Str(pyFunction));
00089 }
00090 };
00091
00092 #endif
00093
00094
00095
00096 class ArRetFunctor_Bool:
00097 public ArRetFunctor<bool>
00098 {
00099 };
00100
00101 #endif // wrapperFunctors.h