1 #ifndef GAUDI_NTUPLESVC_NTUPLEITEMS_H
2 #define GAUDI_NTUPLESVC_NTUPLEITEMS_H 1
5 #define ALLOW_ALL_TYPES
11 #include "GaudiKernel/System.h"
30 template <
class TYP>
class DataItem;
31 template <
class TYP>
class _DataImp;
32 template <
class TYP>
class _ItemImp;
33 template <
class TYP>
class _ArrayImp;
34 template <
class TYP>
class _MatrixImp;
38 template <
class TYP>
class _DataImp :
virtual public _Data<TYP> {
42 typedef const std::string&
CSTR;
43 typedef const std::type_info&
CTYPE;
61 const std::type_info&
m_info;
66 _DataImp(
INTuple* tup,std::string
name,
const std::type_info& info,std::string
index,
long len,TYP low,TYP high,TYP def)
67 : m_length(len), m_tuple(tup), m_name(
std::move(name)), m_index(
std::move(index)),
68 m_def(
std::move(def)), m_range(
std::move(low),
std::move(high)), m_info(info)
79 std::string
typeName()
const override {
83 void reset()
override {
84 std::fill_n(this->
m_buffer, m_length, m_def );
87 long filled()
const override {
91 for (
int l = 0;
l < nd-1;
l++ ) {
95 long *ll = (
long*)m_indexItem->
buffer();
106 if ( !m_indexItem ) m_indexItem = m_tuple->
find(m_index);
111 if ( !m_indexItem ) m_indexItem = m_tuple->
find(m_index);
115 const std::type_info&
typeID()
const override {
return m_info;}
117 long size()
const override {
return m_length*
sizeof(TYP); }
119 void release()
override {
delete this; }
121 bool hasIndex()
const override {
return m_index.length()>0; }
123 const std::string&
index()
const override {
return m_index; }
125 const std::string&
name()
const override {
return m_name; }
131 void setDefault(
const TYP val)
override { m_def = val; }
133 const ItemRange&
range()
const override {
return m_range; }
141 long ndim()
const override {
return 0; }
143 long dim(
long i)
const override {
return (i==0) ? 1 : 0; }
150 template <
class TYP>
class _ItemImp :
virtual public _DataImp<TYP>,
151 virtual public _Item<TYP> {
157 _ItemImp(
INTuple* tup,
const std::string& name,
const std::type_info& info, TYP min, TYP max, TYP def)
158 :
_DataImp<TYP>(tup, name, info,
"", 1, min, max, def) { }
164 void setDefault(
const TYP val)
override { this->m_def = val; }
166 const ItemRange&
range()
const override {
return this->
m_range; }
168 long size()
const override {
return this->m_length*
sizeof(TYP); }
173 template <
class TYP>
class _ArrayImp :
virtual public _DataImp<TYP>,
174 virtual public _Array<TYP> {
179 _ArrayImp(
INTuple* tup,
const std::string& name,
const std::type_info& typ,
const std::string& index,
long len,TYP min,TYP max,TYP def)
180 :
_DataImp<TYP>(tup, name, typ, index, len, min, max, def) { }
186 void setDefault(
const TYP val)
override { this->m_def = val; }
188 const ItemRange&
range()
const override {
return this->
m_range; }
190 long size()
const override {
return this->m_length*
sizeof(TYP); }
192 long ndim()
const override {
return 1; }
194 long dim(
long i)
const override {
201 template <
class TYP>
class _MatrixImp :
virtual public _DataImp<TYP>,
202 virtual public _Matrix<TYP> {
207 _MatrixImp(
INTuple* tup,
const std::string& name,
const std::type_info& typ,
const std::string& index,
208 long ncol,
long nrow,TYP min,TYP max,TYP def)
209 :
_DataImp<TYP>(tup, name, typ, index, nrow*ncol, min, max, def) {
217 void setDefault(
const TYP val)
override { this->m_def = val; }
219 const ItemRange&
range()
const override {
return this->
m_range; }
221 long size()
const override {
return this->m_length*
sizeof(TYP); }
223 long ndim()
const override {
return 2; }
225 long dim(
long i)
const override {
232 #endif // GAUDI_NTUPLESVC_NTUPLEITEMS_H
_DataImp(const _DataImp &)=delete
Inhibit Copy Constructor.
INTupleItem * m_indexItem
Pointer to index item.
long type() const override
TYP information of the item.
~_DataImp() override
Standard destructor.
~_ArrayImp() override=default
Standard Destructor.
long filled() const override
Number of items filled.
const std::string & name() const override
Access _Column name.
_ArrayImp(INTuple *tup, const std::string &name, const std::type_info &typ, const std::string &index, long len, TYP min, TYP max, TYP def)
Standard Constructor.
long size() const override
Size of entire object.
~_ItemImp() override=default
Standard Destructor.
~_MatrixImp() override=default
Standard Destructor.
Range< TYP > ItemRange
Set type definition to make life more easy easy.
static Type ID(const bool)
Access to type information: bool.
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
const ItemRange & range() const override
Access the range if specified.
TYP * m_buffer
Pointer to data buffer.
long size() const override
Size of entire object.
long ndim() const override
Dimension.
DataTypeInfo::Type m_type
_Column type
INTupleItem * indexItem() override
Pointer to index column (if present, 0 else)
TYP m_def
Buffer with default value.
_MatrixImp(INTuple *tup, const std::string &name, const std::type_info &typ, const std::string &index, long ncol, long nrow, TYP min, TYP max, TYP def)
Standard Constructor.
const std::string & index() const override
Access the index _Column.
Data provider interface definition.
const void * buffer() const override
Access data buffer (CONST)
long ndim() const override
Dimension.
Range< TYP > ItemRange
Set type definition to make life more easy easy.
NTuple interface class definition.
std::string m_index
Check that values are within a certain range while filling.
bool hasIndex() const override
Is the tuple have an index column?
NTuple interface class definition.
void reset() override
Reset to default.
long length() const override
Access the buffer length.
void setDefault(const TYP val) override
Set default value.
void setDefault(const TYP val) override
Compiler type ID.
long ndim() const override
Dimension.
long dim(long i) const override
Access individual dimensions.
long size() const override
Size of entire object.
Range< TYP > ItemRange
Set type definition to make life more easy easy.
const ItemRange & range() const override
Access the range if specified.
long size() const override
Size of entire object.
void release() override
Destruct object.
Range< TYP > ItemRange
Set type definition to make life more easy easy.
long m_length
Entire buffer length.
std::string typeName() const override
Get proper type name.
Range< TYP > m_range
Check that values are within a certain range while filling.
INTuple * m_tuple
Pointer to N tuple.
long dim(long i) const override
Access individual dimensions.
const ItemRange & range() const override
Access the range if specified.
const std::type_info & typeID() const override
Compiler type ID.
long m_rows
Number of rows per column.
std::string m_name
_Column name
const std::type_info & m_info
Item type information.
INTuple * tuple() override
Access to hosting ntuple.
long dim(long i) const override
Access individual dimensions.
void setDefault(const TYP val) override
Compiler type ID.
void setType(long t) override
Set the properties of the _Column.
_ItemImp(INTuple *tup, const std::string &name, const std::type_info &info, TYP min, TYP max, TYP def)
Standard Constructor.
const ItemRange & range() const override
Access the range if specified.
virtual const INTupleItem * find(const std::string &name) const =0
Find an item row of the Ntuple (CONST)
void setDefault(const TYP val) override
Compiler type ID.
virtual const void * buffer() const =0
Access data buffer (CONST)
const std::type_info & CTYPE