DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
oks_refresh.cxx
Go to the documentation of this file.
1
8#include <stdlib.h>
9
10#include <boost/program_options.hpp>
11
12#include "oks/kernel.hpp"
13
14using namespace dunedaq;
15using namespace dunedaq::oks;
16
17int
18main(int argc, char **argv)
19{
20 boost::program_options::options_description desc("This program opens and saves oks files to refresh their format");
21
22 std::vector<std::string> include;
23 std::vector<std::string> files;
24 bool show_hidden_attributes = false;
25
26 try
27 {
28 desc.add_options()
29 ("files,f", boost::program_options::value<std::vector<std::string> >(&files)->multitoken()->required(), "oks files")
30 ("include,i", boost::program_options::value<std::vector<std::string> >(&include)->multitoken(), "preload oks files (to fix missing includes)")
31 ("show-all-attributes,x", "show hidden attributes with values equal to defaults")
32 ("help,h", "Print help message");
33
34 boost::program_options::variables_map vm;
35 boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
36
37 boost::program_options::notify(vm);
38
39 if (vm.count("help"))
40 {
41 std::cout << desc << std::endl;
42 return EXIT_SUCCESS;
43 }
44
45 if (vm.count("show-all-attributes"))
46 show_hidden_attributes = true;
47 }
48 catch (std::exception& ex)
49 {
50 std::cerr << "Command line parsing errors occurred:\n" << ex.what() << std::endl;
51 return EXIT_FAILURE;
52 }
53
54 for (const auto &x : files)
55 try
56 {
57 std::cout << "processing file " << x << std::endl;
58 OksKernel kernel(false, false, false, false);
59
60 for(const auto& i : include)
61 kernel.load_file(i);
62
63 auto f = kernel.load_file(x);
64
65 if (f->get_oks_format() == "schema")
66 kernel.save_schema(f);
67 else
68 kernel.save_data(f, true, nullptr, show_hidden_attributes);
69 }
70 catch (oks::exception &ex)
71 {
72 oks::log_timestamp(oks::Error) << "Caught oks exception:\n" << ex << std::endl;
73 return EXIT_FAILURE;
74 }
75
76 return EXIT_SUCCESS;
77}
Provides interface to the OKS kernel.
Definition kernel.hpp:577
OksFile * load_file(const std::string &name, bool bind=true)
Load OKS database file.
Definition kernel.cpp:1788
void save_schema(OksFile *file_h, bool force=false, OksFile *true_file_h=0)
Save OKS schema file.
Definition kernel.cpp:2538
void save_data(OksFile *file_h, bool ignore_bad_objects=false, OksFile *true_file_h=nullptr, bool force_defaults=false)
Save OKS data file.
Definition kernel.cpp:3794
Including Qt Headers.
int main(int argc, char **argv)