OpenASIP 2.2
Loading...
Searching...
No Matches
GuardEncoding.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 GuardEncoding.cc
26 *
27 * Implementation of GuardEncoding class.
28 *
29 * @author Lasse Laasonen 2005 (lasse.laasonen-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#include <cstddef>
34#include <string>
35
36#include "GuardEncoding.hh"
37#include "ObjectState.hh"
38
39using std::string;
40
41const std::string GuardEncoding::OSNAME_GUARD_ENCODING = "guard_encoding";
42const std::string GuardEncoding::OSKEY_INVERTED = "inverted";
43const std::string GuardEncoding::OSKEY_ENCODING = "encoding";
44
45/**
46 * The constructor.
47 *
48 * @param inverted The "invert" flag.
49 * @param encoding The control code.
50 */
51GuardEncoding::GuardEncoding(bool inverted, unsigned int encoding) :
52 inverted_(inverted), encoding_(encoding), parent_(NULL) {
53}
54
55
56/**
57 * The constructor.
58 *
59 * Loads the state of the object from the given ObjectState instance.
60 *
61 * @param state The ObjectState instance.
62 * @exception ObjectStateLoadingException If an error occurs while loading the
63 * state.
64 */
66 : inverted_(false), encoding_(0), parent_(NULL) {
67 try {
70 } catch (const Exception& exception) {
71 const string procName = "GuardEncoding::GuardEncoding";
73 __FILE__, __LINE__, procName, exception.errorMessage());
74 }
75}
76
77/**
78 * The destructor
79 */
82
83
84/**
85 * Returns the parent guard field.
86 *
87 * @return The parent guard field.
88 */
91 return parent_;
92}
93
94
95/**
96 * Tells whether the guard expression is inverted.
97 *
98 * @return True if the guard expression is inverted, otherwise false.
99 */
100bool
102 return inverted_;
103}
104
105
106/**
107 * Returns the control code of the guard expression.
108 *
109 * @return The control code.
110 */
111unsigned int
113 return encoding_;
114}
115
116
117/**
118 * Saves the state of the object to an ObjectState instance.
119 *
120 * @return The newly created ObjectState instance.
121 */
129
130
131/**
132 * Sets the parent pointer.
133 *
134 * @param parent The parent.
135 */
136void
find Finds info of the inner loops in the false
std::string errorMessage() const
Definition Exception.cc:123
GuardField * parent_
The parent guard field.
GuardField * parent() const
GuardEncoding(bool inverted, unsigned int encoding)
virtual ObjectState * saveState() const
unsigned int encoding() const
virtual ~GuardEncoding()
unsigned int encoding_
The encoding.
static const std::string OSNAME_GUARD_ENCODING
ObjectState name for guard encoding.
static const std::string OSKEY_INVERTED
ObjectState attribute key for invert flag.
static const std::string OSKEY_ENCODING
ObjectState attribute key for encoding.
void setParent(GuardField *parent)
bool inverted_
The "invert" flag.
bool isGuardInverted() const
void setAttribute(const std::string &name, const std::string &value)
bool boolAttribute(const std::string &name) const
int intAttribute(const std::string &name) const