/*
-----------------------------------------------------------------------------
This source file is part of the Particle Universe product.

Copyright (c) 2006-2008 Henry van Merode

Usage of this program is free for non-commercial use and licensed under the
the terms of the GNU Lesser General Public License.

You should have received a copy of the GNU Lesser General Public License along with
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
Place - Suite 330, Boston, MA 02111-1307, USA, or go to
http://www.gnu.org/copyleft/lesser.txt.
-----------------------------------------------------------------------------
*/

#ifndef __PU_EVENT_HANDLER_FACTORY_H__
#define __PU_EVENT_HANDLER_FACTORY_H__

#include "ParticleUniversePrerequisites.h"
#include "ParticleUniverseEventHandler.h"
#include "ParticleUniverseITokenInitialiser.h"

namespace ParticleUniverse
{
	/** This is the base factory of all ParticleEventHandler implementations.
    */
	class _ParticleUniverseExport ParticleEventHandlerFactory : public ITokenInitialiser
	{
	    protected:

			/** 
	        */
			template <class T>
			ParticleEventHandler* _createEventHandler(void)
			{
				ParticleEventHandler* particleEventHandler = new T();
				particleEventHandler->setEventHandlerType(getEventHandlerType());
				return particleEventHandler;
			};

	public:
			ParticleEventHandlerFactory(void) {};
	        virtual ~ParticleEventHandlerFactory(void) {};

		    /** Returns the type of the factory, which identifies the event handler type this factory creates. */
			virtual Ogre::String getEventHandlerType() const = 0;

	        /** Creates a new event handler instance.
		    @remarks
	        */
		    virtual ParticleEventHandler* createEventHandler(void) = 0;

			/** Delete an event handler
	        */
			void destroyEventHandler (ParticleEventHandler* eventHandler){delete eventHandler;};
	};

}
#endif
