DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
oks_report_no_descriptions.cxx File Reference
#include <stdlib.h>
#include "oks/attribute.hpp"
#include "oks/class.hpp"
#include "oks/exceptions.hpp"
#include "oks/file.hpp"
#include "oks/kernel.hpp"
#include "oks/relationship.hpp"
Include dependency graph for oks_report_no_descriptions.cxx:

Go to the source code of this file.

Functions

static void printUsage (std::ostream &s)
static void report_class (const OksClass *c, bool no_description)
int main (int argc, char **argv)

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 54 of file oks_report_no_descriptions.cxx.

55{
56 OksKernel kernel;
57 kernel.set_silence_mode(true);
58
59 try {
60 for (int i = 1; i < argc; i++) {
61 const char* cp = argv[i];
62
63 if (!strcmp(cp, "-h") || !strcmp(cp, "--help")) {
64 printUsage(std::cout);
65 return EXIT_SUCCESS;
66 } else {
67 if (kernel.load_file(cp) == 0) {
68 Oks::error_msg("oks_dump") << "\tCan not load file \"" << cp << "\", exiting...\n";
69 return EXIT_FAILURE;
70 }
71 }
72 }
73
74 if (kernel.schema_files().empty()) {
75 Oks::error_msg("oks_dump") << "\tAt least one oks file have to be provided, exiting...\n";
76 return EXIT_FAILURE;
77 }
78 } catch (oks::exception& ex) {
79 std::cerr << "Caught oks exception:\n" << ex << std::endl;
80 return EXIT_FAILURE;
81 } catch (std::exception& e) {
82 std::cerr << "Caught standard C++ exception: " << e.what() << std::endl;
83 return EXIT_FAILURE;
84 } catch (...) {
85 std::cerr << "Caught unknown exception" << std::endl;
86 return EXIT_FAILURE;
87 }
88
89 std::cout << "Processed schema files:\n";
90 for (const auto& i : kernel.schema_files())
91 std::cout << i.second->get_short_file_name() << std::endl;
92
93 for (const auto i : kernel.classes()) {
94 bool printed(false);
95
96 if (i.second->get_description().empty()) {
97 report_class(i.second, true);
98 printed = true;
99 }
100
101 if (const std::list<OksAttribute*>* attrs = i.second->direct_attributes())
102 for (const auto& j : *attrs)
103
104 if (j->get_description().empty()) {
105 if (!printed) {
106 report_class(i.second, false);
107 printed = true;
108 }
109 std::cout << " - attribute \"" << j->get_name() << "\" has no description\n";
110 }
111
112 if (const std::list<OksRelationship*>* rels = i.second->direct_relationships())
113 for (const auto& j : *rels)
114 if (j->get_description().empty()) {
115 if (!printed) {
116 report_class(i.second, false);
117 printed = true;
118 }
119 std::cout << " - relationship \"" << j->get_name() << "\" has no description\n";
120 }
121 }
122
123 return EXIT_SUCCESS;
124}
Provides interface to the OKS kernel.
Definition kernel.hpp:615
OksFile * load_file(const std::string &name, bool bind=true)
Load OKS database file.
Definition kernel.cpp:1625
const OksClass::Map & classes() const
Get classes.
Definition kernel.hpp:1711
void set_silence_mode(const bool b)
Set status of silence mode. To switch 'On'/'Off' use the method's parameter:
Definition kernel.hpp:730
const OksFile::Map & schema_files() const
Get all schema files.
Definition kernel.hpp:1211
static std::ostream & error_msg(const char *)
Definition kernel.cpp:511
static void report_class(const OksClass *c, bool no_description)
static void printUsage(std::ostream &s)

◆ printUsage()

void printUsage ( std::ostream & s)
static

Definition at line 30 of file oks_report_no_descriptions.cxx.

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}

◆ report_class()

void report_class ( const OksClass * c,
bool no_description )
static

Definition at line 43 of file oks_report_no_descriptions.cxx.

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}