LCOV - code coverage report
Current view: top level - artdaq/ArtModules - PrintBuildInfo_module.cc (source / functions) Coverage Total Hit
Test: artdaq.info.cleaned Lines: 0.0 % 34 0
Test Date: 2025-09-04 00:45:34 Functions: 0.0 % 11 0

            Line data    Source code
       1              : ////////////////////////////////////////////////////////////////////////
       2              : // Class:       PrintBuildInfo
       3              : // Module Type: analyzer
       4              : // File:        PrintBuildInfo_module.cc
       5              : //
       6              : // Generated at Fri Aug 15 21:05:07 2014 by lbnedaq using artmod
       7              : // from cetpkgsupport v1_05_02.
       8              : ////////////////////////////////////////////////////////////////////////
       9              : 
      10              : #include "TRACE/tracemf.h"
      11              : 
      12              : #include "artdaq-core/Data/PackageBuildInfo.hh"
      13              : 
      14              : #include "art/Framework/Core/EDAnalyzer.h"
      15              : #include "art/Framework/Core/ModuleMacros.h"
      16              : #include "art/Framework/Principal/Event.h"
      17              : #include "art/Framework/Principal/Handle.h"
      18              : #include "art/Framework/Principal/Run.h"
      19              : #include "art/Framework/Principal/SubRun.h"
      20              : #include "canvas/Utilities/InputTag.h"
      21              : #include "fhiclcpp/ParameterSet.h"
      22              : 
      23              : #include <iostream>
      24              : 
      25              : #define TRACE_NAME "PrintBuildInfo"
      26              : 
      27              : namespace artdaq {
      28              : class PrintBuildInfo;
      29              : }
      30              : 
      31              : /**
      32              :  * \brief An art::EDAnalyzer which prints any artdaq::BuildInfo objects stored in the run
      33              :  */
      34              : class artdaq::PrintBuildInfo : public art::EDAnalyzer
      35              : {
      36              : public:
      37              :         /**
      38              :          * \brief PrintBuildInfo Constructor
      39              :          * \param p ParameterSet used to configure PrintBuildInfo
      40              :          *
      41              :          * \verbatim
      42              :          * PrintBuildInfo accepts the following Parameters:
      43              :          * "buildinfo_module_label" (REQUIRED): The module label for the BuildInfo objects
      44              :          * "buildinfo_instance_label" (REQUIRED): The instance label for the BuildInfo objects
      45              :          * \endverbatim
      46              :          *
      47              :          * These parameters should match those given to the BuildInfo module
      48              :          */
      49              :         explicit PrintBuildInfo(fhicl::ParameterSet const& p);
      50              : 
      51              :         /**
      52              :          * \brief Default virtual Destructor
      53              :          */
      54            0 :         ~PrintBuildInfo() override = default;
      55              : 
      56              :         /**
      57              :          * \brief Called for each event. Required overload for art::EDAnalyzer, No-Op here.
      58              :          */
      59            0 :         void analyze(art::Event const& /*unused*/) override {}
      60              : 
      61              :         /**
      62              :          * \brief Perform actions at the beginning of the run
      63              :          * \param run art::Run object
      64              :          *
      65              :          * This function pretty-prints the BuildInfo information form the run object with the
      66              :          * configured module label and instance label.
      67              :          */
      68              :         void beginRun(art::Run const& run) override;
      69              : 
      70              : private:
      71              :         PrintBuildInfo(PrintBuildInfo const&) = delete;
      72              :         PrintBuildInfo(PrintBuildInfo&&) = delete;
      73              :         PrintBuildInfo& operator=(PrintBuildInfo const&) = delete;
      74              :         PrintBuildInfo& operator=(PrintBuildInfo&&) = delete;
      75              : 
      76              :         std::string buildinfo_module_label_;
      77              :         std::string buildinfo_instance_label_;
      78              : };
      79              : 
      80            0 : artdaq::PrintBuildInfo::PrintBuildInfo(fhicl::ParameterSet const& pset)
      81              :     : EDAnalyzer(pset)
      82            0 :     , buildinfo_module_label_(pset.get<std::string>("buildinfo_module_label"))
      83            0 :     , buildinfo_instance_label_(pset.get<std::string>("buildinfo_instance_label")) {}
      84              : 
      85            0 : void artdaq::PrintBuildInfo::beginRun(art::Run const& run)
      86              : {
      87            0 :         art::Handle<std::vector<artdaq::PackageBuildInfo>> raw;
      88              : 
      89            0 :         TLOG(TLVL_INFO) << "Calling getByLabel: module label: " << buildinfo_module_label_ << ", instance label: " << buildinfo_instance_label_;
      90            0 :         run.getByLabel(buildinfo_module_label_, buildinfo_instance_label_, raw);
      91              : 
      92            0 :         if (raw.isValid())
      93              :         {
      94            0 :                 std::cout << "--------------------------------------------------------------" << std::endl;
      95            0 :                 std::cout.width(20);
      96            0 :                 std::cout << std::left << "Package"
      97            0 :                           << "|";
      98            0 :                 std::cout.width(20);
      99            0 :                 std::cout << std::left << "Version"
     100            0 :                           << "|";
     101            0 :                 std::cout.width(20);
     102            0 :                 std::cout << std::left << "Timestamp" << std::endl;
     103              : 
     104            0 :                 for (const auto& pkg : *raw)
     105              :                 {
     106            0 :                         std::cout.width(20);
     107            0 :                         std::cout << std::left << pkg.getPackageName() << "|";
     108            0 :                         std::cout.width(20);
     109            0 :                         std::cout << std::left << pkg.getPackageVersion() << "|";
     110            0 :                         std::cout.width(20);
     111            0 :                         std::cout << std::left << pkg.getBuildTimestamp() << std::endl;
     112              :                 }
     113              : 
     114            0 :                 std::cout << "--------------------------------------------------------------" << std::endl;
     115              :         }
     116              :         else
     117              :         {
     118            0 :                 std::cerr << "\n"
     119            0 :                           << std::endl;
     120            0 :                 std::cerr << "Warning in artdaq::PrintBuildInfo module: Run " << run.run() << " appears not to have found product instance \"" << buildinfo_instance_label_ << "\" of module \"" << buildinfo_module_label_ << "\"" << std::endl;
     121            0 :                 std::cerr << "\n"
     122            0 :                           << std::endl;
     123              :         }
     124            0 : }
     125              : 
     126            0 : DEFINE_ART_MODULE(artdaq::PrintBuildInfo)  // NOLINT(performance-unnecessary-value-param)
        

Generated by: LCOV version 2.0-1