OpenASIP 2.2
Loading...
Searching...
No Matches
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
36namespace 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 */
65
66
67/**
68 * Sets the name of the port.
69 *
70 * @param name Name of the port.
71 */
72void
73ExternalPort::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 */
83std::string
85 return name_;
86}
87
88
89/**
90 * Sets the direction of the port.
91 *
92 * @param direction The new direction.
93 */
94void
98
99
100/**
101 * Returns the direction of the port.
102 *
103 * @return The direction of the port.
104 */
107 return direction_;
108}
109
110
111/**
112 * Sets the width formula of the port.
113 *
114 * @param widthFormula The new width formula.
115 */
116void
117ExternalPort::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 */
127std::string
129 return widthFormula_;
130}
131
132
133/**
134 * Sets description of the port.
135 *
136 * @param description The new description.
137 */
138void
139ExternalPort::setDescription(const std::string& description) {
141}
142
143
144/**
145 * Returns the description of the port.
146 *
147 * @return The description.
148 */
149std::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 */
161bool
162ExternalPort::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 */
177bool
178ExternalPort::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 */
188int
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 */
202std::string
204 if (index < 0 || index >= parameterDependencyCount()) {
205 throw OutOfRange(__FILE__, __LINE__, __func__);
206 }
207 return parameterDeps_[index];
208}
209}
210
211
212
#define __func__
static bool removeValueIfExists(ContainerType &aContainer, const ElementType &aKey)
static bool containsValue(const ContainerType &aContainer, const ElementType &aKey)
std::string widthFormula() const
void setWidthFormula(const std::string &widthFormula)
ExternalPort(const std::string &name, Direction direction, const std::string &widthFormula, const std::string &description)
virtual ~ExternalPort()
void setName(const std::string &name)
std::string name_
Name of the port.
std::string description_
Description of the port.
std::string parameterDependency(int index) const
std::string widthFormula_
The formula for the width of the port.
void setDirection(Direction direction)
void setDescription(const std::string &description)
bool setParameterDependency(const std::string &parameter)
int parameterDependencyCount() const
Direction direction_
Direction of the port.
std::string name() const
std::string description() const
ParameterTable parameterDeps_
bool unsetParameterDependency(const std::string &parameter)
Direction direction() const
Direction
Direction of port.
Definition HDBTypes.hh:40