LCOV - code coverage report
Current view: top level - listrev/plugins - ListReverser.hpp (source / functions) Coverage Total Hit
Test: code.result Lines: 100.0 % 7 7
Test Date: 2026-08-30 15:04:40 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /**
       2              :  * @file ListReverser.hpp
       3              :  *
       4              :  * ListReverser is a simple DAQModule implementation that reads a list
       5              :  * of integers from one queue, reverses their order in the list, and pushes
       6              :  * the reversed list onto another queue.
       7              :  *
       8              :  * This is part of the DUNE DAQ Software Suite, copyright 2020.
       9              :  * Licensing/copyright details are in the COPYING file that you should have
      10              :  * received with this code.
      11              :  */
      12              : 
      13              : #ifndef LISTREV_PLUGINS_LISTREVERSER_HPP_
      14              : #define LISTREV_PLUGINS_LISTREVERSER_HPP_
      15              : 
      16              : #include "ListStorage.hpp"
      17              : #include "ListWrapper.hpp"
      18              : 
      19              : #include "appfwk/DAQModule.hpp"
      20              : #include "iomanager/Receiver.hpp"
      21              : #include "iomanager/Sender.hpp"
      22              : #include "utilities/WorkerThread.hpp"
      23              : 
      24              : #include "ers/Issue.hpp"
      25              : #include "logging/Logging.hpp" // NOTE: if ISSUES ARE DECLARED BEFORE include logging/Logging.hpp, TLOG_DEBUG<<issue wont work.
      26              : 
      27              : #include <map>
      28              : #include <memory>
      29              : #include <random>
      30              : #include <string>
      31              : #include <vector>
      32              : 
      33              : namespace dunedaq {
      34              : namespace listrev {
      35              : 
      36              : /**
      37              :  * @brief ListReverser reads lists of integers from one queue,
      38              :  * reverses the order of the list, and writes out the reversed list.
      39              :  */
      40              : class ListReverser : public dunedaq::appfwk::DAQModule
      41              : {
      42              : public:
      43              :   /**
      44              :    * @brief ListReverser Constructor
      45              :    * @param name Instance name for this ListReverser instance
      46              :    */
      47              :   explicit ListReverser(const std::string& name);
      48              : 
      49              :   ListReverser(const ListReverser&) = delete;            ///< ListReverser is not copy-constructible
      50              :   ListReverser& operator=(const ListReverser&) = delete; ///< ListReverser is not copy-assignable
      51              :   ListReverser(ListReverser&&) = delete;                 ///< ListReverser is not move-constructible
      52              :   ListReverser& operator=(ListReverser&&) = delete;      ///< ListReverser is not move-assignable
      53              : 
      54              :   void init(std::shared_ptr<appfwk::ConfigurationManager> mcfg) override;
      55              : 
      56              : protected:
      57              :   void generate_opmon_data() override;
      58              : 
      59              : private:
      60              :   // Commands
      61              :   void do_start(const CommandData_t& obj);
      62              :   void do_stop(const CommandData_t& obj);
      63              : 
      64              :   // Callbacks
      65              :   void process_list_request(const RequestList& request);
      66              :   void process_list(const IntList& list);
      67              : 
      68              :   // Data
      69              :   struct PendingList
      70              :   {
      71              :     std::string requestor;
      72              :     std::chrono::steady_clock::time_point start_time;
      73              :     ReversedList list;
      74              : 
      75            2 :     PendingList() = default;
      76            2 :     explicit PendingList(std::string req, int list_id, int rev_id)
      77            2 :       : requestor(req)
      78            2 :       , start_time(std::chrono::steady_clock::now())
      79              :     {
      80            2 :       list.list_id = list_id;
      81            2 :       list.reverser_id = rev_id;
      82            2 :     }
      83              :   };
      84              :   std::map<int, PendingList> m_pending_lists;
      85              :   mutable std::mutex m_map_mutex;
      86              : 
      87              :   // Init
      88              :   std::string m_requests;
      89              :   std::string m_list_connection;
      90              : 
      91              :   // Configuration
      92              :   std::chrono::milliseconds m_send_timeout{ 100 };
      93              :   std::chrono::milliseconds m_request_timeout{ 1000 };
      94              :   size_t m_reverser_id{ 0 };
      95              : 
      96              :   std::vector<std::string> m_generator_connections;
      97              : 
      98              :   // Monitoring
      99              :   std::atomic<uint64_t> m_requests_received{ 0 };       // NOLINT(build/unsigned)
     100              :   std::atomic<uint64_t> m_requests_sent{ 0 };           // NOLINT(build/unsigned)
     101              :   std::atomic<uint64_t> m_lists_received{ 0 };          // NOLINT(build/unsigned)
     102              :   std::atomic<uint64_t> m_lists_sent{ 0 };              // NOLINT(build/unsigned)
     103              :   std::atomic<uint64_t> m_total_requests_received{ 0 }; // NOLINT(build/unsigned)
     104              :   std::atomic<uint64_t> m_total_requests_sent{ 0 };     // NOLINT(build/unsigned)
     105              :   std::atomic<uint64_t> m_total_lists_received{ 0 };    // NOLINT(build/unsigned)
     106              :   std::atomic<uint64_t> m_total_lists_sent{ 0 };        // NOLINT(build/unsigned)
     107              : };
     108              : } // namespace listrev
     109              : 
     110              : // Disable coverage collection LCOV_EXCL_START
     111              : ERS_DECLARE_ISSUE(listrev,
     112              :                   UnexpectedListError,
     113              :                   name << " received list id " << id << " from " << generator <<  " with no pending request",
     114              :                   ((std::string)name)((int)id)((int)generator)) // NOLINT(readability/casting)
     115              : // Re-enable coverage collection LCOV_EXCL_STOP
     116              : 
     117              : } // namespace dunedaq
     118              : 
     119              : #endif // LISTREV_PLUGINS_LISTREVERSER_HPP_
     120              : 
     121              : // Local Variables:
     122              : // c-basic-offset: 2
     123              : // End:
        

Generated by: LCOV version 2.0-1