LCOV - code coverage report
Current view: top level - opmonlib/plugins - fileOpMonFacility.hpp (source / functions) Coverage Total Hit
Test: code.result Lines: 100.0 % 4 4
Test Date: 2026-10-11 15:05:20 Functions: 19.4 % 31 6

            Line data    Source code
       1              : /**
       2              :  * @file fileOpMonFacility.hpp
       3              :  *
       4              :  * This is part of the DUNE DAQ Application Framework, copyright 2020.
       5              :  * Licensing/copyright details are in the COPYING file that you should have
       6              :  * received with this code.
       7              :  */
       8              : 
       9              : #ifndef OPMONLIB_PLUGIN_FILEOPMONFACILITY_HPP_
      10              : #define OPMONLIB_PLUGIN_FILEOPMONFACILITY_HPP_
      11              : 
      12              : #include <opmonlib/JSonOpMonFacility.hpp>
      13              : 
      14              : #include <condition_variable>
      15              : #include <fstream>
      16              : #include <mutex>
      17              : 
      18              : namespace dunedaq {
      19              : 
      20            4 : ERS_DECLARE_ISSUE(opmonlib, BadFile, "Can not open file: " << filename, ((std::string)filename))
      21              : 
      22            2 : ERS_DECLARE_ISSUE(opmonlib, WritingFailed, "Failed to write. Message: " << message, ((std::string)message))
      23              : 
      24            2 : ERS_DECLARE_ISSUE(opmonlib,
      25              :                   FacilityStopRequested,
      26              :                   "Facility about to be destroyed and cannot write messages anymore.",
      27              :                   ERS_EMPTY)
      28              : 
      29            2 : ERS_DECLARE_ISSUE(opmonlib,
      30              :                   FileClosedBeforeWritingComplete,
      31              :                   "Facility was destroyed after " << milliseconds << " ms with " << counter
      32              :                                                   << " entries yet to be written",
      33              :                   ((uint16_t)milliseconds)((uint16_t)counter))
      34              : 
      35              : } // namespace dunedaq
      36              : 
      37              : namespace dunedaq::opmonlib {
      38              : 
      39              : class fileOpMonFacility : public JSonOpMonFacility
      40              : {
      41              : 
      42              : public:
      43              :   explicit fileOpMonFacility(std::string uri, OptionalOrigin);
      44              :   ~fileOpMonFacility();
      45              : 
      46              :   void publish(opmon::OpMonEntry&& e) const override;
      47              : 
      48              : private:
      49              :   void write(opmon::OpMonEntry&& e) const noexcept;
      50              : 
      51              :   mutable std::ofstream m_ofs;
      52              :   mutable std::mutex m_mutex;
      53              :   mutable std::condition_variable m_writing_variable;
      54              :   mutable std::atomic<uint16_t> m_writing_counter{ 0 };
      55              :   mutable std::atomic<bool> m_stop_request{ false };
      56              : };
      57              : 
      58              : } // namespace dunedaq::opmonlib
      59              : 
      60              : #endif // OPMONLIB_PLUGIN_FILEOPMONFACILITY_HPP_
        

Generated by: LCOV version 2.0-1