OpenASIP 2.2
Loading...
Searching...
No Matches
ConditionScript.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 ConditionScript.cc
26 *
27 * Definition of ConditionScript class.
28 *
29 * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30 * @author Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
31 */
32
33#include <string>
34using std::string;
35#include <vector>
36using std::vector;
37
38#include "ConditionScript.hh"
39
40/**
41 * Constructor.
42 *
43 * @param interpreter Interpreter for the script.
44 * @param scriptLine A line of script.
45 */
47 ScriptInterpreter* interpreter,
48 std::string scriptLine) : Script(interpreter, scriptLine) {
49}
50
51/**
52 * Constructor.
53 *
54 * @param interpreter Interpreter for the script.
55 * @param script The script.
56 */
58 ScriptInterpreter* interpreter,
59 std::vector<std::string>& script) : Script(interpreter, script) {
60}
61
62/**
63 * Destructor.
64 */
67
68/**
69 * Tests if condition is true of false.
70 *
71 * @return True, if condition is true, false otherwise.
72 * @exception NumberFormatException If DataObject operation fails.
73 * @exception ScriptExecutionFailure If script execution fails.
74 */
75bool
77 vector<string> scripts = script();
78 if (scripts.size() == 1 && scripts[0] == "") {
79 return true;
80 }
81
82 DataObject obj = execute();
83 if (obj.stringValue() == "0") {
85 return false;
86 }
88 return true;
89}
90
91/**
92 * Copies the condition script.
93 *
94 * Allows dynamically bound copy.
95 *
96 * @return a new instance which is identical to this.
97 */
100 return new ConditionScript(*this);
101}
102
virtual bool conditionOk()
virtual ~ConditionScript()
ConditionScript(ScriptInterpreter *interpreter, std::string scriptLine)
virtual ConditionScript * copy() const
virtual std::string stringValue() const
virtual void setResult(DataObject *result)
ScriptInterpreter * interpreter_
Interpreter executing the commands.
Definition Script.hh:58
virtual std::vector< std::string > script() const
Definition Script.cc:106
virtual DataObject execute()
Definition Script.cc:82