QtRootController.cxx
Go to the documentation of this file.
1 
12 #ifdef HAVE_CONFIG_H
13 #include "config.h"
14 #endif
15 
16 #include "QtRootController.h"
17 
18 #include "RootController.h"
19 #include "QtRootNTuple.h"
20 
22 
23 #include "python/PyApp.h"
24 #include "python/PyDataSource.h"
25 
26 using namespace hippodraw;
27 
30 
33 {
34 }
35 
39 {
40  if ( s_instance == 0 ) {
43  }
44 
45  return s_instance;
46 }
47 
48 DataSource *
50 createNTuple ( const std::string & filename, const std::string & treename )
51 {
52  PyApp::lock();
53 
54  TTree * tree = m_instance -> getTree ( filename, treename );
55  QtRootNTuple * rtuple = new QtRootNTuple ( tree );
56  DataSource * ntuple = rtuple;
57 
58  PyApp::unlock ();
59 
60  return m_instance -> initNTuple ( ntuple, filename, treename );
61 }
62 
65 createDataArray ( const std::string & filename, const std::string & treename )
66 {
67 #ifdef HAVE_NUMARRAY
68  DataSource * rtuple = createNTuple ( filename, treename );
69  PyDataSource * ds = new PyDataSource ( "RootNTuple", rtuple );
70 
71  return ds;
72 #else
73  std::runtime_error e ( "HippoDraw was not built with "
74  "numeric Python support" );
75  throw e;
76 #endif
77 }
78 
79 const std::vector < std::string > &
81 getNTupleNames ( const std::string & filename )
82 {
83  PyApp::lock();
84 
85  try {
86  const std::vector< std::string > & names
87  = m_instance -> getNTupleNames ( filename );
88  PyApp::unlock ();
89  return names;
90  }
91  catch ( const std::runtime_error & e ) {
92  PyApp::unlock ();
93  throw e;
94  }
95  static const std::vector < std::string > names;
96  // never reach following but VC++ insists on return value.
97  return names;
98 }
static QtRootController * s_instance
The singleton QtRootController instance.
QtRootController()
The default constructor, protected from being used.
The ROOT TTree class.
hippodraw::RootController class interface.
hippodraw::QtRootNTuple class interface.
A wrapper for RootController, so that when RootController is used in Qt based application, the application object can be locked and unlocked before calling any ROOT functions.
static void lock()
Obtains a lock on the application&#39;s mutex.
Definition: PyApp.cxx:331
PyDataSource * createDataArray(const std::string &filename, const std::string &treename)
Creates a PyDataSource wrapper to the RootNTuple object.
A wrapper for RootNTuple, so that when RootNTuple is used in Qt based application, the application object can be locked and unlocked before calling any ROOT functions.
Definition: QtRootNTuple.h:37
hippodraw::PyDataSource class interface
static RootController * m_instance
The singleton RootController object.
DataSource * createNTuple(const std::string &filename, const std::string &treename)
Creates a QtRootNTuple wrapper for RootNTuple object.
hippodraw::PyApp class interface.
This class is the public interface to a DataSource object that the user sees as the DataArray object ...
Definition: PyDataSource.h:43
QtRootController class interface.
static QtRootController * instance()
The singleton instance method.
const std::vector< std::string > & getNTupleNames(const std::string &filename)
Returns the names of the top level tree in the Root file.
static void unlock()
Releases the lock on the application&#39;s mutex.
Definition: PyApp.cxx:357
static RootController * instance()
Returns the singleton instance of the RootController.
DataSourceController class interface.
A Controller class for ROOT files.
Base class for DataSource.
Definition: DataSource.h:55

Generated for HippoDraw Class Library by doxygen