DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
Main.cpp File Reference
#include "dbe/MainWindow.hpp"
#include "dbe/MyApplication.hpp"
#include <QApplication>
#include <boost/program_options.hpp>
#include <memory>
#include "dbe/msghandler.hpp"
#include "dbe/messenger.hpp"
#include "dbe/types.hpp"
#include "dbe/confaccessor.hpp"
Include dependency graph for Main.cpp:

Go to the source code of this file.

Functions

int main (int argc, char *argv[])

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Setting language variable to english(otherwise , is interpreted as . in numbers)

Definition at line 25 of file Main.cpp.

26{
28 setenv("LC_ALL", "C", 1);
29
30 std::unique_ptr<dbe::MyApplication> myapp(new dbe::MyApplication(argc, argv));
31
33
34 std::string configv;
35 std::string oksfn;
36 std::string rdbrl;
37 std::string roksrl;
38 QMap<QString, QString> argmap;
39
40 bop::options_description options_description("Allowed options", 128);
41
42 options_description.add_options()
43 ("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 ("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 bop::variables_map options_map;
59
60 try {
61 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 const auto& unknown = bop::collect_unrecognized(parsed.options, bop::include_positional);
65 if(unknown.size() != 0) {
66 std::cerr << "Incorrect command line argument, unrecognized options: ";
67 for(const auto& o : unknown) {
68 std::cerr << o << " ";
69 }
70 std::cerr << std::endl;
71
72 return EXIT_FAILURE;
73 }
74
75 bop::store(parsed, options_map);
76 bop::notify(options_map);
77
78 auto display_help_message = [&options_description]()
79 {
80 std::cout
81 << "DBE: TDAQ online configuration database editor"
82 << std::endl
83 << std::endl
84 << "Usage: dbe [options]"
85 << std::endl
86 << std::endl
87 << options_description
88 << std::endl;
89 };
90
91 if(options_map.count("help")) {
92 display_help_message();
93 return EXIT_SUCCESS;
94 }
95
96 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 }
102 catch(std::exception const & e) {
103 std::cerr << "Incorrect command line argument: " << e.what() << std::endl;
104 return EXIT_FAILURE;
105 }
106
107 std::unique_ptr<dbe::MainWindow> window(new dbe::MainWindow(argmap));
108 try
109 {
110 window->show();
111 return myapp->exec();
112 }
113 catch (std::exception const & e)
114 {
115 std::cerr << "Exception: " << e.what() << std::endl;
116 }
117 catch (...)
118 {
119 std::cerr << "Unknown Exception" << std::endl;
120 }
121
122 return EXIT_FAILURE;
123}
static void init()