00001 00012 #ifdef HAVE_CONFIG_H 00013 #include "config.h" 00014 #endif 00015 00016 #include "ObserverWrap.h" 00017 00018 #include "pattern/Observable.h" 00019 00020 using std::string; 00021 00022 using namespace boost::python; 00023 00024 namespace hippodraw { 00025 namespace Python { 00026 void 00027 export_Observer () 00028 { 00029 class_ < hippodraw::Observer, ObserverWrap, boost::noncopyable > 00030 ( "Observer", 00031 "The base class for classes that can be targets of Observable\n" 00032 "update messages.", 00033 no_init ) 00034 ; 00035 00036 class_ < Observable, boost::noncopyable > 00037 ( "Observable", 00038 "The base class for classes that can be target of an Observer\n" 00039 "object.", 00040 no_init ) 00041 ; 00042 } 00043 } 00044 } 00045 00046 00047 ObserverWrap:: 00048 ObserverWrap ( PyObject * self ) 00049 : hippodraw::Observer (), 00050 m_self ( self ) 00051 { 00052 } 00053 00056 void 00057 ObserverWrap:: 00058 update ( const Observable * obs ) 00059 { 00060 #ifndef HAVE_OLD_PYTHON 00061 PyGILState_STATE state = PyGILState_Ensure (); 00062 call_method < void, const Observable * > ( m_self, "update", obs ); 00063 PyGILState_Release ( state ); 00064 #endif 00065 }