LCOV - code coverage report
Current view: top level - dbe/apps - Main.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 54 0
Test Date: 2026-07-12 15:23:06 Functions: 0.0 % 2 0

            Line data    Source code
       1              : // DUNE DAQ modification notice:
       2              : // This file has been modified from the original ATLAS dbe source for the DUNE DAQ project.
       3              : // Fork baseline commit: dbe-02-12-17 (2022-05-12).
       4              : // Renamed since fork: yes (from src/Main.cpp to apps/Main.cpp).
       5              : 
       6              : /// Including DBE
       7              : #include "dbe/MainWindow.hpp"
       8              : #include "dbe/MyApplication.hpp"
       9              : /// Including QT Headers
      10              : #include <QApplication>
      11              : /// Including BOOST
      12              : #include <boost/program_options.hpp>
      13              : 
      14              : #include <memory>
      15              : 
      16              : #include "dbe/msghandler.hpp"
      17              : #include "dbe/messenger.hpp"
      18              : #include "dbe/types.hpp"
      19              : #include "dbe/confaccessor.hpp"
      20              : 
      21              : template class ::lutils::program::msghandler<dbe::interface::messenger::qt>;
      22              : 
      23              : namespace bop = boost::program_options;
      24              : 
      25            0 : int main(int argc, char *argv[])
      26              : {
      27              :         /// Setting language variable to english(otherwise , is interpreted as . in numbers)
      28            0 :         setenv("LC_ALL", "C", 1);
      29              : 
      30            0 :         std::unique_ptr<dbe::MyApplication> myapp(new dbe::MyApplication(argc, argv));
      31              : 
      32            0 :         dbe::confaccessor::init();
      33              : 
      34            0 :         std::string configv;
      35            0 :         std::string oksfn;
      36            0 :         std::string rdbrl;
      37            0 :         std::string roksrl;
      38            0 :         QMap<QString, QString> argmap;
      39              : 
      40            0 :         bop::options_description options_description("Allowed options", 128);
      41              : 
      42            0 :         options_description.add_options()
      43            0 :                         ("help,h", "Provide help message")
      44              : 
      45              :             // ("version,v", bop::value<std::string>(&configv)->default_value(configv),
      46              :             // "OKS version to load (when the GIT back-end is used - valid only in file mode)")
      47              : 
      48            0 :                         ("file,f", bop::value<std::string>(&oksfn)->default_value(oksfn),
      49              :                         "OKS database file name")
      50              : 
      51              :                         // ("rdb,r", bop::value<std::string>(&rdbrl)->default_value(rdbrl),
      52              :                         // "RDB resource locator (e.g. rdbServerName@partitionName)")
      53              : 
      54              :                         // ("roksrl,o",bop::value<std::string>(&roksrl)->default_value(roksrl),
      55              :                         // "ROKS resource locator (e.g. oracle://atlas_oks/r:atlas_oks_archive:<schema version>:<data version>)")
      56              :     ;
      57              : 
      58            0 :         bop::variables_map options_map;
      59              : 
      60            0 :     try {
      61            0 :         bop::parsed_options parsed = bop::command_line_parser(argc, argv).options(options_description).allow_unregistered().run();
      62              : 
      63              :         // This is to properly catch any positional argument (not supported)
      64            0 :         const auto& unknown = bop::collect_unrecognized(parsed.options, bop::include_positional);
      65            0 :         if(unknown.size() != 0) {
      66            0 :             std::cerr << "Incorrect command line argument, unrecognized options: ";
      67            0 :             for(const auto& o : unknown) {
      68            0 :                 std::cerr << o << " ";
      69              :             }
      70            0 :             std::cerr << std::endl;
      71              : 
      72              :             return EXIT_FAILURE;
      73              :         }
      74              : 
      75            0 :         bop::store(parsed, options_map);
      76            0 :         bop::notify(options_map);
      77              : 
      78            0 :         auto display_help_message = [&options_description]()
      79              :         {
      80            0 :             std::cout
      81            0 :             << "DBE: TDAQ online configuration database editor"
      82            0 :             << std::endl
      83            0 :             << std::endl
      84            0 :             << "Usage: dbe [options]"
      85            0 :             << std::endl
      86            0 :             << std::endl
      87            0 :             << options_description
      88            0 :             << std::endl;
      89            0 :         };
      90              : 
      91            0 :         if(options_map.count("help")) {
      92            0 :             display_help_message();
      93              :             return EXIT_SUCCESS;
      94              :         }
      95              : 
      96            0 :         argmap.insert("f", QString::fromStdString(oksfn));
      97              :         // argmap.insert("r", QString::fromStdString(rdbrl));
      98              :         // argmap.insert("o", QString::fromStdString(roksrl));
      99              :         // argmap.insert("v", QString::fromStdString(configv));
     100              : 
     101            0 :     }
     102            0 :     catch(std::exception const & e) {
     103            0 :         std::cerr << "Incorrect command line argument: " << e.what() << std::endl;
     104            0 :         return EXIT_FAILURE;
     105            0 :     }
     106              : 
     107            0 :         std::unique_ptr<dbe::MainWindow> window(new dbe::MainWindow(argmap));
     108            0 :         try
     109              :         {
     110            0 :                 window->show();
     111            0 :                 return myapp->exec();
     112              :         }
     113            0 :         catch (std::exception const & e)
     114              :         {
     115            0 :                 std::cerr << "Exception: " << e.what() << std::endl;
     116            0 :         }
     117            0 :         catch (...)
     118              :         {
     119            0 :                 std::cerr << "Unknown Exception" << std::endl;
     120            0 :         }
     121              : 
     122              :         return EXIT_FAILURE;
     123            0 : }
        

Generated by: LCOV version 2.0-1