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