PyNTuple.cxx
Go to the documentation of this file.
1 
12 #include "PyNTuple.h"
13 
14 #include "PyApp.h"
15 
16 #include <stdexcept>
17 
18 using std::runtime_error;
19 using std::string;
20 using std::vector;
21 
22 using namespace hippodraw;
23 
24 
26 PyNTuple ( const std::vector < std::string > & labels )
27  : NTuple ( labels )
28 {
29  // nothing else to be done.
30 }
31 
33 PyNTuple ( unsigned int n )
34  : NTuple ( n )
35 {
36  // nothing else to be done
37 }
38 
40 PyNTuple ( const PyNTuple & nt )
41  : NTuple ( nt )
42 {
43  // nothing else to be done
44 }
45 
47 PyNTuple ( const NTuple & nt )
48  : NTuple ( nt )
49 {
50  // nothing else to be done
51 }
52 
55  : NTuple ( )
56 {
57 }
58 
59 void
61 setTitle ( const std::string & title )
62 {
63  PyApp::lock ();
64  DataSource::setTitle ( title );
65  PyApp::unlock ();
66 }
67 
68 int
70 addColumn ( const std::string & label,
71  const std::vector < double > & column )
72 {
73  PyApp::lock ();
74  int index = -1;
75  try {
76  index = NTuple::addColumn ( label, column );
77  }
78  catch ( const runtime_error & e ) {
79  PyApp::unlock ();
80  throw e;
81  }
82  PyApp::unlock ();
83 
84  return index;
85 }
86 
87 int
89 addColumn ( const std::string & label,
90  const std::vector < float > & fcolumn )
91 {
92  PyApp::lock ();
93  std::vector < double > dcolumn( fcolumn.begin(), fcolumn.end());
94 
95  int index = -1;
96  try {
97  index = NTuple::addColumn ( label, dcolumn );
98  }
99  catch ( const runtime_error & e ) {
100  PyApp::unlock ();
101  throw e;
102  }
103  PyApp::unlock ();
104 
105  return index;
106 }
107 
108 void
110 replaceColumn ( unsigned int i, const std::vector < double > & column )
111 {
112  PyApp::lock ();
113  try {
114  NTuple::replaceColumn ( i, column );
115  }
116  catch ( const runtime_error & e ) {
117  PyApp::unlock ();
118  throw e;
119  }
120  PyApp::unlock ();
121 }
122 
123 void
125 replaceColumn ( const std::string & label,
126  const std::vector < double > & column )
127 {
128  PyApp::lock ();
129  try {
130  DataSource::replaceColumn ( label, column );
131  }
132  catch ( const runtime_error & e ) {
133  PyApp::unlock ();
134  throw e;
135  }
136  PyApp::unlock ();
137 }
138 
139 void
141 addRow ( const std::vector < double > & row )
142 {
143  // at some point we needed this lock, but after to code was fixed so
144  // PyCanvas checks for pending events this lock causes
145  // run_test_scripts to hang when running with no pompt.
146 
147  PyApp::lock ();
148 
149  try {
150  NTuple::addRow ( row );
151  }
152  catch ( const runtime_error & e ) {
153  PyApp::unlock ();
154  throw e;
155  }
156 
157  PyApp::unlock ();
158 }
159 
160 void
163 {
164  PyApp::lock ();
165  NTuple::clear ();
166  PyApp::unlock ();
167 }
168 
169 void
171 append ( const DataSource * source )
172 {
173  PyApp::lock ();
174  NTuple::append ( source );
175  PyApp::unlock ();
176 }
virtual void setTitle(const std::string &title)
Sets the title of the data source to title.
Definition: DataSource.cxx:146
unsigned int i
virtual void replaceColumn(const std::string &label, const std::vector< double > &array)
Replaces data in column label with contents of array.
Definition: DataSource.cxx:360
virtual int addColumn(const std::string &label, const std::vector< float > &column)
Definition: PyNTuple.cxx:89
virtual void clear()
Clears the NTuple.
Definition: NTuple.cxx:211
virtual void replaceColumn(unsigned int index, const std::vector< double > &data)
Replaces the data in column col.
Definition: NTuple.cxx:440
static void lock()
Obtains a lock on the application&#39;s mutex.
Definition: PyApp.cxx:331
virtual void append(const DataSource *source)
Appends the data from the source.
Definition: PyNTuple.cxx:171
hippodraw::PyNTuple class interface.
column
The column indices for 2 dimension data point tuple.
virtual void addRow(const std::vector< double > &v)
Adds a row to the end of the ntuple.
Definition: NTuple.cxx:266
virtual void append(const DataSource *source)
Appends the data from the source.
Definition: NTuple.cxx:189
hippodraw::PyApp class interface.
virtual int addColumn(const std::string &, const std::vector< double > &column)
Adds a column to the end of the ntuple and returns the index to the added column. ...
Definition: NTuple.cxx:405
virtual void setTitle(const std::string &title)
Sets the title of the DataSource.
Definition: PyNTuple.cxx:61
A DataSource class implemented with std::vector&lt;double&gt; to store the column data. ...
Definition: NTuple.h:33
static void unlock()
Releases the lock on the application&#39;s mutex.
Definition: PyApp.cxx:357
virtual void clear()
Clears the NTuple.
Definition: PyNTuple.cxx:162
virtual void addRow(const std::vector< double > &row)
Adds a row to the end of the ntuple.
Definition: PyNTuple.cxx:141
return index
Definition: PickTable.cxx:182
virtual void replaceColumn(unsigned int i, const std::vector< double > &column)
Replaces the data in column col.
Definition: PyNTuple.cxx:110
A wrapper for NTuple, so that when NTuple is used in Qt based application, the application object can...
Definition: PyNTuple.h:28
PyNTuple()
The default constructor.
Definition: PyNTuple.cxx:54
Base class for DataSource.
Definition: DataSource.h:55

Generated for HippoDraw Class Library by doxygen