LCOV - code coverage report
Current view: top level - mu2e-pcie-utils/dtcInterfaceLib/test - fragmentTester.h (source / functions) Coverage Total Hit
Test: mu2edaq.info.cleaned Lines: 0.0 % 18 0
Test Date: 2026-07-30 01:56:44 Functions: 0.0 % 8 0

            Line data    Source code
       1              : #pragma once
       2              : #include <vector>
       3              : 
       4              : #define BLOCK_COUNT_MAX 10000
       5              : 
       6              : /// <summary>
       7              : /// A small pseudo-Fragment used for testing
       8              : /// </summary>
       9              : class fragmentTester
      10              : {
      11              :   public:
      12              :         /// <summary>
      13              :         /// Construct a fragmentTester object with the given initial size
      14              :         /// </summary>
      15              :         /// <param name="bytes">Initial size of the fragmentTester object</param>
      16            0 :         explicit fragmentTester(size_t bytes)
      17            0 :             : vals_(bytes)
      18            0 :             , block_count(0) {}
      19              : 
      20            0 :         ~fragmentTester() = default;
      21              : 
      22              :         /// <summary>
      23              :         /// Get the size of the data (excluding header information), in bytes
      24              :         /// </summary>
      25              :         /// <returns>Size of the data, in bytes</returns>
      26            0 :         size_t dataSize()
      27              :         {
      28            0 :                 if(block_count == 0)
      29              :                 {
      30            0 :                         return 0;
      31              :                 }
      32            0 :                 return blocks[block_count - 1];
      33              :         }
      34              : 
      35              :         /// <summary>
      36              :         /// Get the size of the pseudo-Fragment, in bytes
      37              :         /// </summary>
      38              :         /// <returns>Size of the Fragment data, in bytes</returns>
      39            0 :         size_t fragSize() const { return vals_.size(); }
      40              : 
      41              :         /// <summary>
      42              :         /// Adds space in the data vector
      43              :         /// </summary>
      44              :         /// <param name="bytes">Amount of space to add</param>
      45            0 :         void addSpace(size_t bytes) { vals_.resize(vals_.size() + bytes); }
      46              : 
      47              :         /// <summary>
      48              :         /// Get a pointer to the start of the data
      49              :         /// </summary>
      50              :         /// <returns>Pointer to the start of the data</returns>
      51            0 :         uint8_t* dataBegin() { return reinterpret_cast<uint8_t*>(&vals_[0]); }
      52              : 
      53              :         /// <summary>
      54              :         /// Flag event completion, updates block size array and block counter
      55              :         /// </summary>
      56              :         /// <param name="bytes">Bytes in this block</param>
      57            0 :         void endSubEvt(size_t bytes)
      58              :         {
      59            0 :                 if(block_count > 0)
      60              :                 {
      61            0 :                         blocks[block_count] = blocks[block_count - 1] + bytes;
      62              :                 }
      63              :                 else
      64              :                 {
      65            0 :                         blocks[0] = bytes;
      66              :                 }
      67            0 :                 block_count++;
      68            0 :         }
      69              : 
      70              :         /// <summary>
      71              :         /// Get the block count of the pseudo-Fragment
      72              :         /// </summary>
      73              :         /// <returns>The block count of the Fragment</returns>
      74            0 :         size_t hdr_block_count() const { return block_count; }
      75              : 
      76              :   private:
      77              :         std::vector<uint8_t> vals_;
      78              :         size_t               blocks[BLOCK_COUNT_MAX];
      79              :         size_t               block_count;
      80              : };
        

Generated by: LCOV version 2.0-1