The CommandFactory's role is to isolate Command creation into a single class. The factory provides a createCommand method that determines which concrete command subclass should be created, and returns it. That way, all the rest of the application needs to know is that they are dealing with a Command, not a specific Command subclass.
This class is implemented as a singleton.
|CommandFactory* instance ()|
Get a pointer to the single instance of the CommandFactory class.
|void setIRCModule (IRCModule* ircModule)|
The CommandFactory needs to know what IRCModule is currently used to pass it along to Commands it creates. This method must be called before any call to createCommand.
PRECONDITIONS: ircModule != 0
|ircModule||A non-null pointer to the IRCModule object to use.|
|Command* createCommand (DCCUser* pUser,QString text)|
Create the appropriate Command subclass, depending on the given text. The first word of text is taken as the command name, and the corresponding command subclass is created. The calling method is responsible for freeing the created object.
PRECONDITIONS: _ircModule != 0 ; pUser != 0 ; text != ""
|pUser||A pointer to the DCCUser object of the user who initiated the command.|
|text||The text given by the user. The first word will be interpreted as the command's name.|
Returns: A pointer to a new Command object, or 0 if the first word of text did not correspond to any known command.