14 #include "xdotwriter.h"
16 #include "xitemnode.h"
17 #include "xlistnode.h"
19 XDotWriter::XDotWriter(
const shared_ptr<XNode> &root, std::ofstream &ofs)
20 : m_root(root), m_ofs(ofs), m_unnamedcnt(0) {
22 ofs <<
"/* KAME2 measurement configuration file" << std::endl
23 <<
"* Automatically created. KAME version. " << VERSION << std::endl
24 <<
"* date: " << XTime::now().getTimeStr() << std::endl
27 XDotWriter::~XDotWriter() {
36 m_ofs <<
"node [shape=box,style=filled,color=green];" << std::endl;
44 XDotWriter::write(
const shared_ptr<XNode> &node,
const Snapshot &shot) {
45 if(std::find(m_nodes.begin(), m_nodes.end(), node) == m_nodes.end()) {
46 m_ofs <<
"obj_" << (uintptr_t)node.get()
47 <<
" [label=\"" << node->getName()
48 <<
"\"]" << std::endl;
49 m_nodes.push_back(node);
56 for(
auto it = shot.list(node)->begin(); it != shot.list(node)->end(); it++) {
57 shared_ptr<XNode> child = *it;
59 if(child->getName().empty()) {
63 m_ofs <<
"obj_" << (uintptr_t)child.get()
65 <<
"obj_" << (uintptr_t)node.get()
73 m_ofs <<
"unnamedobj_" << (int)m_unnamedcnt
74 <<
" [label=\"" << (
const char*)QString("%1 obj.").arg(unnamed).toUtf8().data()
75 << "\"]" << std::endl;
76 m_ofs << "unnamedobj_" << (
int)m_unnamedcnt
78 << "obj_" << (uintptr_t)node.get()