LCOV - code coverage report
Current view: top level - oksutils/apps - oks_refresh.cxx (source / functions) Coverage Total Hit
Test: code.result Lines: 0.0 % 40 0
Test Date: 2026-10-11 15:05:20 Functions: 0.0 % 1 0

            Line data    Source code
       1              : //
       2              : // DUNE DAQ modification notice:
       3              : // This file has been modified from the original ATLAS oks_utils source for the DUNE DAQ project.
       4              : // Fork baseline commit: c2e7dfc7 (2022-03-30).
       5              : // Renamed since fork: yes (from src/bin/oks_refresh.cpp to apps/oks_refresh.cxx).
       6              : //
       7              : 
       8              : /**
       9              :  *  \file oks_validate_repository.cpp
      10              :  *
      11              :  *  This file is part of the OKS package.
      12              :  *  Author: <Igor.Soloviev@cern.ch>
      13              :  */
      14              : 
      15              : #include <stdlib.h>
      16              : 
      17              : #include <boost/program_options.hpp>
      18              : 
      19              : #include "oks/kernel.hpp"
      20              : 
      21              : using namespace dunedaq;
      22              : using namespace dunedaq::oks;
      23              : 
      24              : int
      25            0 : main(int argc, char** argv)
      26              : {
      27            0 :   boost::program_options::options_description desc("This program opens and saves oks files to refresh their format");
      28              : 
      29            0 :   std::vector<std::string> include;
      30            0 :   std::vector<std::string> files;
      31            0 :   bool show_hidden_attributes = false;
      32              : 
      33            0 :   try {
      34            0 :     desc.add_options()("files,f",
      35            0 :                        boost::program_options::value<std::vector<std::string>>(&files)->multitoken()->required(),
      36            0 :                        "oks files")("include,i",
      37            0 :                                     boost::program_options::value<std::vector<std::string>>(&include)->multitoken(),
      38            0 :                                     "preload oks files (to fix missing includes)")(
      39            0 :       "show-all-attributes,x", "show hidden attributes with values equal to defaults")("help,h", "Print help message");
      40              : 
      41            0 :     boost::program_options::variables_map vm;
      42            0 :     boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
      43              : 
      44            0 :     boost::program_options::notify(vm);
      45              : 
      46            0 :     if (vm.count("help")) {
      47            0 :       std::cout << desc << std::endl;
      48            0 :       return EXIT_SUCCESS;
      49              :     }
      50              : 
      51            0 :     if (vm.count("show-all-attributes"))
      52            0 :       show_hidden_attributes = true;
      53            0 :   } catch (std::exception& ex) {
      54            0 :     std::cerr << "Command line parsing errors occurred:\n" << ex.what() << std::endl;
      55            0 :     return EXIT_FAILURE;
      56            0 :   }
      57              : 
      58            0 :   for (const auto& x : files)
      59            0 :     try {
      60            0 :       std::cout << "processing file " << x << std::endl;
      61            0 :       OksKernel kernel(false, false, false, false);
      62              : 
      63            0 :       for (const auto& i : include)
      64            0 :         kernel.load_file(i);
      65              : 
      66            0 :       auto f = kernel.load_file(x);
      67              : 
      68            0 :       if (f->get_oks_format() == "schema")
      69            0 :         kernel.save_schema(f);
      70              :       else
      71            0 :         kernel.save_data(f, true, nullptr, show_hidden_attributes);
      72            0 :     } catch (oks::exception& ex) {
      73            0 :       oks::log_timestamp(oks::Error) << "Caught oks exception:\n" << ex << std::endl;
      74            0 :       return EXIT_FAILURE;
      75            0 :     }
      76              : 
      77            0 :   return EXIT_SUCCESS;
      78            0 : }
        

Generated by: LCOV version 2.0-1