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