OpenASIP  2.0
ExternalPort.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2014 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 ExternalPort.cc
26  *
27  * Implementation of ExternalPort class.
28  *
29  * @author Henry Linjamäki 2014 (henry.linjamaki-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include "ExternalPort.hh"
34 #include "ContainerTools.hh"
35 
36 namespace HDB {
37 
38 /**
39  * The constructor.
40  *
41  * Registers the port automatically to the given FUImplementation instance.
42  *
43  * @param name Name of the port.
44  * @param direction Direction of the port.
45  * @param widthFormula The formula for the width of the port.
46  * @param description Description of the port.
47  * @param parent The parent FUImplementation instance.
48  */
50  const std::string& name,
51  Direction direction,
52  const std::string& widthFormula,
53  const std::string& description) :
54  name_(name), direction_(direction), widthFormula_(widthFormula),
55  description_(description) {
56 
57 }
58 
59 
60 /**
61  * The destructor.
62  */
64 }
65 
66 
67 /**
68  * Sets the name of the port.
69  *
70  * @param name Name of the port.
71  */
72 void
73 ExternalPort::setName(const std::string& name) {
74  name_ = name;
75 }
76 
77 
78 /**
79  * Returns the name of the port.
80  *
81  * @return The name of the port.
82  */
83 std::string
85  return name_;
86 }
87 
88 
89 /**
90  * Sets the direction of the port.
91  *
92  * @param direction The new direction.
93  */
94 void
97 }
98 
99 
100 /**
101  * Returns the direction of the port.
102  *
103  * @return The direction of the port.
104  */
105 Direction
107  return direction_;
108 }
109 
110 
111 /**
112  * Sets the width formula of the port.
113  *
114  * @param widthFormula The new width formula.
115  */
116 void
117 ExternalPort::setWidthFormula(const std::string& widthFormula) {
119 }
120 
121 
122 /**
123  * Returns the formula for the width of the port.
124  *
125  * @return The formula.
126  */
127 std::string
129  return widthFormula_;
130 }
131 
132 
133 /**
134  * Sets description of the port.
135  *
136  * @param description The new description.
137  */
138 void
139 ExternalPort::setDescription(const std::string& description) {
141 }
142 
143 
144 /**
145  * Returns the description of the port.
146  *
147  * @return The description.
148  */
149 std::string
151  return description_;
152 }
153 
154 
155 /**
156  * Sets a parameter dependency for the port.
157  *
158  * @param parameter Name of the parameter the port is dependent on.
159  * @return True if parameter dependency was added, false if already existed.
160  */
161 bool
162 ExternalPort::setParameterDependency(const std::string& parameter) {
164  parameterDeps_.push_back(parameter);
165  return true;
166  }
167  return false;
168 }
169 
170 
171 /**
172  * Unsets the dependency of the given parameter.
173  *
174  * @param parameter The parameter.
175  * @return True if parameter dependency was removed, false if it didn't exist.
176  */
177 bool
178 ExternalPort::unsetParameterDependency(const std::string& parameter) {
180 }
181 
182 
183 /**
184  * Returns the number of parameters the port is dependent on.
185  *
186  * @return The number of parameters.
187  */
188 int
190  return parameterDeps_.size();
191 }
192 
193 
194 /**
195  * Returns name of a parameter the port is dependent on.
196  *
197  * @param index Determines which parameter is returned.
198  * @return The name of the parameter.
199  * @exception OutOfRange If the index is negative or not smaller than the
200  * number of parameters the port is dependent on.
201  */
202 std::string
204  if (index < 0 || index >= parameterDependencyCount()) {
205  throw OutOfRange(__FILE__, __LINE__, __func__);
206  }
207  return parameterDeps_[index];
208 }
209 }
210 
211 
212 
HDB::ExternalPort::parameterDeps_
ParameterTable parameterDeps_
Definition: ExternalPort.hh:83
HDB::ExternalPort::setDescription
void setDescription(const std::string &description)
Definition: ExternalPort.cc:139
HDB
Definition: CostDatabase.hh:49
HDB::ExternalPort::widthFormula_
std::string widthFormula_
The formula for the width of the port.
Definition: ExternalPort.hh:80
ExternalPort.hh
OutOfRange
Definition: Exception.hh:320
HDB::ExternalPort::setParameterDependency
bool setParameterDependency(const std::string &parameter)
Definition: ExternalPort.cc:162
HDB::ExternalPort::direction_
Direction direction_
Direction of the port.
Definition: ExternalPort.hh:78
HDB::ExternalPort::unsetParameterDependency
bool unsetParameterDependency(const std::string &parameter)
Definition: ExternalPort.cc:178
HDB::ExternalPort::~ExternalPort
virtual ~ExternalPort()
Definition: ExternalPort.cc:63
HDB::ExternalPort::ExternalPort
ExternalPort(const std::string &name, Direction direction, const std::string &widthFormula, const std::string &description)
Definition: ExternalPort.cc:49
HDB::ExternalPort::setName
void setName(const std::string &name)
Definition: ExternalPort.cc:73
ContainerTools::removeValueIfExists
static bool removeValueIfExists(ContainerType &aContainer, const ElementType &aKey)
HDB::ExternalPort::parameterDependency
std::string parameterDependency(int index) const
Definition: ExternalPort.cc:203
HDB::Direction
Direction
Direction of port.
Definition: HDBTypes.hh:40
__func__
#define __func__
Definition: Application.hh:67
HDB::ExternalPort::setWidthFormula
void setWidthFormula(const std::string &widthFormula)
Definition: ExternalPort.cc:117
HDB::ExternalPort::name_
std::string name_
Name of the port.
Definition: ExternalPort.hh:76
HDB::ExternalPort::description_
std::string description_
Description of the port.
Definition: ExternalPort.hh:82
HDB::ExternalPort::setDirection
void setDirection(Direction direction)
Definition: ExternalPort.cc:95
ContainerTools::containsValue
static bool containsValue(const ContainerType &aContainer, const ElementType &aKey)
HDB::ExternalPort::description
std::string description() const
Definition: ExternalPort.cc:150
HDB::ExternalPort::name
std::string name() const
Definition: ExternalPort.cc:84
HDB::ExternalPort::direction
Direction direction() const
Definition: ExternalPort.cc:106
HDB::ExternalPort::widthFormula
std::string widthFormula() const
Definition: ExternalPort.cc:128
HDB::ExternalPort::parameterDependencyCount
int parameterDependencyCount() const
Definition: ExternalPort.cc:189
ContainerTools.hh