ROOTANA
Loading...
Searching...
No Matches
TGenericData.hxx
Go to the documentation of this file.
1#ifndef TGenericData_hxx_seen
2#define TGenericData_hxx_seen
3
4#include <string>
5#include <iostream>
6#include <inttypes.h>
7
8/// A generic ABC for storing decoded data banks.
9/// Provides methods for accessing unstructured data.
10/// INherited classes will provide more user-friendly data access.
12
13 public:
14
15 TGenericData(int bklen, int bktype, const char* name, void *pdata):fSize(bklen),
16fBankType(bktype), fBankName(name),fData(pdata){
17
18
19 };
20
21 virtual ~TGenericData(){};
22
23 // GetData16()
24 const uint16_t* GetData16() const { return reinterpret_cast<const uint16_t*>(fData); }
25
26 // GetData32()
27 const uint32_t* GetData32() const { return reinterpret_cast<const uint32_t*>(fData); }
28
29 // GetData64()
30 const uint64_t* GetData64() const { return reinterpret_cast<const uint64_t*>(fData); }
31
32 // GetFloat()
33 const float* GetFloat() const { return reinterpret_cast<const float*>(fData); }
34
35 // GetDouble()
36 const double* GetDouble() const { return reinterpret_cast<const double*>(fData); }
37
38 // GetChar()
39 const char* GetChar() const { return reinterpret_cast<const char*>(fData); }
40
41
42 int GetSize() const {return fSize;}
43
44 int GetType() const {return fBankType;}
45
46 std::string GetName() const {return fBankName;}
47
48 /// Dump the bank contents in an unstructured way
49 void Dump(){
50
51 std::cout << "Generic decoder for bank named " << GetName().c_str() << std::endl;
52 for(int i = 0; i < GetSize(); i++){
53 std::cout << std::hex << "0x" << GetData32()[i] << std::dec << std::endl;
54 }
55
56 }
57
58 /// Print the bank contents in a structured way.
59 virtual void Print(){
60 Dump();
61 }
62
63 private:
64
65 /// Size of the bank (in what units?)
66 int fSize;
67
68 /// Bank data type (MIDAS TID_xxx).
70
71 /// Bank name
72 std::string fBankName;
73
74 /// Pointer to the unstructured data.
75 /// The data itself is NOT owned by TGenericData.
76 void *fData;
77
78
79};
80
81#endif
const char * GetChar() const
const uint64_t * GetData64() const
int GetSize() const
std::string fBankName
Bank name.
const uint16_t * GetData16() const
virtual ~TGenericData()
virtual void Print()
Print the bank contents in a structured way.
int GetType() const
int fBankType
Bank data type (MIDAS TID_xxx).
const float * GetFloat() const
TGenericData(int bklen, int bktype, const char *name, void *pdata)
int fSize
Size of the bank (in what units?)
std::string GetName() const
void Dump()
Dump the bank contents in an unstructured way.
const uint32_t * GetData32() const
const double * GetDouble() const