blob: dfb8c7f22e8b0142d2b7f1a961d54dc05bebde36 [file] [log] [blame]
surmeh01bceff2f2018-03-29 16:29:27 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
surmeh01bceff2f2018-03-29 16:29:27 +01004//
5
6#pragma once
7
8#include <ostream>
9#include <vector>
10#include <memory>
11
12namespace armnn
13{
14
15class DotBase
16{
17public:
18 explicit DotBase(std::ostream& stream)
19 : m_Stream(stream) {}
20
21 std::ostream& GetStream() { return m_Stream; }
22
23private:
24 std::ostream& m_Stream;
25};
26
27class HtmlSection : public DotBase
28{
29public:
30 explicit HtmlSection(std::ostream& stream)
31 : DotBase(stream) { GetStream() << "<";}
32 ~HtmlSection() { GetStream() << ">"; }
33};
34
35class HtmlSimpleTag : public DotBase
36{
37public:
38 explicit HtmlSimpleTag(std::ostream& stream, const char* name)
39 : DotBase(stream)
40 , m_Name(name){ GetStream() << "<" << m_Name << ">"; }
41 ~HtmlSimpleTag() { GetStream() << "</" << m_Name << ">"; }
42
43private:
44 const char* m_Name;
45};
46
47class HtmlBold : public HtmlSimpleTag
48{
49public:
50 explicit HtmlBold(std::ostream &stream)
51 : HtmlSimpleTag(stream, "B") {}
52};
53
54class HtmlFont : public DotBase
55{
56public:
57 explicit HtmlFont(std::ostream& stream, int fontSize, const char* color, const char* face);
58 explicit HtmlFont(std::ostream& stream);
59 ~HtmlFont();
60};
61
62class DotAttributeSet : public DotBase
63{
64public:
65 explicit DotAttributeSet(std::ostream& stream);
66 ~DotAttributeSet();
67
68 DotAttributeSet & AddAttribute(const std::string& name, const std::stringstream& value);
69 DotAttributeSet & AddAttribute(const std::string& name, int value);
70 DotAttributeSet & AddAttribute(const std::string& name, const std::string& value);
71private:
72 std::vector<std::string> m_Attributes;
73};
74
75class DotEdge : public DotBase
76{
77public:
78 explicit DotEdge(std::ostream& stream, unsigned int fromNodeId, unsigned int toNodeId);
79 ~DotEdge();
80
81 DotAttributeSet& GetAttributeSet() { return *m_Attributes.get(); }
82private:
83 std::unique_ptr<DotAttributeSet> m_Attributes;
84};
85
86class NodeContent : public DotBase
87{
88public:
89 explicit NodeContent(std::ostream& stream);
90 NodeContent & SetName(const std::string & name);
91 NodeContent & AddContent(const std::string & content);
92
93 ~NodeContent();
94private:
95 std::string m_Name;
96 std::vector<std::string> m_Contents;
97};
98
99class DotNode : public DotBase
100{
101public:
102 explicit DotNode(std::ostream& stream, unsigned int nodeId, const char* label);
103 ~DotNode();
104
105 NodeContent& GetContents() { return *m_Contents.get(); }
106 DotAttributeSet& GetAttributeSet() { return *m_Attributes.get(); }
107private:
108 std::unique_ptr<NodeContent> m_Contents;
109 std::unique_ptr<DotAttributeSet> m_Attributes;
110};
111
112class DotDefaults : public DotBase
113{
114public:
115 explicit DotDefaults(std::ostream& stream, const char* type);
116 ~DotDefaults();
117
118 DotAttributeSet& GetAttributeSet() { return *m_Attributes.get(); }
119private:
120 std::unique_ptr<DotAttributeSet> m_Attributes;
121};
122
123class DotGraph : public DotBase
124{
125public:
126 explicit DotGraph(std::ostream& stream, const char* name);
127 ~DotGraph();
128private:
129};
130
131} //namespace armnn