8 #include "GaudiKernel/IDataProviderSvc.h"
9 #include "GaudiKernel/ISelectStatement.h"
10 #include "GaudiKernel/IDataManagerSvc.h"
11 #include "GaudiKernel/GenericAddress.h"
12 #include "GaudiKernel/SmartDataPtr.h"
13 #include "GaudiKernel/Tokenizer.h"
14 #include "GaudiKernel/IRegistry.h"
15 #include "GaudiKernel/Algorithm.h"
16 #include "GaudiKernel/MsgStream.h"
17 #include "GaudiKernel/SmartIF.h"
18 #include "GaudiKernel/NTuple.h"
19 #include "GaudiKernel/ObjectFactory.h"
25 return long(it->
range().upper());
28 template<
class TYP>
static
35 TYP low = source->
range().lower();
36 TYP high = source->
range().upper();
38 long ndim = source->
ndim();
39 const std::string& name = source->
name();
41 long dim[4], idxLen = 0;
42 long dim1 = 1, dim2 = 1;
44 for (
int i = 0;
i < ndim;
i++ )
45 dim[
i] = source->
dim(
i);
49 idxName = index->
name();
50 switch( index->
type() ) {
52 idxLen = upper<unsigned char>(index);
55 idxLen = upper<unsigned short>(index);
58 idxLen = upper<unsigned int>(index);
61 idxLen = upper<unsigned long>(index);
64 idxLen = upper<char>(index);
67 idxLen = upper<short>(index);
70 idxLen = upper<int>(index);
73 idxLen = upper<long>(index);
77 <<
" is not a valid index column!" <<
endmsg;
86 dim1 = (hasIdx) ? idxLen : dim[0];
97 dim1 = (hasIdx) ? idxLen : dim[0];
98 dim2 = (hasIdx) ? dim[0] : dim[1];
112 return tuple->
add(it);
169 for ( Tokenizer::Items::iterator
i = tok.
items().begin();
i != tok.
items().end();
i++ ) {
170 const std::string& tag = (*i).tag();
171 const std::string& val = (*i).value();
190 if ( fun.length() > 0 ||
m_criteria.length() > 0 ) {
191 if (
m_criteria.length() > 0 && fun.length() == 0 ) fun =
"NTuple::Selector";
197 log <<
MSG::ERROR <<
"Failed to access service \""
223 INTuple::ItemContainer::const_iterator
i;
225 for (i = items.begin(); i != items.end(); ++
i) {
226 long type = (*i)->type();
229 status = createItem(log, tuple, *i, (
unsigned char)0);
232 status = createItem(log, tuple, *i, (
unsigned short)0);
235 status = createItem(log, tuple, *i, (
unsigned int)0);
238 status = createItem(log, tuple, *i, (
unsigned long)0);
241 status = createItem(log, tuple, *i,
char(0));
244 status = createItem(log, tuple, *i,
short(0));
247 status = createItem(log, tuple, *i,
int(0));
250 status = createItem(log, tuple, *i,
long(0));
253 status = createItem(log, tuple, *i,
false);
256 status = createItem(log, tuple, *i,
float(0.0));
259 status = createItem(log, tuple, *i,
double(0.0));
265 status = createItem(log, tuple, *i, (
void*)0);
285 if ( 0 != clone && 0 != src ) {
290 INTuple::ItemContainer::const_iterator
i;
292 for (i = clone_items.begin(); i != clone_items.end(); ++
i) {
294 const std::string& nam = itm->
name();
297 log <<
"Tuple item " << nam <<
" not present in " << src_id <<
endmsg;
300 if ( itm->
type() != src_itm->
type() ) {
301 log <<
"Tuple item " << nam <<
" are of different types in "
302 << src_id <<
":" << src_itm->
typeName() <<
" <-> "
306 if ( itm->
ndim() != src_itm->
ndim() ) {
307 log <<
"Tuple item " << nam <<
" have different dimensions in "
308 << src_id <<
":" << src_itm->
ndim() <<
" <-> "
312 for (
int j=0; j<itm->
ndim(); ++j) {
313 if ( src_itm->
dim(j) != itm->
dim(j) ) {
314 log <<
"Tuple item " << nam <<
" have different dimensions in "
315 << src_id <<
"[" << j <<
"]:" << src_itm->
dim(j) <<
" <-> "
316 << clone_id <<
"[" << j <<
"]:" << itm->
dim(j) <<
endmsg;
321 log <<
"Tuple item " << nam <<
" has different index colums "
322 << src_id <<
":" << src_itm->
hasIndex() <<
" <-> "
328 log <<
"Tuple item " << nam <<
" has different index colums "
329 << src_id <<
":" << src_itm->
index() <<
" <-> "
346 std::vector<GenericAddress> addrVector(clone_items.size());
349 size_t k = 0, nentry = 0;
352 for (k=0; k < source_items.size(); ++k ) {
357 while ( status.isSuccess() ) {
359 if ( status.isSuccess() ) {
360 INTuple::ItemContainer::const_iterator
i;
362 for (k=0,i = source_items.begin(); i != source_items.end(); ++
i,++k) {
366 switch((*i)->type()) {
368 size =
sizeof(
unsigned char);
371 size =
sizeof(
unsigned short);
374 size =
sizeof(
unsigned int);
377 size =
sizeof(
unsigned long);
383 size =
sizeof(short);
395 size =
sizeof(float);
398 size =
sizeof(double);
401 *(std::string*)out_itm->
buffer() = *(std::string*)src_itm->
buffer();
405 size = ::strlen((
const char*)src_itm->
buffer())+1;
409 *(
void**)out_itm->
buffer() = *(
void**)src_itm->
buffer();
431 if ( !status.isSuccess() ) {
432 log <<
MSG::ERROR <<
"Failed to write record " << nentry
437 log <<
MSG::INFO <<
"End of reading tuple " << input
438 <<
" after " << nentry <<
" entries." <<
endmsg;
470 nt->attachSelector(stmt);
491 for (
size_t inp=0; inp <
m_inputs.size(); ++inp) {