PyNTupleController.cxx
Go to the documentation of this file.
1 
12 #ifdef _MSC_VER
13 // nonstandard extension used 'extern' before...
14 # pragma warning(disable:4231)
15 
16 // needs to have dll-interface used by client
17 # pragma warning(disable:4251)
18 
19 // non dll-interface struct
20 # pragma warning(disable:4275)
21 
22 // 'int' : forcing value to bool 'true' or 'false' (performance warning)
23 # pragma warning(disable:4800)
24 #endif
25 
26 #include "PyNTupleController.h"
27 
28 #include "PyApp.h"
29 #include "PyDataSource.h"
30 #include "PyNTuple.h"
31 
34 
35 #include <stdexcept>
36 
37 using namespace hippodraw;
38 
41 
42 
45 {
46 }
47 
51 {
52  if ( s_instance == 0 ) {
55  }
56 
57  return s_instance;
58 }
59 
60 NTuple *
63 {
64  PyNTuple * ntuple = new PyNTuple ();
66  controller -> registerNTuple ( ntuple );
67 
68  return ntuple;
69 }
70 
71 DataSource *
73 createNTuple ( const std::string & filename )
74 {
75  PyApp::lock ();
76  unsigned int columns = 0;
77  PyNTuple * ntuple = new PyNTuple ( columns );
78 
79  try {
80  m_instance -> fillFromFile ( filename, ntuple );
81  }
82  catch ( const std::runtime_error & e ) {
83  PyApp::unlock ();
84  delete ntuple;
85  throw e;
86  }
87  PyApp::unlock ();
88 
89  return ntuple;
90 }
91 
94 createCircularBuffer ( unsigned int columns )
95 {
96  return m_instance -> createCircularBuffer ( columns );
97 }
98 
101 createDataArray ( const std::string & filename )
102 {
103 #ifdef HAVE_NUMARRAY
104  DataSource * tuple = createNTuple ( filename );
105  PyDataSource * ds = new PyDataSource ( "NTuple", tuple );
106 
107  return ds;
108 #else
109  std::runtime_error e ( "HippoDraw was not built with "
110  "numeric Python support" );
111  throw e;
112 #endif
113 }
114 
115 DataSource *
117 findDataSource ( const std::string & name ) const
118 {
120 
121  return dsc -> findDataSource ( name );
122 }
123 
124 std::string
127 {
128  PyApp::lock ();
130 
131  std::string name = dsc -> registerNTuple ( source );
132  PyApp::unlock ();
133 
134  return name;
135 }
136 
137 void
139 registerNTuple ( const std::string & name, DataSource * source )
140 {
142 
143  dsc -> registerNTuple ( name, source );
144 }
145 
146 int
149  const std::string & filename )
150 {
151  return m_instance -> writeNTupleToFile ( source, filename );
152 }
153 
154 void
156 changeName ( DataSource * source, const std::string & new_name )
157 {
158  source -> setName ( new_name );
159 }

Generated for HippoDraw Class Library by doxygen