#ifndef EMPATHY_UTIL_GRAPHVIZ_H
#define EMPATHY_UTIL_GRAPHVIZ_H
namespace empathy::util
{
namespace colors
{
// Base16 default color palette.
extern const char* base00;
extern const char* base01;
extern const char* base02;
extern const char* base03;
extern const char* base04;
extern const char* base05;
extern const char* base06;
extern const char* base07;
extern const char* base08;
extern const char* base09;
extern const char* base0A;
extern const char* base0B;
extern const char* base0C;
extern const char* base0D;
extern const char* base0E;
extern const char* base0F;
}
// Helper class to dump data structures into a graphiz dot file.
class GraphVizBuilder
{
public:
GraphVizBuilder( ostream& output );
~GraphVizBuilder();
ostream& indent() const;
ostream& newLine() const;
static const char* BGColor;
static const char* TextColor;
static const char* GetNodeColor( uint32_t id );
uint32_t getNodeId( const void* pNodeAddress );
void addEdge( const void* pFrom, const void* pTo );
class Indention
{
public:
Indention( GraphVizBuilder& builder );
~Indention();
private:
GraphVizBuilder& m_builder;
};
class Table
{
public:
Table( GraphVizBuilder& builder, const char* pColor = TextColor );
~Table();
private:
GraphVizBuilder& m_builder;
};
class Row
{
public:
Row( GraphVizBuilder& builder );
~Row();
private:
GraphVizBuilder& m_builder;
};
class Cell
{
public:
Cell( GraphVizBuilder& builder );
~Cell();
private:
GraphVizBuilder& m_builder;
};
class Color
{
public:
Color( GraphVizBuilder& builder, const char* pColor );
~Color();
private:
GraphVizBuilder& m_builder;
};
class Node
{
public:
Node( GraphVizBuilder& builder, const void* pAddress, const char* pTitle = nullptr );
~Node();
private:
GraphVizBuilder& m_builder;
};
private:
ostream& m_output;
unordered_map< const void*, uint32_t > m_nodesDict;
queue< function< void() > > m_workQueue;
uint32_t m_indention = 1;
uint32_t m_nodeCount = 0;
uint32_t m_currentNode = 0;
uint32_t m_portCount = 0;
};
}
#endif