TRflxCallback.cxx

Go to the documentation of this file.
00001 #ifdef PYROOT_USE_REFLEX
00002 
00003 // Bindings
00004 #include "PyROOT.h"
00005 #include "TRflxCallback.h"
00006 #include "RootWrapper.h"
00007 
00008 // ROOT
00009 #include "Reflex/Base.h"
00010 #include "Reflex/Member.h"
00011 #include "Reflex/Scope.h"
00012 #include "Reflex/Type.h"
00013 
00014 
00015 //- data ---------------------------------------------------------------------
00016 std::auto_ptr< ROOT::Reflex::ICallback > PyROOT::TRflxCallback::gCallback;
00017 
00018 
00019 //- static methods -----------------------------------------------------------
00020 PyObject* PyROOT::TRflxCallback::Enable()
00021 {
00022 // Setup callback to receive Reflex notification of new types
00023 
00024 // TODO: add python warning message if gCallback, set and return 0
00025    gCallback.reset( new TRflxCallback );
00026 
00027    Py_INCREF( Py_True );
00028    return Py_True;
00029 }
00030 
00031 //____________________________________________________________________________
00032 PyObject* PyROOT::TRflxCallback::Disable()
00033 {
00034 // Remove notification from Reflex
00035    if ( ! gCallback.get() ) {
00036    // TODO: add python error message and return 0
00037       Py_INCREF( Py_False );
00038       return Py_False;
00039    }
00040 
00041    gCallback.reset();
00042 
00043    Py_INCREF( Py_True );
00044    return Py_True;
00045 }
00046 
00047 
00048 //- constructor and destructor -----------------------------------------------
00049 PyROOT::TRflxCallback::TRflxCallback()
00050 {
00051 // Install self as callback to receive notifications from Reflex
00052    ROOT::Reflex::InstallClassCallback( this );
00053 }
00054 
00055 //____________________________________________________________________________
00056 PyROOT::TRflxCallback::~TRflxCallback()
00057 {
00058 // Remove self as callback to receive notifications from Reflex
00059    ROOT::Reflex::UninstallClassCallback( this );
00060 }
00061 
00062 
00063 //- public members -----------------------------------------------------------
00064 void PyROOT::TRflxCallback::operator() ( const ROOT::Reflex::Type& t )
00065 {
00066    PyObject* pyclass = MakeRootClassFromString< ROOT::Reflex::Scope,\
00067       ROOT::Reflex::Base, ROOT::Reflex::Member >( t.Name( ROOT::Reflex::SCOPED ) );
00068    Py_XDECREF( pyclass );
00069 }
00070 
00071 //____________________________________________________________________________
00072 void PyROOT::TRflxCallback::operator() ( const ROOT::Reflex::Member& /* m */ )
00073 {
00074    /* nothing yet */
00075 }
00076 
00077 #endif // PYROOT_USE_REFLEX

Generated on Tue Jul 5 14:10:16 2011 for ROOT_528-00b_version by  doxygen 1.5.1