|
PLearn 0.1
|
#include <PLearnCommandRegistry.h>
Public Types | |
| typedef map< string, PLearnCommand * > | command_map |
Public Member Functions | |
| PLearnCommandRegistry (PLearnCommand *plcommand) | |
| prints out detailed help for the given command on the given stream | |
Static Public Member Functions | |
| static const command_map & | allCommands () |
| Returns a const reference to the unique command map. | |
| static PLearnCommand * | getCommand (const string &commandname) |
| Returns the PLearnCommand with the given name, or error. | |
| static void | do_register (PLearnCommand *command) |
| registers a command | |
| static bool | is_registered (const string &commandname) |
| checks wether a command is registered with that name | |
| static void | run (const string &commandname, const vector< string > &args) |
| prints a list of all commands with their one-line summary | |
Static Protected Member Functions | |
| static void | badcommand (const string &commandname) |
| Issues a "bad command" message. | |
| static command_map & | commands () |
| Returns a reference to the unique command map. | |
Friends | |
| class | HTMLHelpCommand |
Definition at line 54 of file PLearnCommandRegistry.h.
| typedef map<string, PLearnCommand*> PLearn::PLearnCommandRegistry::command_map |
Definition at line 60 of file PLearnCommandRegistry.h.
| PLearn::PLearnCommandRegistry::PLearnCommandRegistry | ( | PLearnCommand * | plcommand | ) | [inline] |
prints out detailed help for the given command on the given stream
This constructor will simply register the given PLearnCommand
Definition at line 95 of file PLearnCommandRegistry.h.
{ do_register(plcommand); }
| static const command_map& PLearn::PLearnCommandRegistry::allCommands | ( | ) | [inline, static] |
Returns a const reference to the unique command map.
Definition at line 73 of file PLearnCommandRegistry.h.
Referenced by PLearn::HelpSystem::listCommands().
{ return commands(); }

| void PLearn::PLearnCommandRegistry::badcommand | ( | const string & | commandname | ) | [static, protected] |
Issues a "bad command" message.
Definition at line 76 of file PLearnCommandRegistry.cc.
References PLearn::endl(), PLearn::flush(), PLearn::HelpSystem::helpCommands(), and PLearn::perr.
{
perr << "No '" << commandname << "' command available." << endl;
perr << "Available commands are: " << endl;
//print_command_summary(cerr);
perr << HelpSystem::helpCommands() << flush;
perr << "You can get more help for any of these commands by invoking the help command" << endl;
}

| PLearnCommandRegistry::command_map & PLearn::PLearnCommandRegistry::commands | ( | ) | [static, protected] |
Returns a reference to the unique command map.
Definition at line 49 of file PLearnCommandRegistry.cc.
Referenced by PLearn::HTMLHelpCommand::helpCommands(), and PLearn::HTMLHelpCommand::helpOnCommand().
{
static PLearnCommandRegistry::command_map commands_;
return commands_;
}

| void PLearn::PLearnCommandRegistry::do_register | ( | PLearnCommand * | command | ) | [static] |
registers a command
Definition at line 55 of file PLearnCommandRegistry.cc.
References PLearn::PLearnCommand::name.
{ commands()[command->name] = command; }
| PLearnCommand * PLearn::PLearnCommandRegistry::getCommand | ( | const string & | commandname | ) | [static] |
Returns the PLearnCommand with the given name, or error.
Definition at line 94 of file PLearnCommandRegistry.cc.
Referenced by PLearn::HelpSystem::helpCommands(), PLearn::HelpSystem::helpCommandsHTML(), PLearn::HelpSystem::helpOnCommand(), and PLearn::HelpSystem::helpOnCommandHTML().
{
command_map::iterator it = commands().find(commandname);
if(it==commands().end()) badcommand(commandname);
return it->second;
}

| bool PLearn::PLearnCommandRegistry::is_registered | ( | const string & | commandname | ) | [static] |
checks wether a command is registered with that name
Definition at line 58 of file PLearnCommandRegistry.cc.
Referenced by PLearn::is_command(), and PLearn::HelpCommand::run().

| void PLearn::PLearnCommandRegistry::run | ( | const string & | commandname, |
| const vector< string > & | args | ||
| ) | [static] |
prints a list of all commands with their one-line summary
run the given (registered) command with the given arguments
Definition at line 85 of file PLearnCommandRegistry.cc.
Referenced by PLearn::plearn_main().
{
command_map::iterator it = commands().find(commandname);
if(it==commands().end())
badcommand(commandname);
else
it->second->run(args);
}

friend class HTMLHelpCommand [friend] |
Definition at line 57 of file PLearnCommandRegistry.h.
1.7.4