#ifndef SHELL_H #define SHELL_H #include #include #include #include #include #include #include #include #include #include #include "command.h" //#include "commands.h" #include "commandexecutor.h" using std::string; using std::cin; using std::cout; using std::cerr; using std::string; using std::vector; using std::istringstream; namespace mshconsole { class Shell : public CommandExecutor { class Commands { Shell* parent; vector commands; //commands that work the same thread of the shell vector threadCommands; //commands that work on a different thread public: Commands(Shell*); void add(Command*, bool isthread=false); size_t howMany() const; int launch(const vector* args, bool launchThread=false); }; static bool undoingLine; Commands cmds; string ps; string name; void (*shellSetup)(Shell *); void (*shellPostSetup)(Shell *); bool notLoop; int launchCmd(vector* args); static void EofHandler(int); string* read_line(); vector* split_line(const string* line); class IsUndoingLineException {}; class CommandNotFoundException {}; public: Shell(string n="msh", string ps="MSH$", void (*s)(Shell*)=0, void (*pss)(Shell*)=0); string getPs() const; void setPs(const string &value); string getName() const; void setName(const string &value); int launch(); void setShellSetup(void (*)(Shell *)); void (*getShellSetup())(Shell*); void setShellPostSetup(void (*)(Shell *)); void (*getShellPostSetup())(Shell*); //for in-shell commands void addCmd(Command *cmd, bool isThread=false); size_t howManyCmds() const; int executeCmd(vector* args); int executeCmd(const string& args); }; } #endif // SHELL_H