DUNE-DAQ
DUNE Trigger and Data Acquisition software
Toggle main menu visibility
Loading...
Searching...
No Matches
dunedaq
sourcecode
oksutils
apps
oks_report_no_descriptions.cxx
Go to the documentation of this file.
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_report_no_descriptions.cpp to apps/oks_report_no_descriptions.cxx).
6
//
7
16
17
#include <stdlib.h>
18
19
#include "
oks/attribute.hpp
"
20
#include "
oks/relationship.hpp
"
21
#include "
oks/class.hpp
"
22
#include "
oks/kernel.hpp
"
23
#include "
oks/file.hpp
"
24
#include "
oks/exceptions.hpp
"
25
26
using namespace
dunedaq
;
27
using namespace
dunedaq::oks
;
28
29
static
void
30
printUsage
(std::ostream& s)
31
{
32
s <<
"Usage: oks_report_bad_classes [--help] database-file [database-file(s)]\n"
33
"\n"
34
"Options:\n"
35
" -h | --help print this text\n"
36
"\n"
37
"Description:\n"
38
" Report classes, attributes and relationships without description.\n"
39
"\n"
;
40
}
41
42
static
void
43
report_class
(
const
OksClass
* c,
bool
no_description)
44
{
45
std::cout <<
" * class \""
<< c->get_name() <<
'\"'
;
46
47
if
(no_description)
48
std::cout <<
" has no description"
;
49
50
std::cout <<
" (from \""
<< c->get_file()->get_short_file_name() <<
"\")\n"
;
51
}
52
53
int
54
main
(
int
argc,
char
**argv)
55
{
56
OksKernel
kernel;
57
kernel.
set_silence_mode
(
true
);
58
59
try
60
{
61
for
(
int
i = 1; i < argc; i++)
62
{
63
const
char
*cp = argv[i];
64
65
if
(!strcmp(cp,
"-h"
) || !strcmp(cp,
"--help"
))
66
{
67
printUsage
(std::cout);
68
return
EXIT_SUCCESS;
69
}
70
else
71
{
72
if
(kernel.
load_file
(cp) == 0)
73
{
74
Oks::error_msg
(
"oks_dump"
) <<
"\tCan not load file \""
<< cp <<
"\", exiting...\n"
;
75
return
EXIT_FAILURE;
76
}
77
}
78
}
79
80
if
(kernel.
schema_files
().empty())
81
{
82
Oks::error_msg
(
"oks_dump"
) <<
"\tAt least one oks file have to be provided, exiting...\n"
;
83
return
EXIT_FAILURE;
84
}
85
}
86
catch
(
oks::exception
&ex)
87
{
88
std::cerr <<
"Caught oks exception:\n"
<< ex << std::endl;
89
return
EXIT_FAILURE;
90
}
91
catch
(std::exception &e)
92
{
93
std::cerr <<
"Caught standard C++ exception: "
<< e.what() << std::endl;
94
return
EXIT_FAILURE;
95
}
96
catch
(...)
97
{
98
std::cerr <<
"Caught unknown exception"
<< std::endl;
99
return
EXIT_FAILURE;
100
}
101
102
std::cout <<
"Processed schema files:\n"
;
103
for
(
const
auto
&i : kernel.
schema_files
())
104
std::cout << i.second->get_short_file_name() << std::endl;
105
106
for
(
const
auto
i : kernel.
classes
())
107
{
108
bool
printed(
false
);
109
110
if
(i.second->get_description().empty())
111
{
112
report_class
(i.second,
true
);
113
printed =
true
;
114
}
115
116
if
(
const
std::list<OksAttribute*> *attrs = i.second->direct_attributes())
117
for
(
const
auto
&j : *attrs)
118
119
if
(j->get_description().empty())
120
{
121
if
(!printed)
122
{
123
report_class
(i.second,
false
);
124
printed =
true
;
125
}
126
std::cout <<
" - attribute \""
<< j->get_name() <<
"\" has no description\n"
;
127
}
128
129
if
(
const
std::list<OksRelationship*> *rels = i.second->direct_relationships())
130
for
(
const
auto
&j : *rels)
131
if
(j->get_description().empty())
132
{
133
if
(!printed)
134
{
135
report_class
(i.second,
false
);
136
printed =
true
;
137
}
138
std::cout <<
" - relationship \""
<< j->get_name() <<
"\" has no description\n"
;
139
}
140
}
141
142
return
EXIT_SUCCESS;
143
}
attribute.hpp
class.hpp
dunedaq::oks::OksClass
The OKS class.
Definition
class.hpp:205
dunedaq::oks::OksKernel
Provides interface to the OKS kernel.
Definition
kernel.hpp:582
dunedaq::oks::OksKernel::load_file
OksFile * load_file(const std::string &name, bool bind=true)
Load OKS database file.
Definition
kernel.cpp:1793
dunedaq::oks::OksKernel::classes
const OksClass::Map & classes() const
Get classes.
Definition
kernel.hpp:1772
dunedaq::oks::OksKernel::set_silence_mode
void set_silence_mode(const bool b)
Set status of silence mode. To switch 'On'/'Off' use the method's parameter:
Definition
kernel.hpp:703
dunedaq::oks::OksKernel::schema_files
const OksFile::Map & schema_files() const
Get all schema files.
Definition
kernel.hpp:1228
dunedaq::oks::Oks::error_msg
static std::ostream & error_msg(const char *)
Definition
kernel.cpp:561
dunedaq::oks::exception
Definition
exceptions.hpp:18
file.hpp
exceptions.hpp
kernel.hpp
dunedaq::oks
Definition
OksConfiguration.hpp:24
dunedaq
Including Qt Headers.
Definition
module.cpp:16
main
int main(int argc, char **argv)
Definition
oks_report_no_descriptions.cxx:54
report_class
static void report_class(const OksClass *c, bool no_description)
Definition
oks_report_no_descriptions.cxx:43
printUsage
static void printUsage(std::ostream &s)
Definition
oks_report_no_descriptions.cxx:30
relationship.hpp
Generated on
for DUNE-DAQ by
1.17.0