LCOV - code coverage report
Current view: top level - asiolibs/src - GenericReceiverModel.hpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 11 0
Test Date: 2026-10-11 15:05:20 Functions: 0.0 % 4 0

            Line data    Source code
       1              : /**
       2              :  * @file GenericReceiverModel.hpp Generic IOManager Receiver model
       3              :  *
       4              :  * This is part of the DUNE DAQ , copyright 2020.
       5              :  * Licensing/copyright details are in the COPYING file that you should have
       6              :  * received with this code.
       7              :  */
       8              : #ifndef ASIOLIBS_SRC_GENERICRECEIVERMODEL_HPP_
       9              : #define ASIOLIBS_SRC_GENERICRECEIVERMODEL_HPP_
      10              : 
      11              : #include "GenericReceiverConcept.hpp"
      12              : 
      13              : #include <memory>
      14              : #include <string>
      15              : #include <utility>
      16              : 
      17              : namespace dunedaq::asiolibs {
      18              : 
      19              : template<class TargetPayloadType>
      20              : class GenericReceiverModel : public GenericReceiverConcept
      21              : {
      22              : public:
      23            0 :   explicit GenericReceiverModel(const std::string& receiver_connection_name)
      24            0 :     : m_receiver(get_iom_receiver<TargetPayloadType>(receiver_connection_name))
      25              :   {
      26            0 :   }
      27              : 
      28            0 :   std::optional<TypeErasedPayload> try_receive(dunedaq::iomanager::Receiver::timeout_t timeout) override
      29              :   {
      30            0 :     auto opt_payload = m_receiver->try_receive(timeout);
      31            0 :     if (opt_payload) {
      32              :       // Allocate the received payload on the heap with shared ownership,
      33              :       // so its lifetime can outlive this function and be tied to async sends.
      34            0 :       auto payload = std::make_shared<TargetPayloadType>(std::move(*opt_payload));
      35            0 :       return TypeErasedPayload{ std::reinterpret_pointer_cast<const void>(payload), payload.get(), sizeof(*payload) };
      36            0 :     }
      37            0 :     return std::nullopt;
      38            0 :   }
      39              : 
      40              : private:
      41              :   /**
      42              :    * @brief Generic IOManager Receiver
      43              :    */
      44              :   std::shared_ptr<iomanager::ReceiverConcept<TargetPayloadType>> m_receiver;
      45              : };
      46              : 
      47              : } // namespace dunedaq::asiolibs
      48              : 
      49              : #endif // ASIOLIBS_SRC_GENERICRECEIVERMODEL_HPP_
        

Generated by: LCOV version 2.0-1