Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
python
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
32
#include "
datasrcs/DataSourceController.h
"
33
#include "
datasrcs/NTupleController.h
"
34
35
#include <stdexcept>
36
37
using namespace
hippodraw;
38
39
NTupleController
*
PyNTupleController::m_instance
= 0;
40
PyNTupleController
*
PyNTupleController::s_instance
= 0;
41
42
43
PyNTupleController::
44
PyNTupleController
()
45
{
46
}
47
48
PyNTupleController
*
49
PyNTupleController::
50
instance
()
51
{
52
if
(
s_instance
== 0 ) {
53
s_instance
=
new
PyNTupleController
();
54
m_instance
=
NTupleController::instance
();
55
}
56
57
return
s_instance
;
58
}
59
60
NTuple
*
61
PyNTupleController::
62
createNTuple
( )
63
{
64
PyNTuple
* ntuple =
new
PyNTuple
();
65
DataSourceController
* controller =
DataSourceController::instance
();
66
controller ->
registerNTuple
( ntuple );
67
68
return
ntuple;
69
}
70
71
DataSource
*
72
PyNTupleController::
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
92
CircularBuffer
*
93
PyNTupleController::
94
createCircularBuffer
(
unsigned
int
columns )
95
{
96
return
m_instance
->
createCircularBuffer
( columns );
97
}
98
99
PyDataSource
*
100
PyNTupleController::
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
*
116
PyNTupleController::
117
findDataSource
(
const
std::string & name )
const
118
{
119
DataSourceController
* dsc =
DataSourceController::instance
();
120
121
return
dsc ->
findDataSource
( name );
122
}
123
124
std::string
125
PyNTupleController::
126
registerNTuple
(
DataSource
* source )
127
{
128
PyApp::lock
();
129
DataSourceController
* dsc =
DataSourceController::instance
();
130
131
std::string name = dsc ->
registerNTuple
( source );
132
PyApp::unlock
();
133
134
return
name;
135
}
136
137
void
138
PyNTupleController::
139
registerNTuple
(
const
std::string & name,
DataSource
* source )
140
{
141
DataSourceController
* dsc =
DataSourceController::instance
();
142
143
dsc ->
registerNTuple
( name, source );
144
}
145
146
int
147
PyNTupleController::
148
writeNTupleToFile
(
DataSource
* source,
149
const
std::string & filename )
150
{
151
return
m_instance
->
writeNTupleToFile
( source, filename );
152
}
153
154
void
155
PyNTupleController::
156
changeName
(
DataSource
* source,
const
std::string & new_name )
157
{
158
source -> setName ( new_name );
159
}
Generated for HippoDraw Class Library by