PandA-2024.02
cg_node.cpp
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  */
45 #include "cg_node.hpp"
46 #include "exceptions.hpp" // for THROW_ERROR
47 #include "structural_objects.hpp" // for structural_object, structural_obje...
48 
49 void cg_edge_info::print(std::ostream& os) const
50 {
52  {
53  os << GetPointer<constant_o>(from_port)->get_value();
54  }
55  else if(from_port->get_owner()->get_kind() == port_vector_o_K)
56  {
57  os << from_port->get_owner()->get_id() << "[" << from_port->get_id() << "]";
58  }
59  else
60  {
61  os << from_port->get_id();
62  }
63  os << "-";
64  if(to_port->get_owner()->get_kind() == port_vector_o_K)
65  {
66  os << to_port->get_owner()->get_id() << "[" << to_port->get_id() << "]";
67  }
68  else
69  {
70  os << to_port->get_id();
71  }
72 }
73 
75 {
76 }
77 
78 void cg_edge_writer::operator()(std::ostream& out, const EdgeDescriptor& e) const
79 {
80  const auto* edge_info = Cget_edge_info<cg_edge_info>(e, *g);
81  bool is_critical = false;
82  if(edge_info)
83  {
84  is_critical = edge_info->is_critical;
85  }
86  if(is_critical)
87  {
88  out << "[color=red, ";
89  }
90  else if(DATA_SELECTOR & g->GetSelector(e))
91  {
92  out << "[color=blue, ";
93  }
94  else if(CLOCK_SELECTOR & g->GetSelector(e))
95  {
96  out << "[color=yellow, ";
97  }
98  else if(CHANNEL_SELECTOR & g->GetSelector(e))
99  {
100  out << "[color=green, ";
101  }
102  else
103  {
104  THROW_ERROR(std::string("InconsistentDataStructure"));
105  }
106  if(edge_info)
107  {
108  out << "label=\"";
109  edge_info->print(out);
110  out << "\"";
111  }
112  out << "]";
113 }
114 
116 {
117 }
118 
119 void cg_label_writer::operator()(std::ostream& out, const vertex& v) const
120 {
121  bool is_critical = GET_CRITICAL(g, v);
122  if(GET_TYPE(g, v) == TYPE_ENTRY || GET_TYPE(g, v) == TYPE_EXIT)
123  {
124  out << "[color=" << (is_critical ? "red" : "blue") << ",shape=Msquare";
125  }
126  else
127  {
128  out << "[shape=box";
129  if(is_critical)
130  {
131  out << ",color=red";
132  }
133  }
134  out << ", label=\"" << GET_NAME(g, v) << " \\n" << GET_OPERATION(g, v) << "\"]";
135 }
int GetSelector() const
Return the selector of this graph.
Definition: graph.hpp:922
#define GET_TYPE(data, vertex_index)
Helper macro returning the type associated with a node.
#define GET_OPERATION(data, vertex_index)
Helper macro returning the operation associated with a node.
const graph * g
Definition: cg_node.hpp:235
const std::string & get_id() const
Return the identifier associated with the structural_object.
#define GET_NAME(data, vertex_index)
Helper macro returning the name associated with a node.
Node, edge and graph description of the graph associated with a structural description.
structural_objectRef to_port
destination port/channel to the edge is attached
Definition: cg_node.hpp:112
exceptions managed by PandA
#define CHANNEL_SELECTOR
Channel line selector.
Definition: cg_node.hpp:67
#define TYPE_EXIT
constant identifying the node type of an exit node.
void operator()(std::ostream &out, const EdgeDescriptor &e) const
Definition: cg_node.cpp:78
cg_edge_writer(const graph *_g)
Definition: cg_node.cpp:74
#define DATA_SELECTOR
Data line selector.
Definition: cg_node.hpp:63
boost::graph_traits< graph >::vertex_descriptor vertex
vertex definition.
Definition: graph.hpp:1303
General class used to describe a graph in PandA.
Definition: graph.hpp:771
virtual enum so_kind get_kind() const =0
Virtual function used to find the real type of a structural_object instance.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Definition: exceptions.hpp:263
const graph * g
Definition: cg_node.hpp:224
void print(std::ostream &os) const
Print the information associated with the current node of the graph.
Definition: cg_node.cpp:49
This class describes all classes used to represent a structural object.
const structural_objectRef get_owner() const
Return the owner.
void operator()(std::ostream &out, const vertex &v) const
Definition: cg_node.cpp:119
#define GET_CRITICAL(data, node_index)
Definition: cg_node.hpp:102
#define TYPE_ENTRY
constant identifying the node type of an entry node.
structural_objectRef from_port
port from which the edge is generated
Definition: cg_node.hpp:110
cg_label_writer(const graph *_g)
Definition: cg_node.cpp:115
#define CLOCK_SELECTOR
Clock line selector.
Definition: cg_node.hpp:65
boost::graph_traits< graph >::edge_descriptor EdgeDescriptor
edge definition.
Definition: graph.hpp:1316

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