#ifndef SHELL_H #define SHELL_H #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; using std::nullptr_t; 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 //just one instance of the object static bool created; Commands(const Commands&); Commands operator=(const Commands&); 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 *); bool notLoop; int launchCmd(vector* args); static void EofHandler(int); string* read_line(); vector* split_line(const string* line); class IsUndoingLineException {}; public: Shell(string n="msh", string ps="MSH$", void (*s)(Shell*)=0); string getPs() const; void setPs(const string &value); string getName() const; void setName(const string &value); void launch(); //for in-shell commands void addCmd(Command *cmd, bool isThread=false); size_t howManyCmds() const; int executeCmd(vector* args); int executeCmd(const string& args); //exceptions class CommandsAlreadyCreatedException{}; class CommandNotFoundException{}; class ShellLaunchInSetupException{}; }; #endif // SHELL_H