OpenASIP 2.2
Loading...
Searching...
No Matches
FUGuardEncoding.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 FUGuardEncoding.cc
26 *
27 * Implementation of FUGuardEncoding class.
28 *
29 * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#include <string>
34
35#include "FUGuardEncoding.hh"
36#include "GuardField.hh"
37#include "ObjectState.hh"
38
39using std::string;
40
41const std::string FUGuardEncoding::OSNAME_FU_GUARD_ENCODING = "fu_guard_enc";
42const std::string FUGuardEncoding::OSKEY_FU_NAME = "fu_name";
43const std::string FUGuardEncoding::OSKEY_PORT_NAME = "port_name";
44
45/**
46 * The constructor.
47 *
48 * Creates a guard encoding and registers it into the given guard field. The
49 * guard expression is identified by the name of function unit and port, and
50 * the "invert" flag, all given as parameters.
51 *
52 * @param fu Name of the function unit.
53 * @param port Name of the port.
54 * @param inverted The "invert" flag.
55 * @param encoding The control code of the guard expression.
56 * @param parent The parent guard field.
57 * @exception ObjectAlreadyExists If the guard expression is already encoded
58 * in the parent field, or if the given control
59 * code is already assigned to another guard
60 * expression.
61 */
63 const std::string& fu, const std::string& port, bool inverted,
64 unsigned int encoding, GuardField& parent)
65 : GuardEncoding(inverted, encoding), functionUnit_(fu), port_(port) {
68}
69
70/**
71 * The constructor.
72 *
73 * Loads the state of the object from the given ObjectState instance.
74 *
75 * @param state The ObjectState instance.
76 * @param parent The parent guard field.
77 * @exception ObjectStateLoadingException If an error occurs while loading the
78 * state.
79 * @exception ObjectAlreadyExists If the guard expression if already encoded
80 * in the parent field, or if the given control
81 * code is already assigned to another guard
82 * expression.
83 */
85 : GuardEncoding(state), functionUnit_(""), port_("") {
86 const string procName = "FUGuardEncoding::FUGuardEncoding";
87
88 if (state->name() != OSNAME_FU_GUARD_ENCODING) {
89 throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
90 }
91
92 try {
95 } catch (const Exception& exception) {
97 __FILE__, __LINE__, procName, exception.errorMessage());
98 }
99
102}
103
104/**
105 * The destructor.
106 */
112
113
114/**
115 * Returns the name of the function unit that contains the port of this guard
116 * expression.
117 *
118 * @return The name of the function unit.
119 */
120std::string
124
125
126/**
127 * Returns the name of the FU port of this guard expression.
128 *
129 * @return The name of the FU port.
130 */
131std::string
133 return port_;
134}
135
136
137/**
138 * Saves the state of the object to an ObjectState instance.
139 *
140 * @return The newly created ObjectState instance.
141 */
std::string errorMessage() const
Definition Exception.cc:123
static const std::string OSKEY_PORT_NAME
ObjectState attribute key for the name of the port.
std::string functionUnit_
Name of the function unit.
static const std::string OSNAME_FU_GUARD_ENCODING
ObjectState name for FU guard encoding.
std::string port() const
virtual ObjectState * saveState() const
virtual ~FUGuardEncoding()
std::string port_
Name of the port.
FUGuardEncoding(const std::string &fu, const std::string &port, bool inverted, unsigned int encoding, GuardField &parent)
std::string functionUnit() const
static const std::string OSKEY_FU_NAME
ObjectState attribute key for the name of the function unit.
GuardField * parent() const
virtual ObjectState * saveState() const
void setParent(GuardField *parent)
void addGuardEncoding(GPRGuardEncoding &encoding)
void removeGuardEncoding(GPRGuardEncoding &encoding)
void setName(const std::string &name)
void setAttribute(const std::string &name, const std::string &value)
std::string stringAttribute(const std::string &name) const
std::string name() const