3 #ifndef GAUDIKERNEL_NTUPLE_H
4 #define GAUDIKERNEL_NTUPLE_H
24 class NTupleDirectory;
37 template <
class TYP>
class Range;
38 template <
class TYP>
class _Data;
39 template <
class TYP>
class _Item;
43 template <
class TYP>
class Item;
44 template <
class TYP>
class Array;
79 static TYP
max() {
return std::numeric_limits<TYP>::max() ; }
86 Range(
const bool ,
const bool ) {}
92 bool lower()
const {
return false; }
94 bool upper()
const {
return true; }
98 static bool min() {
return false; }
100 static bool max() {
return true; }
120 virtual void setDefault(
const TYP d) = 0;
133 const std::string& name,
134 const std::type_info& info,
141 *this->m_buffer = copy.
get();
147 virtual TYP
get()
const {
return *this->m_buffer; }
152 template <
class TYP>
class GAUDI_API _Array :
virtual public _Data<TYP> {
155 static _Array* create(
INTuple* tup,
156 const std::string& name,
157 const std::type_info& info,
158 const std::string& index,
166 long len = this->length();
167 if ( len == copy.
length() ) {
168 const T* source = (
const T*)copy.
buffer();
169 for (
int i = 0;
i < len;
i++ ) {
170 *(this->m_buffer +
i) = *(source +
i);
174 throw std::out_of_range
175 (
"N-tuple matrix cannot be copied! The index range does not match!");
179 const TYP&
data(
long i)
const {
return *(this->m_buffer +
i); }
181 TYP&
data(
long i) {
return *(this->m_buffer +
i); }
186 template <
class TYP>
class GAUDI_API _Matrix :
virtual public _Data<TYP> {
193 const std::string& name,
194 const std::type_info& info,
195 const std::string& index,
204 long len = this->length();
205 if ( len == copy.
length() ) {
206 const T* source = (
const T*)copy.
buffer();
207 for (
int i = 0;
i < len;
i++ ) {
208 *(this->m_buffer +
i) = *(source +
i);
212 throw std::out_of_range
213 (
"N-tuple matrix cannot be copied! The index range does not match!");
217 TYP*
column(
long i) {
return (this->m_buffer + i*m_rows); }
219 const TYP*
column(
long i)
const {
return (this->m_buffer + i*m_rows); }
224 template <
class TYP>
class _Accessor {
241 operator const void*()
const {
return m_ptr; }
252 template <
class TYP>
class Item :
virtual public _Accessor< _Item<TYP> > {
258 operator const TYP ()
const {
return this->
m_ptr->get(); }
270 this->
m_ptr->set( data );
276 this->
m_ptr->set( data->get() );
280 this->
m_ptr->set ( this->
m_ptr->get() + data );
284 this->
m_ptr->set ( this->
m_ptr->get() - data );
288 this->
m_ptr->set ( this->
m_ptr->get() * data );
292 this->
m_ptr->set ( this->
m_ptr->get() / data );
305 operator bool ()
const {
return this->
m_ptr->get(); }
308 this->
m_ptr->set( data );
314 this->
m_ptr->set( data->get() );
321 template <
class TYP>
class Array :
virtual public _Accessor < _Array<TYP> > {
328 *(this->
m_ptr) = *(copy.operator->());
342 template <
class TYP>
class Matrix :
virtual public _Accessor< _Matrix<TYP> > {
349 *(this->
m_ptr) = *(copy.operator->());
408 if (
clID() == CLID_ColumnWiseTuple ) {
421 if (
clID() == CLID_ColumnWiseTuple ) {
431 template <
class TYPE>
446 template <
class TYPE>
449 const std::string& index,
453 if ( !
i_find(name) &&
clID() == CLID_ColumnWiseTuple ) {
466 template <
class TYPE>
470 const std::string& index,
474 if ( !
i_find(name) &&
clID() == CLID_ColumnWiseTuple ) {
489 if ( !
i_find(name) &&
clID() == CLID_ColumnWiseTuple ) {
503 return i_item(name, result.m_ptr);
509 return i_item(name, result.m_ptr);
515 return i_item(name, result.m_ptr);
521 return i_item(name, result.m_ptr);
527 return i_item(name, result.m_ptr);
534 return i_item(name, result.m_ptr);
606 return i_addItem( name, 1,
"", TYPE(low), TYPE(high), itm.m_ptr);
699 template <
class TYPE,
class INDEX,
class RANGE>
StatusCode
707 index->range().distance(),
739 template <
class TYPE,
class INDEX,
class RANGE>
StatusCode
747 index->range().distance(),
784 index->range().distance(),
816 index->range().distance(),
926 index->range().distance(),
961 col_index->range().distance(),
1001 template <
class TYPE,
class INDEX,
class RANGE>
StatusCode
1010 index->range().distance(),
1045 template <
class TYPE,
class INDEX,
class RANGE>
StatusCode
1054 index->range().distance(),
1075 return CLID_NTupleDirectory;
1107 return CLID_NTupleFile;
1156 virtual void dummy() = 0;
1165 virtual void dummy() = 0;
1168 #ifndef ALLOW_ALL_TYPES
1170 typedef Item<bool> BoolItem;
1171 typedef Item<char> CharItem;
1172 typedef Item<unsigned char> UCharItem;
1173 typedef Item<short> ShortItem;
1174 typedef Item<unsigned short> UShortItem;
1175 typedef Item<long> LongItem;
1176 typedef Item<long long> LongLongItem;
1177 typedef Item<unsigned long> ULongItem;
1178 typedef Item<unsigned long long> ULongLongItem;
1179 typedef Item<int> IntItem;
1180 typedef Item<unsigned int> UIntItem;
1181 typedef Item<float> FloatItem;
1182 typedef Item<double> DoubleItem;
1183 typedef Array<bool> BoolArray;
1184 typedef Array<char> CharArray;
1185 typedef Array<unsigned char> UCharArray;
1186 typedef Array<short> ShortArray;
1187 typedef Array<unsigned short> UShortArray;
1188 typedef Array<long> LongArray;
1189 typedef Array<unsigned long> ULongArray;
1190 typedef Array<int> IntArray;
1191 typedef Array<unsigned int> UIntArray;
1192 typedef Array<float> FloatArray;
1193 typedef Array<double> DoubleArray;
1194 typedef Matrix<bool> BoolMatrix;
1195 typedef Matrix<char> CharMatrix;
1196 typedef Matrix<unsigned char> UCharMatrix;
1197 typedef Matrix<short> ShortMatrix;
1198 typedef Matrix<unsigned short> UShortMatrix;
1199 typedef Matrix<long> LongMatrix;
1200 typedef Matrix<unsigned long> ULongMatrix;
1201 typedef Matrix<int> IntMatrix;
1202 typedef Matrix<unsigned int> UIntMatrix;
1203 typedef Matrix<float> FloatMatrix;
1204 typedef Matrix<double> DoubleMatrix;
1208 inline std::ostream& operator<<(std::ostream& s, const Item<T>& obj)
1219 #endif // GAUDIKERNEL_NTUPLE_H
StatusCode addItem(const std::string &name, Item< INDEX > &index, Matrix< TYPE > &matrix, long rows, const RANGE low, const RANGE high)
Add an variable size Matrix of data to a column wise N tuple.
const std::string & name() const
Retrun physical file name.
bool lower() const
Lower boundary of range.
void setLogicalName(const std::string &l)
Item< TYP > & operator/=(const TYP data)
Item< TYP > & operator+=(const TYP data)
void setOpen(bool flag)
Set "open" flag.
KeyedObjectManager< array > Array
Forward declaration of specialized redirection array object manager.
void setName(const std::string &nam)
Set access type.
TYP m_lower
Lower boundary of range.
StatusCode addItem(const std::string &name, Item< INDEX > &index, Array< TYPE > &array)
Add an indexed Array of data to a column wise N tuple.
std::string m_logName
Logical file name.
StatusCode addItem(const std::string &name, Item< INDEX > &index, Array< TYPE > &array, const RANGE low, const RANGE high)
Add an indexed Array of data to a column wise N tuple with a range.
StatusCode addIndexedItem(const std::string &name, Item< INDEX > &index, long rows, Matrix< TYPE > &matrix, const RANGE low, const RANGE high)
Add an variable size Matrix of data to a column wise N tuple.
Abstract class describing a matrix column in a N tuple.
Class acting as a smart pointer holding a N tuple _Item.
StatusCode i_item(const std::string &name, _Item< TYPE > *&result) const
Locate a _Column of data to the N tuple type safe.
StatusCode i_addItem(const std::string &name, long dim1, long dim2, const std::string &index, TYPE low, TYPE high, _Matrix< TYPE > *&result)
Add a _Item of data to the N tuple.
Abstract class describing a column in a N tuple.
Range< TYP > ItemRange
Set type definition to make life more easy easy.
TYP & operator[](const T i)
Array operator.
SmartDataPtr< NTuple::File > NTupleFilePtr
virtual StatusCode add(INTupleItem *item)=0
Add an item row to the N tuple.
_Array< TYP > & operator=(const _Array< T > ©)
Assignment operator.
StatusCode item(const std::string &name, const Item< TYPE > &result) const
Locate a scalar Item of data to the N tuple type safe (CONST)
static TYP min()
Minimal number of data.
TYP * operator->()
Dereference operator.
StatusCode item(const std::string &name, const Matrix< TYPE > &result) const
Locate a Matrix of data to the N tuple type safe (CONST)
const TYP operator*() const
Dereference operator for pointers(CONST)
StatusCode addItem(const std::string &name, long cols, long rows, Matrix< TYPE > &matrix)
Add an fixed size Matrix of data to a column wise N tuple.
StatusCode item(const std::string &name, const Array< TYPE > &result) const
Locate a Array of data to the N tuple type safe (CONST)
TYP * column(long i)
Access to data by reference.
_Matrix< TYP > & operator=(const _Matrix< T > ©)
Assignment operator.
SmartDataPtr< NTuple::Tuple > NTuplePtr
StatusCode addIndexedItem(const std::string &name, Item< INDEX > &index, Array< TYPE > &array, const RANGE low, const RANGE high)
Add an indexed Array of data to a column wise N tuple with a range.
const Range< TYP > & range() const
Access the range.
virtual TYP get() const
Access to data by reference (CONST)
long type() const
Return access type.
StatusCode addItem(const std::string &name, Item< INDEX > &index, Matrix< TYPE > &matrix, long rows)
Add an variable size Matrix of data to a column wise N tuple.
Item()
Standard Constructor.
static const CLID & classID()
class ID of the object
void set(const TYP &item)
Access to data by reference.
NTuple interface class definition.
Matrix & operator=(const Matrix< T > ©)
Assignment operator.
StatusCode addIndexedItem(const std::string &name, Item< INDEX > &col_index, long rows, Matrix< TYPE > &matrix)
Add an variable size Matrix of data to a column wise N tuple.
virtual ~Range()
Destructor.
StatusCode addIndexedItem(const std::string &name, Item< INDEX > &index, Array< TYPE > &array)
Add an indexed Array of data to a column wise N tuple.
StatusCode i_item(const std::string &name, _Matrix< TYPE > *&result) const
Locate a _Matrix of data to the N tuple type safe.
Item()
Standard Constructor.
Item< TYP > & operator-=(const TYP data)
NTuple interface class definition.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Class acting as a smart pointer holding a N tuple entry.
static bool max()
Maximal number of data.
This class is used for returning status codes from appropriate routines.
Matrix()
Standard Constructor.
_Item< TYP > & operator=(const _Item< T > ©)
Assignment operator.
StatusCode addItem(const std::string &name, Item< TYPE > &itm, const RANGE low, const RANGE high)
Add a scalar data item a N tuple with a range.
StatusCode addItem(const std::string &name, long cols, long rows, Matrix< TYPE > &result, const RANGE low, const RANGE high)
Add an fixed size Matrix of data to a column wise N tuple.
static TYP max()
Maximal number of data.
Item & operator=(const Item< T > &data)
Assignment operator.
bool upper() const
Upper boundary of range.
Array()
Standard Constructor.
virtual const CLID & clID() const
class ID of the object
std::string m_name
Physical file name.
StatusCode i_addObject(const std::string &name, _Item< TYPE * > *&result, const std::type_info &)
Specialization acting as a smart pointer holding a N tuple _Item.
StatusCode addItem(const std::string &name, long dim, Array< TYPE > &array)
Add an fixed-size Array of data to a column wise N tuple.
TYP upper() const
Upper boundary of range.
Abstract class describing basic data in an Ntuple.
bool isOpen() const
Access "open" flag.
unsigned int CLID
Class ID definition.
StatusCode addItem(const std::string &name, Item< IOpaqueAddress * > &itm)
Add an address object item to an N tuple: specialized call.
Range(const Range< TYP > ©)
Copy constructor.
virtual ~_Item()
Destructor.
Abstract base class which allows the user to interact with the actual N tuple implementation.
virtual ~File()
Standard destructor.
bool operator!() const
Check if column is present.
void setType(const long typ)
Set access type.
bool m_isOpen
Flag to indicate wether the file was opened already.
std::vector< Row > Matrix
virtual const CLID & clID() const
class ID of the object
TYP distance() const
Distance between lower and upper range.
TYP * m_ptr
Pointer to instance.
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
StatusCode addItem(const std::string &name, Item< TYPE * > &itm)
Add an simple object item to an N tuple.
const TYP * column(long i) const
Access to data by reference (CONST)
StatusCode i_addItem(const std::string &name, long dim, const std::string &index, TYPE low, TYPE high, _Array< TYPE > *&result)
Add a _Item of data to the N tuple.
virtual ~_Accessor()
Standard Destructor.
Item & operator=(const bool data)
Assignment operator.
StatusCode item(const std::string &name, Array< TYPE > &result)
Locate a Array of data to the N tuple type safe.
Item & operator=(const Item< T > &data)
Assignment operator.
const TYP & data(long i) const
Access to data by reference (CONST)
File(long type, const std::string name, const std::string &logName)
Standard constructor.
TYP * operator[](const T i)
Array operator.
virtual INTupleItem * i_find(const std::string &name) const =0
Internally used by abstract classes.
Item & operator=(const TYP data)
Assignment operator.
A small class used to access easily (and efficiently) data items residing in data stores...
StatusCode addItem(const std::string &name, Item< TYPE > &itm)
Add a scalar data item a N tuple.
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
long m_rows
Number of rows per column.
TYP m_upper
Upper boundary of range.
Range(const Range< bool > &)
Copy constructor.
TYP * m_buffer
Pointer to data buffer.
SmartDataPtr< NTuple::Directory > NTupleDirPtr
Item< TYP > & operator*=(const TYP data)
Array & operator=(const Array< T > ©)
Assignment operator.
const TYP * operator->() const
Dereference operator (CONST)
virtual ~Range()
Destructor.
Range(const bool, const bool)
Standard constructor.
StatusCode item(const std::string &name, Item< TYPE > &result)
Locate a scalar Item of data to the N tuple type safe.
Directory()
Standard constructor.
Opaque address interface definition.
StatusCode i_item(const std::string &name, _Item< TYPE * > *&result) const
Locate a _Column of data to the N tuple type unsafe for objects.
NamedRange_< CONTAINER > range(const CONTAINER &cnt, const std::string &name)
simple function to create the named range form arbitrary container
StatusCode addItem(const std::string &name, long dim, Array< TYPE > &array, const RANGE low, const RANGE high)
Add an fixed-size Array of data to a column wise N tuple with a range.
Class acting as a smart pointer holding a N tuple _Item.
StatusCode i_item(const std::string &name, _Item< IOpaqueAddress * > *&result) const
Locate a _Column of data to the N tuple type safe.
_Accessor()
Standard Constructor.
Range(const TYP low, const TYP upper)
Standard constructor.
Class acting as a smart pointer holding a N tuple _Item.
static bool min()
Minimal number of data.
A DataObject is the base class of any identifiable object on any data store.
Small class representing an N tuple directory in the transient store.
_Accessor< TYP > & operator=(const _Accessor< TYP > &)
bool distance() const
Distance between lower and upper range.
StatusCode item(const std::string &name, Matrix< TYPE > &result)
Locate a Matrix of data to the N tuple type safe.
virtual ~Directory()
Standard destructor.
const std::string & logicalName() const
TYP operator*()
Dereference operator for pointers.
virtual ~Tuple()
Standard destructor.
TYP lower() const
Lower boundary of range.
StatusCode i_item(const std::string &name, _Array< TYPE > *&result) const
Locate a _Array of data to the N tuple type safe.
StatusCode i_addItem(const std::string &name, long, const std::string &, TYPE low, TYPE high, _Item< TYPE > *&result)
Add a _Item of data to the N tuple.
TYP & data(long i)
Access to data by reference (CONST)
Range & operator=(const Range< TYP > ©)
Adjust ranges.
Small class representing an N tuple file in the transient store.
static const CLID & classID()
class ID of the object
virtual long length() const =0
Access the buffer length.
virtual const void * buffer() const =0
Access data buffer (CONST)
Abstract class describing a column-array in a N tuple.