Source: CommandFactory.h


Annotated List
Files
Globals
Hierarchy
Index
/***************************************************************************
 *
 * File:    CommandFactory.h
 * Created: Fri Jan 7 2000
 * (C) 2000 by David M. <captjay@superlink.net>
 *
 ***************************************************************************/
/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#ifndef COMMANDFACTORY_H
#define COMMANDFACTORY_H

#include <qobject.h>
#include <qstring.h>
#include "Command.h"

class IRCModule;
class DCCUser;

/**
* @author David M.
* @short Create command objects.
*
* The CommandFactory's role is to isolate Command creation into a single class.
* The factory provides a @ref 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.
*/
class CommandFactory : public QObject  {
public:
	~CommandFactory();
	/**
	* Get a pointer to the single instance of the CommandFactory class.
	*/
	static CommandFactory* instance();
	/**
	* 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 @ref createCommand.
	*
	* PRECONDITIONS: ircModule != 0
	* @param ircModule A non-null pointer to the IRCModule object to use.
	*/
  void setIRCModule(IRCModule* ircModule);

  /**
  * Create the appropriate @ref 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 != ""
  * @param pUser A pointer to the DCCUser object of the user who initiated
  * the command.
  * @param text The text given by the user. The first word will be interpreted
  * as the command's name.
  * @return A pointer to a new Command object, or 0 if the first word of text
  * did not correspond to any known command.
  */
  Command* createCommand(DCCUser* pUser,QString text);
protected:
	CommandFactory();
  static CommandFactory* _instance;
private:
  IRCModule* _ircModule;
};

#endif

Generated by: nightsky@centauri on Sat Jan 15 23:06:10 2000, using kdoc 2.0a30.