# # # patch "cmd.hh" # from [52377d3932566abc191667df0ebc1d4f50265ecd] # to [a0b681abc8d9e4c1bacba9872c74ca3d0aefb6fd] # # patch "cmd_automate.cc" # from [b27ebd32c5e0d86f94f3e56090b14b33fe5c46ba] # to [c767bbcf9be20884fbf2b1abe603c6a0c7c64b42] # ============================================================ --- cmd.hh 52377d3932566abc191667df0ebc1d4f50265ecd +++ cmd.hh a0b681abc8d9e4c1bacba9872c74ca3d0aefb6fd @@ -91,6 +91,18 @@ namespace commands class automate : public command { + // This function is supposed to be called only after the requirements + // for "automate" commands have been fulfilled. This is done by the + // "exec" function defined below, which implements code shared among + // all automation commands. Also, this is also needed by the "stdio" + // automation, as it executes multiple of these commands sharing the + // same initialization, hence the friend declaration. + virtual void exec_from_automate(args_vector args, + command_id const & execid, + app_state & app, + std::ostream & output) const = 0; + friend class automate_stdio; + public: automate(std::string const & name, std::string const & params, @@ -98,13 +110,9 @@ namespace commands std::string const & desc, options::options_type const & opts); - virtual void exec(app_state & app, - command_id const & execid, - args_vector const & args); - virtual void run(args_vector args, - command_id const & execid, - app_state & app, - std::ostream & output) const = 0; + void exec(app_state & app, + command_id const & execid, + args_vector const & args); }; }; @@ -238,22 +246,24 @@ namespace commands { // automatically built from these. #define CMD_AUTOMATE(C, params, abstract, desc, opts) \ namespace commands { \ - struct automate_ ## C : public automate \ + class automate_ ## C : public automate \ { \ + void exec_from_automate(args_vector args, \ + command_id const & execid, \ + app_state & app, \ + std::ostream & output) const; \ + public: \ automate_ ## C() : automate(#C, params, abstract, desc, \ options::options_type() | opts) \ {} \ - void run(args_vector args, \ - command_id const & execid, \ - app_state & app, \ - std::ostream & output) const; \ }; \ automate_ ## C C ## _automate; \ } \ -void commands::automate_ ## C :: run(args_vector args, \ - command_id const & execid, \ - app_state & app, \ - std::ostream & output) const +void commands::automate_ ## C :: exec_from_automate \ + (args_vector args, \ + command_id const & execid, \ + app_state & app, \ + std::ostream & output) const CMD_FWD_DECL(__root__); ============================================================ --- cmd_automate.cc b27ebd32c5e0d86f94f3e56090b14b33fe5c46ba +++ cmd_automate.cc c767bbcf9be20884fbf2b1abe603c6a0c7c64b42 @@ -43,7 +43,7 @@ namespace commands { args_vector const & args) { make_io_binary(); - run(args, execid, app, std::cout); + exec_from_automate(args, execid, app, std::cout); } } @@ -372,7 +372,7 @@ CMD_AUTOMATE(stdio, "", opts = options::opts::globals() | acmd->opts(); opts.instantiate(&app.opts).from_key_value_pairs(params); - acmd->run(args, id, app, os); + acmd->exec_from_automate(args, id, app, os); } else opts.instantiate(&app.opts).from_key_value_pairs(params);