diff --git a/src/commands/Command.cpp b/src/commands/Command.cpp index bbb188f4f..c11aaa40c 100644 --- a/src/commands/Command.cpp +++ b/src/commands/Command.cpp @@ -37,20 +37,15 @@ extern Context context; //////////////////////////////////////////////////////////////////////////////// -Command* Command::factory (const std::string& name) +void Command::factory (std::map & all) { - Command* command; - if (name == "execute") command = new CmdExec (); - else if (name == "help") command = new CmdHelp (); - else if (name == "install") command = new CmdInstall (); - else if (name == "tip") command = new CmdTip (); - else if (name == "_logo") command = new CmdLogo (); - else - throw std::string ("Unrecognized command object '") + name + "'"; + Command* c; - // TODO Initialize command object. - - return command; + c = new CmdExec (); all[c->keyword ()] = c; + c = new CmdHelp (); all[c->keyword ()] = c; + c = new CmdInstall (); all[c->keyword ()] = c; + c = new CmdLogo (); all[c->keyword ()] = c; + c = new CmdTip (); all[c->keyword ()] = c; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/commands/Command.h b/src/commands/Command.h index 7c74d0be5..fd38985cd 100644 --- a/src/commands/Command.h +++ b/src/commands/Command.h @@ -27,6 +27,7 @@ #ifndef INCLUDED_COMMAND #define INCLUDED_COMMAND +#include #include class Command @@ -38,7 +39,7 @@ public: bool operator== (const Command&) const; // TODO Is this necessary? virtual ~Command (); - static Command* factory (const std::string&); + static void factory (std::map &); std::string keyword () const; std::string usage () const; diff --git a/src/custom.cpp b/src/custom.cpp index bd9afe084..b1b2a3172 100644 --- a/src/custom.cpp +++ b/src/custom.cpp @@ -250,10 +250,13 @@ int handleCustomReport (const std::string& report, std::string& outs) view.colorOdd (alternate); view.intraColorOdd (alternate); - // Add the columns. - std::vector ::iterator it; - for (it = columns.begin (); it != columns.end (); ++it) - view.add (Column::factory (*it, report)); + // Add the columns and labels. + for (int i = 0; i < columns.size (); ++i) + { + Column* c = Column::factory (columns[i], report); + c->setLabel (labels[i]); + view.add (c); + } // How many lines taken up by table header? int table_header;