OpenASIP  2.0
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 
47 class ScriptInterpreter;
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 
56 public:
57  explicit CustomCommand(std::string name);
58  CustomCommand(const CustomCommand& cmd);
59  virtual ~CustomCommand();
60 
61  std::string name() const;
62 
64  InterpreterContext* context() const;
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 
78 private:
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
CustomCommand::setContext
void setContext(InterpreterContext *context)
CustomCommand::checkArgumentCount
bool checkArgumentCount(int argumentCount, int minimum, int maximum)
Definition: CustomCommand.cc:82
CustomCommand::name
std::string name() const
Exception.hh
DataObject
Definition: DataObject.hh:50
CustomCommand::setInterpreter
void setInterpreter(ScriptInterpreter *si)
CustomCommand::checkPositiveIntegerArgument
bool checkPositiveIntegerArgument(const DataObject &argument)
Definition: CustomCommand.cc:134
CustomCommand::context
InterpreterContext * context() const
CustomCommand::name_
std::string name_
The name of the command.
Definition: CustomCommand.hh:83
InterpreterContext.hh
CustomCommand::execute
virtual bool execute(const std::vector< DataObject > &arguments)=0
CustomCommand::checkIntegerArgument
bool checkIntegerArgument(const DataObject &argument)
Definition: CustomCommand.cc:110
ScriptInterpreter.hh
CustomCommand::CustomCommand
CustomCommand(std::string name)
Definition: CustomCommand.cc:48
CustomCommand.icc
LineReader.hh
CustomCommand::checkUnsignedIntegerArgument
bool checkUnsignedIntegerArgument(const DataObject &argument)
Definition: CustomCommand.cc:164
CustomCommand
Definition: CustomCommand.hh:54
InterpreterContext
Definition: InterpreterContext.hh:40
DataObject.hh
CustomCommand::interpreter
ScriptInterpreter * interpreter() const
CustomCommand::operator=
CustomCommand & operator=(const CustomCommand &)
Assignment not allowed.
ScriptInterpreter
Definition: ScriptInterpreter.hh:55
CustomCommand::checkDoubleArgument
bool checkDoubleArgument(const DataObject &argument)
Definition: CustomCommand.cc:195
CustomCommand::interpreter_
ScriptInterpreter * interpreter_
Interpreter for the command.
Definition: CustomCommand.hh:87
CustomCommand::context_
InterpreterContext * context_
Context of the command.
Definition: CustomCommand.hh:85
CustomCommand::helpText
virtual std::string helpText() const =0
CustomCommand::~CustomCommand
virtual ~CustomCommand()
Definition: CustomCommand.cc:66