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: 2025-12-21 13:07:08 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::listrev {
      34              : 
      35              : /**
      36              :  * @brief ListReverser reads lists of integers from one queue,
      37              :  * reverses the order of the list, and writes out the reversed list.
      38              :  */
      39              : class ListReverser : public dunedaq::appfwk::DAQModule
      40              : {
      41              : public:
      42              :   /**
      43              :    * @brief ListReverser Constructor
      44              :    * @param name Instance name for this ListReverser instance
      45              :    */
      46              :   explicit ListReverser(const std::string& name);
      47              : 
      48              :   ListReverser(const ListReverser&) = delete;            ///< ListReverser is not copy-constructible
      49              :   ListReverser& operator=(const ListReverser&) = delete; ///< ListReverser is not copy-assignable
      50              :   ListReverser(ListReverser&&) = delete;                 ///< ListReverser is not move-constructible
      51              :   ListReverser& operator=(ListReverser&&) = delete;      ///< ListReverser is not move-assignable
      52              : 
      53              :   void init(std::shared_ptr<appfwk::ConfigurationManager> mcfg) override;
      54              : 
      55              : protected:
      56              :   void generate_opmon_data() override;
      57              : 
      58              : private:
      59              :   // Commands
      60              :   void do_start(const CommandData_t& obj);
      61              :   void do_stop(const CommandData_t& obj);
      62              : 
      63              :   // Callbacks
      64              :   void process_list_request(const RequestList& request);
      65              :   void process_list(const IntList& list);
      66              : 
      67              :   // Data
      68              :   struct PendingList
      69              :   {
      70              :     std::string requestor;
      71              :     std::chrono::steady_clock::time_point start_time;
      72              :     ReversedList list;
      73              : 
      74            2 :     PendingList() = default;
      75            2 :     explicit PendingList(std::string req, int list_id, int rev_id)
      76            2 :       : requestor(req)
      77            2 :       , start_time(std::chrono::steady_clock::now())
      78              :     {
      79            2 :       list.list_id = list_id;
      80            2 :       list.reverser_id = rev_id;
      81            2 :     }
      82              :   };
      83              :   std::map<int, PendingList> m_pending_lists;
      84              :   mutable std::mutex m_map_mutex;
      85              : 
      86              :   // Init
      87              :   std::string m_requests;
      88              :   std::string m_list_connection;
      89              : 
      90              :   // Configuration
      91              :   std::chrono::milliseconds m_send_timeout{ 100 };
      92              :   std::chrono::milliseconds m_request_timeout{ 1000 };
      93              :   size_t m_reverser_id{ 0 };
      94              : 
      95              :   std::vector<std::string> m_generator_connections;
      96              : 
      97              :   // Monitoring
      98              :   std::atomic<uint64_t> m_requests_received{ 0 };       // NOLINT(build/unsigned)
      99              :   std::atomic<uint64_t> m_requests_sent{ 0 };           // NOLINT(build/unsigned)
     100              :   std::atomic<uint64_t> m_lists_received{ 0 };          // NOLINT(build/unsigned)
     101              :   std::atomic<uint64_t> m_lists_sent{ 0 };              // NOLINT(build/unsigned)
     102              :   std::atomic<uint64_t> m_total_requests_received{ 0 }; // NOLINT(build/unsigned)
     103              :   std::atomic<uint64_t> m_total_requests_sent{ 0 };     // NOLINT(build/unsigned)
     104              :   std::atomic<uint64_t> m_total_lists_received{ 0 };    // NOLINT(build/unsigned)
     105              :   std::atomic<uint64_t> m_total_lists_sent{ 0 };        // NOLINT(build/unsigned)
     106              : };
     107              : } // namespace dunedaq::listrev
     108              : 
     109              : #endif // LISTREV_PLUGINS_LISTREVERSER_HPP_
     110              : 
     111              : // Local Variables:
     112              : // c-basic-offset: 2
     113              : // End:
        

Generated by: LCOV version 2.0-1