OpenASIP  2.0
GraphEdge.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file GraphEdge.cc
26  *
27  * Prototype of graph-based program representation: implementation of graph
28  * edge.
29  *
30  * @author Andrea Cilio 2005 (cilio-no.spam-cs.tut.fi)
31  * @author Vladimir Guzma 2006 (vladimir.guzma-no.spam-tut.fi)
32  * @note rating: red
33  */
34 
35 #include "GraphEdge.hh"
36 #include "Conversion.hh"
37 
39 
40 GraphEdge::GraphEdge() : edgeID_(edgeCounter_++), weight_(-1) {}
41 
42 GraphEdge::GraphEdge(const GraphEdge& e) : edgeID_(edgeCounter_++), weight_(e.weight()) {}
43 
44 /**
45  * Clones edge. Needed for dynamic binding, when copying
46  * instances through the base class.
47  *
48  * @return Dynamically allocated copy of the edge.
49  */
50 GraphEdge*
52  throw WrongSubclass(
53  __FILE__, __LINE__, __func__,
54  "Cloning must be done in subclass or use copy constructor.");
55  return NULL;
56 }
57 
58 /**
59  * Return the label of the edge as a string.
60  *
61  * Used for printing graph in GraphViz .dot file.
62  *
63  * @return The edge ID as a string
64  */
67  return Conversion::toString(edgeID());
68 }
69 
70 /**
71  * Returns the string that should be placed in the edge's properties section in
72  * the GraphViz Dot string.
73  *
74  * This can be overridden in the derived class to add different properties (e.g.,
75  * colors, etc.) to different type of edges. The default implementation only
76  * sets the label property.
77  *
78  * @return String describing the Dot properties of the edge.
79  */
82  return TCEString("label=\"") + toString() + "\"";
83 }
84 
85 
86 /**
87  * Return edge ID as integer.
88  *
89  * @return The edge ID as integer
90  */
91 int
93  return edgeID_;
94 }
95 
96 
GraphEdge::~GraphEdge
virtual ~GraphEdge()
Definition: GraphEdge.cc:38
GraphEdge.hh
Conversion::toString
static std::string toString(const T &source)
GraphEdge::edgeCounter_
static int edgeCounter_
Definition: GraphEdge.hh:78
WrongSubclass
Definition: Exception.hh:336
Conversion.hh
GraphEdge::toString
virtual TCEString toString() const
Definition: GraphEdge.cc:66
__func__
#define __func__
Definition: Application.hh:67
GraphEdge::edgeID
virtual int edgeID() const
Definition: GraphEdge.cc:92
GraphEdge::edgeID_
int edgeID_
Definition: GraphEdge.hh:76
GraphEdge::dotString
virtual TCEString dotString() const
Definition: GraphEdge.cc:81
GraphEdge
Definition: GraphEdge.hh:52
TCEString
Definition: TCEString.hh:53
GraphEdge::GraphEdge
GraphEdge()
Definition: GraphEdge.cc:40
GraphEdge::clone
virtual GraphEdge * clone() const
Definition: GraphEdge.cc:51