OpenASIP  2.0
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 
39 using std::string;
40 
41 const std::string GuardEncoding::OSNAME_GUARD_ENCODING = "guard_encoding";
42 const std::string GuardEncoding::OSKEY_INVERTED = "inverted";
43 const 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  */
51 GuardEncoding::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  */
81 }
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  */
100 bool
102  return inverted_;
103 }
104 
105 
106 /**
107  * Returns the control code of the guard expression.
108  *
109  * @return The control code.
110  */
111 unsigned 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  */
127  return state;
128 }
129 
130 
131 /**
132  * Sets the parent pointer.
133  *
134  * @param parent The parent.
135  */
136 void
138  parent_ = parent;
139 }
ObjectStateLoadingException
Definition: Exception.hh:551
GuardEncoding::isGuardInverted
bool isGuardInverted() const
Definition: GuardEncoding.cc:101
ObjectState
Definition: ObjectState.hh:59
GuardField
Definition: GuardField.hh:55
GuardEncoding::OSKEY_INVERTED
static const std::string OSKEY_INVERTED
ObjectState attribute key for invert flag.
Definition: GuardEncoding.hh:58
GuardEncoding.hh
GuardEncoding::setParent
void setParent(GuardField *parent)
Definition: GuardEncoding.cc:137
GuardEncoding::encoding_
unsigned int encoding_
The encoding.
Definition: GuardEncoding.hh:71
GuardEncoding::parent_
GuardField * parent_
The parent guard field.
Definition: GuardEncoding.hh:73
ObjectState.hh
Exception
Definition: Exception.hh:54
GuardEncoding::encoding
unsigned int encoding() const
Definition: GuardEncoding.cc:112
GuardEncoding::GuardEncoding
GuardEncoding(bool inverted, unsigned int encoding)
Definition: GuardEncoding.cc:51
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
GuardEncoding::OSNAME_GUARD_ENCODING
static const std::string OSNAME_GUARD_ENCODING
ObjectState name for guard encoding.
Definition: GuardEncoding.hh:56
GuardEncoding::~GuardEncoding
virtual ~GuardEncoding()
Definition: GuardEncoding.cc:80
false
find Finds info of the inner loops in the false
Definition: InnerLoopFinder.cc:81
GuardEncoding::inverted_
bool inverted_
The "invert" flag.
Definition: GuardEncoding.hh:69
ObjectState::boolAttribute
bool boolAttribute(const std::string &name) const
Definition: ObjectState.cc:338
ObjectState::intAttribute
int intAttribute(const std::string &name) const
Definition: ObjectState.cc:276
GuardEncoding::OSKEY_ENCODING
static const std::string OSKEY_ENCODING
ObjectState attribute key for encoding.
Definition: GuardEncoding.hh:60
GuardEncoding::saveState
virtual ObjectState * saveState() const
Definition: GuardEncoding.cc:123
ObjectState::setAttribute
void setAttribute(const std::string &name, const std::string &value)
Definition: ObjectState.cc:100
GuardEncoding::parent
GuardField * parent() const
Definition: GuardEncoding.cc:90