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 }
std::string registerNTuple(DataSource *source)
Registers the DataSource object and returns its assigned name.
int writeNTupleToFile(DataSource *source, const std::string &filename)
Writes the DataSource to the file filename.
PyDataSource * createDataArray(const std::string &filename)
Creates a DataArray Python object from the file filename.
static void lock()
Obtains a lock on the application&#39;s mutex.
Definition: PyApp.cxx:331
hippodraw::PyNTuple class interface.
static PyNTupleController * instance()
The singleton instance method.
CircularBuffer * createCircularBuffer(unsigned int n)
Creates an empty CircularBuffer object with n columns.
hippodraw::PyDataSource class interface
static PyNTupleController * s_instance
The singleton PyNTupleController instance.
hippodraw::PyApp class interface.
A singleton class that is the interface between GUI and the NTuple objects.
PyNTupleController()
The default constructor, protected from being used.
This class is the public interface to a DataSource object that the user sees as the DataArray object ...
Definition: PyDataSource.h:43
DataSource * findDataSource(const std::string &name) const
Finds the DataSource by name.
A singleton class that is the interface between GUI and the DataSource objects.
static NTupleController * instance()
Returns the pointer to the singleton instance.
A wrapper for NTupleController for use from Python.
A DataSource class implemented with std::vector&lt;double&gt; to store the column data. ...
Definition: NTuple.h:33
hippodraw::PyNTupleController class interface.
static void unlock()
Releases the lock on the application&#39;s mutex.
Definition: PyApp.cxx:357
CircularBuffer manager.
hippodraw::NTupleController class interface
A wrapper for NTuple, so that when NTuple is used in Qt based application, the application object can...
Definition: PyNTuple.h:28
DataSourceController class interface.
void changeName(DataSource *source, const std::string &new_name)
Changes the name of the DataSource.
static NTupleController * m_instance
The singleton NTupleController object.
NTuple * createNTuple()
Creates an empty NTuple object.
static DataSourceController * instance()
Returns the pointer to the singleton instance.
Base class for DataSource.
Definition: DataSource.h:55

Generated for HippoDraw Class Library by doxygen