TGenericData.hxx

Go to the documentation of this file.
00001 #ifndef TGenericData_hxx_seen
00002 #define TGenericData_hxx_seen
00003 
00004 #include <string>
00005 #include <iostream>
00006 #include <inttypes.h>
00007 
00008 /// A generic ABC for storing decoded data banks.
00009 /// Provides methods for accessing unstructured data.
00010 /// INherited classes will provide more user-friendly data access.
00011 class TGenericData{
00012 
00013  public:
00014 
00015   TGenericData(int bklen, int bktype, const char* name, void *pdata):fSize(bklen),
00016 fBankType(bktype), fBankName(name),fData(pdata){
00017    
00018 
00019   };
00020 
00021   virtual ~TGenericData(){};
00022 
00023   //  GetData16()
00024   const uint16_t* GetData16() const { return reinterpret_cast<const uint16_t*>(fData); }
00025 
00026   //  GetData32()
00027   const uint32_t* GetData32() const { return reinterpret_cast<const uint32_t*>(fData); }
00028 
00029   //  GetData64()
00030   const uint64_t* GetData64() const { return reinterpret_cast<const uint64_t*>(fData); }
00031 
00032   int GetSize() const {return fSize;}
00033 
00034   int GetType() const {return fBankType;}
00035 
00036   std::string GetName() const {return fBankName;}
00037 
00038   /// Dump the bank contents in an unstructured way
00039   void Dump(){
00040 
00041     std::cout << "Generic decoder for bank named " <<  GetName().c_str() << std::endl;
00042     for(int i = 0; i < GetSize(); i++){
00043       std::cout << std::hex << "0x" << GetData32()[i] << std::dec << std::endl;
00044     }
00045 
00046   }
00047 
00048   /// Print the bank contents in a structured way.
00049   virtual void Print(){
00050     Dump();
00051   }
00052   
00053   private:
00054 
00055   /// Size of the bank (in what units?)
00056   int fSize;
00057 
00058   /// Bank data type (MIDAS TID_xxx).
00059   int fBankType;
00060 
00061   /// Bank name
00062   std::string fBankName;
00063 
00064   /// Pointer to the unstructured data.
00065   /// The data itself is NOT owned by TGenericData.
00066   void *fData;
00067 
00068 
00069 };
00070 
00071 #endif

Generated on 12 Feb 2016 for ROOT Analyzer by  doxygen 1.6.1