OpenASIP 2.2
Loading...
Searching...
No Matches
OperationModule.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 OperationModule.cc
26 *
27 * Definition of OperationModule class.
28 *
29 * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30 * @note rating: yellow
31 * @note reviewed 7 September 2004 by pj, jn, jm, ao
32 */
33
34#include <string>
35
36#include "OperationModule.hh"
37#include "FileSystem.hh"
38
39using std::string;
40
41/// Property file extension.
43/// Behavior file extension.
45/// Source file extension.
47
48/**
49 * Constructor.
50 *
51 * @param name The name of the module.
52 * @param path The path of the module.
53 */
55 const std::string& name,
56 const std::string& path) : path_(path), name_(name) {
57}
58
59/**
60 * Copy constructor.
61 *
62 * @param om The module to be copied.
63 */
68
69/**
70 * Destructor.
71 */
74
75/**
76 * Assignment operator.
77 *
78 * @param om Module to be assigned.
79 */
86
87/**
88 * Checks whether OperationModule has behavior definition file.
89 *
90 * @return True if OperationModule has behavior definition file.
91 */
92bool
97
98/**
99 * Returns the name of the behavior module.
100 *
101 * @return The name of the behavior module.
102 * @exception FileNotFound If behavior module is not found.
103 */
104string
106 if (!definesBehavior()) {
107 std::string method = "OperationModule::behaviorModule()";
108 std::string msg = "Behavior file not found: " + behaviorFileName();
109 throw FileNotFound(__FILE__, __LINE__, method, msg);
110 }
111
113}
114
115/**
116 * Returns the name of the properties module.
117 *
118 * @return The name of the properties module.
119 */
120string
124
125/**
126 * Checks whether module has behavior source file.
127 *
128 * @return True if module has behavior source file.
129 */
130bool
136
137/**
138 * Returns the name of the behavior source code file.
139 *
140 * @return The name of the behavior source code file.
141 * @exception FileNotFound If behavior source file not found.
142 */
143string
145 if (!hasBehaviorSource()) {
146 std::string method = "OperationModule::behaviorSourceModule()";
147 std::string msg = "Behavior source file not found.";
148 throw FileNotFound(__FILE__, __LINE__, method, msg);
149 }
150
152}
153
154/**
155 * Returns the name of the module.
156 *
157 * @return The name of the module.
158 */
159std::string
161 return name_;
162}
163
164/**
165 * Returns the name of the behavior file name.
166 *
167 * @return The name of the behavior file name.
168 */
169std::string
173
174/**
175 * Returns the name of the properties file.
176 *
177 * @return The name of the properties file.
178 */
179std::string
183
184/**
185 * Returns the name of the code file.
186 *
187 * @return The name of the code file.
188 */
189std::string
193
194//////////////////////////////////////////////////////////////////////////////
195// NullOperationModule
196//////////////////////////////////////////////////////////////////////////////
197
199
200/**
201 * Constructor.
202 */
205
206/**
207 * Destructor.
208 */
211
212/**
213 * Writes a message to error log and aborts the program.
214 *
215 * @return Never returns.
216 */
217string
219 abortWithError("name()");
220 return "";
221}
222
223/**
224 * Writes a message to error log and aborts the program.
225 *
226 * @return Never returns.
227 */
228bool
230 abortWithError("definesBehavior()");
231 return false;
232}
233
234/**
235 * Writes a message to error log and aborts the program.
236 *
237 * @return Never returns.
238 * @exception FileNotFound If behavior module is not found.
239 */
240string
242 abortWithError("behaviorModule()");
243 return "";
244}
245
246/**
247 * Writes a message to error log and aborts the program.
248 *
249 * @return Never returns.
250 */
251string
253
254 abortWithError("propertiesModule()");
255 return "";
256}
257
258/**
259 * Writes a message to error log and aborts the program.
260 *
261 * @return Never returns.
262 */
263bool
265 abortWithError("hasBehaviorSource()");
266 return false;
267}
268
269/**
270 * Writes a message to error log and aborts the program.
271 *
272 * @return Never returns.
273 * @exception FileNotFound Doesn't throw.
274 */
275string
277 abortWithError("behaviorSourceModule()");
278 return "";
279}
#define abortWithError(message)
static const std::string DIRECTORY_SEPARATOR
static std::string directoryOfPath(const std::string fileName)
Definition FileSystem.cc:79
static bool fileExists(const std::string fileName)
virtual std::string propertiesModule() const
virtual bool definesBehavior() const
virtual std::string behaviorSourceModule() const
virtual bool hasBehaviorSource() const
static NullOperationModule instance_
Unique instance of NullOperationModule.
virtual std::string name() const
virtual std::string behaviorModule() const
std::string name_
The name of the module.
virtual bool hasBehaviorSource() const
virtual std::string name() const
OperationModule(const std::string &name, const std::string &path)
std::string behaviorSourceFileName() const
std::string behaviorFileName() const
virtual std::string behaviorSourceModule() const
static const std::string BEHAVIOR_FILE_EXTENSION
File extension of operation behavior file.
std::string path_
The path of the module.
std::string propertyFileName() const
static const std::string PROPERTY_FILE_EXTENSION
File extension of operation property file.
virtual bool definesBehavior() const
virtual std::string propertiesModule() const
static const std::string BEHAVIOR_SOURCE_FILE_EXTENSION
File extension of operation behavior source file.
OperationModule & operator=(const OperationModule &om)
virtual ~OperationModule()
virtual std::string behaviorModule() const