ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Node.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
24#ifndef __ONERT_DUMPER_DOT_NODE_H__
25#define __ONERT_DUMPER_DOT_NODE_H__
26
27#include <string>
28#include <memory>
29#include <vector>
30#include <unordered_map>
31
32namespace onert::dumper::dot
33{
34
46
51class Node
52{
53public:
54 const static inline std::string DEFAULT_FILLCOLOR = "x11";
55 const static inline std::string DEFAULT_COLORSCHEME = "white";
56 // RED, BLUE, GREEN, PURPLE, ORANGE, YELLOW, BROWN, PINK
57 const static inline std::string BG_COLORS[8] = {"1", "2", "3", "4", "5", "6", "7", "8"};
58
59public:
64 virtual ~Node() = default;
65
71 Node(const std::string &id);
72
78 std::string id() const { return _id; }
79
85 const std::unordered_map<std::string, std::string> &attributes() const { return _attributes; }
92 void setAttribute(const std::string &key, const std::string &val);
99 std::string getAttribute(const std::string &key);
100
106 void addOutEdge(Node *dotinfo) { _out_edges.emplace_back(dotinfo); }
112 const std::vector<Node *> &out_edges() const { return _out_edges; }
113
114private:
115 std::string _id;
116 // TODO: Apply Heterogeneous lookup for unordered containers (transparent hashing) since C++20
117 // to use `std::string_view` with lookup functions in unordered containers
118 std::unordered_map<std::string, std::string> _attributes;
119 std::vector<Node *> _out_edges;
120};
121
122} // namespace onert::dumper::dot
123
124#endif // __ONERT_DUMPER_DOT_NODE_H__
Class that represents a Node in "dot" format.
Definition Node.h:52
const std::vector< Node * > & out_edges() const
Return list of out edges.
Definition Node.h:112
void addOutEdge(Node *dotinfo)
Add an edge in the graph, which is an outgoing edge.
Definition Node.h:106
static const std::string DEFAULT_COLORSCHEME
Definition Node.h:55
void setAttribute(const std::string &key, const std::string &val)
Store an attribute with key-value pair.
Definition Node.cc:30
std::string id() const
return id
Definition Node.h:78
std::string getAttribute(const std::string &key)
Get the attributte value that is associated with key.
Definition Node.cc:32
const std::unordered_map< std::string, std::string > & attributes() const
return attributes
Definition Node.h:85
static const std::string DEFAULT_FILLCOLOR
Definition Node.h:54
virtual ~Node()=default
Destroy the Node object.
static const std::string BG_COLORS[8]
Definition Node.h:57