PLearn 0.1
Public Types | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Friends
PLearn::PLearnCommandRegistry Class Reference

#include <PLearnCommandRegistry.h>

List of all members.

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_mapallCommands ()
 Returns a const reference to the unique command map.
static PLearnCommandgetCommand (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_mapcommands ()
 Returns a reference to the unique command map.

Friends

class HTMLHelpCommand

Detailed Description

Definition at line 54 of file PLearnCommandRegistry.h.


Member Typedef Documentation

Definition at line 60 of file PLearnCommandRegistry.h.


Constructor & Destructor Documentation

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); }

Member Function Documentation

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(); }

Here is the caller graph for this function:

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;
}

Here is the call graph for this function:

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_;
}

Here is the caller graph for this function:

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;
}

Here is the caller graph for this function:

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().

{ return commands().find(commandname)!=commands().end(); }

Here is the caller graph for this function:

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);
}

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class HTMLHelpCommand [friend]

Definition at line 57 of file PLearnCommandRegistry.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines