LCOV - code coverage report
Current view: top level - midasio - midasio.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 4 0
Test Date: 2025-11-11 10:26:08 Functions: 0.0 % 2 0

            Line data    Source code
       1              : // midasio.h
       2              : 
       3              : #ifndef MIDASIO_H
       4              : #define MIDASIO_H
       5              : 
       6              : #include <string>
       7              : #include <vector>
       8              : #include <stdint.h>
       9              : 
      10              : #ifndef TID_LAST
      11              : /**
      12              : MIDAS Data Type Definitions                             min      max    */
      13              : #define TID_BYTE      1       /**< DEPRECATED, use TID_UINT8 instead    */
      14              : #define TID_UINT8     1       /**< unsigned byte         0       255    */
      15              : #define TID_SBYTE     2       /**< DEPRECATED, use TID_INT8 instead     */
      16              : #define TID_INT8      2       /**< signed byte         -128      127    */
      17              : #define TID_CHAR      3       /**< single character      0       255    */
      18              : #define TID_WORD      4       /**< DEPRECATED, use TID_UINT16 instead   */
      19              : #define TID_UINT16    4       /**< two bytes             0      65535   */
      20              : #define TID_SHORT     5       /**< DEPRECATED, use TID_INT16 instead    */
      21              : #define TID_INT16     5       /**< signed word        -32768    32767   */
      22              : #define TID_DWORD     6       /**< DEPRECATED, use TID_UINT32 instead   */
      23              : #define TID_UINT32    6       /**< four bytes            0      2^32-1  */
      24              : #define TID_INT       7       /**< DEPRECATED, use TID_INT32 instead    */
      25              : #define TID_INT32     7       /**< signed dword        -2^31    2^31-1  */
      26              : #define TID_BOOL      8       /**< four bytes bool       0        1     */
      27              : #define TID_FLOAT     9       /**< 4 Byte float format                  */
      28              : #define TID_FLOAT32   9       /**< 4 Byte float format                  */
      29              : #define TID_DOUBLE   10       /**< 8 Byte float format                  */
      30              : #define TID_FLOAT64  10       /**< 8 Byte float format                  */
      31              : #define TID_BITFIELD 11       /**< 32 Bits Bitfield      0  111... (32) */
      32              : #define TID_STRING   12       /**< zero terminated string               */
      33              : #define TID_ARRAY    13       /**< array with unknown contents          */
      34              : #define TID_STRUCT   14       /**< structure with fixed length          */
      35              : #define TID_KEY      15       /**< key in online database               */
      36              : #define TID_LINK     16       /**< link in online database              */
      37              : #define TID_INT64    17       /**< 8 bytes int          -2^63   2^63-1  */
      38              : #define TID_UINT64   18       /**< 8 bytes unsigned int  0      2^64-1  */
      39              : #define TID_QWORD    18       /**< 8 bytes unsigned int  0      2^64-1  */
      40              : #define TID_LAST     19       /**< end of TID list indicator            */
      41              : #endif
      42              : 
      43            0 : class TMBank
      44              : {
      45              :  public:
      46              :    std::string name;            ///< bank name, 4 characters max
      47              :    uint32_t    type = 0;        ///< type of bank data, enum of TID_xxx
      48              :    uint32_t    data_size   = 0; ///< size of bank data in bytes
      49              :    size_t      data_offset = 0; ///< offset of data for this bank in the event data[] container
      50              : };
      51              : 
      52            0 : class TMEvent
      53              : {
      54              : public: // event data
      55              :    bool error;                  ///< event has an error - incomplete, truncated, inconsistent or corrupted
      56              :    
      57              :    uint16_t event_id;           ///< MIDAS event ID
      58              :    uint16_t trigger_mask;       ///< MIDAS trigger mask
      59              :    uint32_t serial_number;      ///< MIDAS event serial number
      60              :    uint32_t time_stamp;         ///< MIDAS event time stamp (unix time in sec)
      61              :    uint32_t data_size;          ///< MIDAS event data size
      62              : 
      63              :    size_t   event_header_size;  ///< size of MIDAS event header
      64              :    uint32_t bank_header_flags;  ///< flags from the MIDAS event bank header
      65              : 
      66              :    std::vector<TMBank> banks;   ///< list of MIDAS banks, fill using FindAllBanks()
      67              :    std::vector<char> data;      ///< MIDAS event bytes
      68              : 
      69              : public: // internal data
      70              : 
      71              :    bool found_all_banks;        ///< all the banks in the event data have been discovered
      72              :    size_t bank_scan_position;   ///< location where scan for MIDAS banks was last stopped
      73              : 
      74              : public: // constructors
      75              :    TMEvent(); // ctor
      76              :    TMEvent(const void* buf, size_t buf_size); // ctor
      77              :    void Reset();       ///< reset everything
      78              :    void ParseEvent();  ///< parse event data
      79              :    void ParseHeader(const void* buf, size_t buf_size); ///< parse event header
      80              :    void Init(uint16_t event_id, uint16_t trigger_mask = 0, uint32_t serial_number = 0, uint32_t time_stamp = 0, size_t capacity = 0);
      81              : 
      82              : public: // read data
      83              :    void FindAllBanks();                      ///< scan the MIDAS event, find all data banks
      84              :    TMBank* FindBank(const char* bank_name);  ///< scan the MIDAS event
      85              :    char* GetEventData();                     ///< get pointer to MIDAS event data
      86              :    const char* GetEventData() const;         ///< get pointer to MIDAS event data
      87              :    char* GetBankData(const TMBank*);         ///< get pointer to MIDAS data bank
      88              :    const char* GetBankData(const TMBank*) const; ///< get pointer to MIDAS data bank
      89              : 
      90              : public: // add data
      91              :    void AddBank(const char* bank_name, int tid, const char* buf, size_t size); ///< add new MIDAS bank
      92              : 
      93              : public: // bank manipulation
      94              :    //void DeleteBank(const TMBank*);           ///< delete MIDAS bank
      95              : 
      96              : public: // information methods
      97              : 
      98              :    std::string HeaderToString() const;            ///< print the MIDAS event header
      99              :    std::string BankListToString() const;          ///< print the list of MIDAS banks
     100              :    std::string BankToString(const TMBank*) const; ///< print definition of one MIDAS bank
     101              : 
     102              :    void PrintHeader() const;
     103              :    void PrintBanks(int level = 0);
     104              :    void DumpHeader() const;
     105              : };
     106              : 
     107              : class TMReaderInterface
     108              : {
     109              :  public:
     110              :    TMReaderInterface(); // ctor
     111              :    virtual int Read(void* buf, int count) = 0;
     112              :    virtual int Close() = 0;
     113            0 :    virtual ~TMReaderInterface() {};
     114              :  public:
     115              :    bool fError;
     116              :    std::string fErrorString;
     117              :    static bool fgTrace;
     118              : };
     119              : 
     120              : class TMWriterInterface
     121              : {
     122              :  public:
     123              :    virtual int Write(const void* buf, int count) = 0;
     124              :    virtual int Close() = 0;
     125            0 :    virtual ~TMWriterInterface() {};
     126              :  public:
     127              :    static bool fgTrace;
     128              : };
     129              : 
     130              : TMReaderInterface* TMNewReader(const char* source);
     131              : TMWriterInterface* TMNewWriter(const char* destination);
     132              : 
     133              : TMEvent* TMReadEvent(TMReaderInterface* reader);
     134              : void TMWriteEvent(TMWriterInterface* writer, const TMEvent* event);
     135              : 
     136              : extern bool TMTraceCtorDtor;
     137              : 
     138              : #endif
     139              : 
     140              : /* emacs
     141              :  * Local Variables:
     142              :  * tab-width: 8
     143              :  * c-basic-offset: 3
     144              :  * indent-tabs-mode: nil
     145              :  * End:
     146              :  */
     147              : 
        

Generated by: LCOV version 2.0-1