OpenASIP 2.2
Loading...
Searching...
No Matches
CustomCommand.hh
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 CustomCommand.hh
26 *
27 * The declaration of CustomCommand 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 * @note reviewed 27 May 2004 by pj, jn, vpj, ll
32 * @note rating: green
33 */
34
35#ifndef TTA_CUSTOM_COMMAND_HH
36#define TTA_CUSTOM_COMMAND_HH
37
38#include <string>
39#include <vector>
40
41#include "LineReader.hh"
42#include "InterpreterContext.hh"
43#include "ScriptInterpreter.hh"
44#include "DataObject.hh"
45#include "Exception.hh"
46
48
49/**
50 * Abstract base class for all CustomCommands for Interpreter.
51 *
52 * CustomCommand is a user defined command designed for a particular task.
53 */
55
56public:
57 explicit CustomCommand(std::string name);
58 CustomCommand(const CustomCommand& cmd);
59 virtual ~CustomCommand();
60
61 std::string name() const;
62
65
68
69 virtual bool execute(const std::vector<DataObject>& arguments) = 0;
70 virtual std::string helpText() const = 0;
71
72 bool checkArgumentCount(int argumentCount, int minimum, int maximum);
73 bool checkIntegerArgument(const DataObject& argument);
74 bool checkPositiveIntegerArgument(const DataObject& argument);
75 bool checkUnsignedIntegerArgument(const DataObject& argument);
76 bool checkDoubleArgument(const DataObject& argument);
77
78private:
79 /// Assignment not allowed.
81
82 /// The name of the command.
83 std::string name_;
84 /// Context of the command.
86 /// Interpreter for the command.
88};
89
90#include "CustomCommand.icc"
91
92#endif
InterpreterContext * context() const
bool checkArgumentCount(int argumentCount, int minimum, int maximum)
bool checkUnsignedIntegerArgument(const DataObject &argument)
std::string name_
The name of the command.
virtual bool execute(const std::vector< DataObject > &arguments)=0
std::string name() const
virtual ~CustomCommand()
CustomCommand & operator=(const CustomCommand &)
Assignment not allowed.
ScriptInterpreter * interpreter_
Interpreter for the command.
virtual std::string helpText() const =0
InterpreterContext * context_
Context of the command.
bool checkIntegerArgument(const DataObject &argument)
ScriptInterpreter * interpreter() const
bool checkPositiveIntegerArgument(const DataObject &argument)
void setContext(InterpreterContext *context)
void setInterpreter(ScriptInterpreter *si)
bool checkDoubleArgument(const DataObject &argument)