00001 00012 #ifdef HAVE_CONFIG_H 00013 #include "config.h" 00014 #endif 00015 00016 #include "QtRootController.h" 00017 00018 #include "RootController.h" 00019 #include "QtRootNTuple.h" 00020 00021 #include "datasrcs/DataSourceController.h" 00022 00023 #include "python/PyApp.h" 00024 #include "python/PyDataSource.h" 00025 00026 using namespace hippodraw; 00027 00028 RootController * QtRootController::m_instance = 0; 00029 QtRootController * QtRootController::s_instance = 0; 00030 00031 QtRootController:: 00032 QtRootController() 00033 { 00034 } 00035 00036 QtRootController * 00037 QtRootController:: 00038 instance () 00039 { 00040 if ( s_instance == 0 ) { 00041 s_instance = new QtRootController (); 00042 m_instance = RootController::instance (); 00043 } 00044 00045 return s_instance; 00046 } 00047 00048 DataSource * 00049 QtRootController:: 00050 createNTuple ( const std::string & filename, const std::string & treename ) 00051 { 00052 PyApp::lock(); 00053 00054 TTree * tree = m_instance -> getTree ( filename, treename ); 00055 QtRootNTuple * rtuple = new QtRootNTuple ( tree ); 00056 DataSource * ntuple = rtuple; 00057 00058 PyApp::unlock (); 00059 00060 return m_instance -> initNTuple ( ntuple, filename, treename ); 00061 } 00062 00063 PyDataSource * 00064 QtRootController:: 00065 createDataArray ( const std::string & filename, const std::string & treename ) 00066 { 00067 #ifdef HAVE_NUMARRAY 00068 DataSource * rtuple = createNTuple ( filename, treename ); 00069 PyDataSource * ds = new PyDataSource ( "RootNTuple", rtuple ); 00070 00071 return ds; 00072 #else 00073 std::runtime_error e ( "HippoDraw was not built with " 00074 "numeric Python support" ); 00075 throw e; 00076 #endif 00077 } 00078 00079 const std::vector < std::string > & 00080 QtRootController:: 00081 getNTupleNames ( const std::string & filename ) 00082 { 00083 PyApp::lock(); 00084 00085 try { 00086 const std::vector< std::string > & names 00087 = m_instance -> getNTupleNames ( filename ); 00088 PyApp::unlock (); 00089 return names; 00090 } 00091 catch ( const std::runtime_error & e ) { 00092 PyApp::unlock (); 00093 throw e; 00094 } 00095 static const std::vector < std::string > names; 00096 // never reach following but VC++ insists on return value. 00097 return names; 00098 }