1 #ifndef COMMANDINTERPRETER_H_
2 #define COMMANDINTERPRETER_H_
9 class CommandInterpreter
15 std::string description;
21 virtual ~Command() { }
23 void set_help(const std::string &);
24 void set_help(const std::string &, const std::string &);
25 const std::string &get_description() const { return description; }
26 const std::string &get_help() const { return help; }
28 virtual void execute(const std::string &) = 0;
33 class CommandFunction: public Command
36 typedef void (T::*Func)(const std::string &);
41 CommandFunction(T *o, Func f): obj(o), func(f) { }
43 virtual void execute(const std::string &a)
47 class CommandAlias: public Command
53 CommandAlias(Command *);
55 const Command *get_target() const { return target; }
57 virtual void execute(const std::string &);
60 typedef std::map<std::string, Command *> CommandMap;
66 CommandInterpreter(GlDbg &);
69 Command ®ister_command(const std::string &n, T *o, void (T::*f)(const std::string &))
70 { return *(commands[n] = new CommandFunction<T>(o, f)); }
72 void execute(const std::string &);
75 void cmd_help(const std::string &);
76 void cmd_run(const std::string &);
77 void cmd_break(const std::string &);
78 void cmd_unbreak(const std::string &);
79 void cmd_next(const std::string &);
80 void cmd_finish(const std::string &);
81 void cmd_continue(const std::string &);
82 void cmd_signal(const std::string &);
83 void cmd_kill(const std::string &);
84 void cmd_exit(const std::string &);