PandA-2024.02
typed_node_info.hpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
44 #ifndef TYPED_NODE_INFO_HPP
45 #define TYPED_NODE_INFO_HPP
46 
48 #include "node_info.hpp"
49 
51 #include "graph.hpp"
52 
54 #include <ostream>
55 
57 #include "refcount.hpp"
58 
63 #define ENTRY "ENTRY"
64 
69 #define EXIT "EXIT"
70 
74 #define TYPE_ENTRY 2
75 
79 #define TYPE_EXIT 4
80 
84 #define TYPE_GENERIC 8
85 
91 
98 template <class Graph>
99 bool is_entry_node(const Graph* g, typename boost::graph_traits<Graph>::vertex_descriptor node)
100 {
101  return (GET_TYPE(g, node) == TYPE_ENTRY && boost::in_degree(node, *g) == 0);
102 }
103 
110 template <class Graph>
111 bool is_exit_node(const Graph* g, typename boost::graph_traits<Graph>::vertex_descriptor node)
112 {
113  return (GET_TYPE(g, node) == TYPE_EXIT && boost::out_degree(node, *g) == 0);
114 }
115 
116 struct TypedNodeInfo : public NodeInfo
117 {
122  std::string node_operation;
123 
127  std::string vertex_name;
128 
134  unsigned int node_type;
135 
139  TypedNodeInfo();
140 
144  ~TypedNodeInfo() override;
145 
150  void print(std::ostream&, int detail_level = 0) const override;
151 
157  friend std::ostream& operator<<(std::ostream& os, const TypedNodeInfo& s)
158  {
159  s.print(os);
160  return os;
161  }
162 };
163 
170 #define GET_OPERATION(data, vertex_index) Cget_node_info<TypedNodeInfo>(vertex_index, *(data))->node_operation
171 
178 #define GET_NAME(data, vertex_index) Cget_node_info<TypedNodeInfo>(vertex_index, *(data))->vertex_name
179 
186 #define GET_TYPE(data, vertex_index) Cget_node_info<TypedNodeInfo>(vertex_index, *(data))->node_type
187 #endif
std::string vertex_name
Definition of the node name property.
TypedNodeInfo()
Constructor.
#define GET_TYPE(data, vertex_index)
Helper macro returning the type associated with a node.
void print(std::ostream &, int detail_level=0) const override
Print the information associated with the node of the graph.
Class specification of the graph structures.
std::string node_operation
Custom vertex property: node_operation.
#define TYPE_EXIT
constant identifying the node type of an exit node.
Base class description of data information associated with each node of a graph.
bool is_exit_node(const Graph *g, typename boost::graph_traits< Graph >::vertex_descriptor node)
Helper function checking if a node is an exit node.
~TypedNodeInfo() override
Destructor.
unsigned int node_type
Custom vertex property: node_type.
bool is_entry_node(const Graph *g, typename boost::graph_traits< Graph >::vertex_descriptor node)
Base class storing user data information.
Template definition of refcount.
#define TYPE_ENTRY
constant identifying the node type of an entry node.
friend std::ostream & operator<<(std::ostream &os, const TypedNodeInfo &s)
Friend definition of the << operator.

Generated on Mon Feb 12 2024 13:02:53 for PandA-2024.02 by doxygen 1.8.13