3 This file is part of gldbg
4 Copyright © 2009-2010 Mikko Rasa, Mikkosoft Productions
5 Distributed under the GPL
8 #ifndef COMMANDINTERPRETER_H_
9 #define COMMANDINTERPRETER_H_
16 class CommandInterpreter
22 std::string description;
28 virtual ~Command() { }
30 void set_help(const std::string &);
31 void set_help(const std::string &, const std::string &);
32 const std::string &get_description() const { return description; }
33 const std::string &get_help() const { return help; }
35 virtual void execute(const std::string &) = 0;
40 class CommandFunction: public Command
43 typedef void (T::*Func)(const std::string &);
48 CommandFunction(T *o, Func f): obj(o), func(f) { }
50 virtual void execute(const std::string &a)
54 class CommandAlias: public Command
60 CommandAlias(Command *);
62 const Command *get_target() const { return target; }
64 virtual void execute(const std::string &);
67 typedef std::map<std::string, Command *> CommandMap;
73 CommandInterpreter(GlDbg &);
76 Command ®ister_command(const std::string &n, T *o, void (T::*f)(const std::string &))
77 { return *(commands[n] = new CommandFunction<T>(o, f)); }
79 void execute(const std::string &);
82 void cmd_help(const std::string &);
83 void cmd_run(const std::string &);
84 void cmd_break(const std::string &);
85 void cmd_unbreak(const std::string &);
86 void cmd_next(const std::string &);
87 void cmd_finish(const std::string &);
88 void cmd_continue(const std::string &);
89 void cmd_signal(const std::string &);
90 void cmd_kill(const std::string &);
91 void cmd_exit(const std::string &);