DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
dbe::tool::graph Namespace Reference

Classes

class  gtool
class  segregated_graph_write
class  stats
class  writegraph

Functions

void write (gtool::t_graph const &, std::string const &)
void write_to_cout (gtool::t_graph const &)
void write_to_file (gtool::t_graph const &, std::string const &)

Function Documentation

◆ write()

void dbe::tool::graph::write ( gtool::t_graph const & g,
std::string const & ofn )

Send a graph to output or a file. The file is used if the second parameter is not an empty string.

Parameters
Thegraph to send to file
Thefile name to write to

Definition at line 202 of file gtool.cpp.

203{
204 if (ofn.empty()) {
205 write_to_cout(g);
206 } else {
207 write_to_file(g, ofn);
208 }
209}
void write_to_cout(gtool::t_graph const &)
Definition gtool.cpp:212
void write_to_file(gtool::t_graph const &, std::string const &)
Definition gtool.cpp:219

◆ write_to_cout()

void dbe::tool::graph::write_to_cout ( gtool::t_graph const & g)

Send a graph to standard output

Parameters
thegraph to write

Definition at line 212 of file gtool.cpp.

213{
214 INFO("Sending output to stdout", "Program execution control")
215 boost::write_graphviz(std::cout, g, boost::make_label_writer(boost::get(&gtool::vertex_label::label, g)));
216}
#define INFO(...)
Definition messenger.hpp:98

◆ write_to_file()

void dbe::tool::graph::write_to_file ( gtool::t_graph const & g,
std::string const & ofn )

Send a graph to file. If the operation could not be completed EXIT_FAIL is returned

Parameters
Thegraph to write
Thefilename to write to
Returns
EXIT_SUCCESS in case of success

Definition at line 219 of file gtool.cpp.

220{
221 std::ofstream of;
222 of.open(ofn);
223
224 if (of.is_open()) {
225 INFO("Sending output to file", "Program execution control", "File name:", ofn);
226 boost::write_graphviz(of, g, boost::make_label_writer(boost::get(&gtool::vertex_label::label, g)));
227
228 of.close();
229
230 if (of.fail()) {
231 ERROR("Could not close file", "Program execution control", "File name:", ofn);
232 } else {
233 NOTE("Output written to file", "Program execution control success", "File name:", ofn);
234 }
235 } else {
236 ERROR("Output could not be written file", "Stream could not be opened", "File name:", ofn);
237 write_to_cout(g);
238 }
239}
#define ERROR(...)
Definition messenger.hpp:90
#define NOTE(...)