EventFactory.h

00001 /***************************************************************************
00002  *                                                                         *
00003  *   (c) Art Tevs, MPI Informatik Saarbruecken                             *
00004  *       mailto: <tevs@mpi-sb.mpg.de>                                      *
00005  *                                                                         *
00006  *   This program is free software; you can redistribute it and/or modify  *
00007  *   it under the terms of the GNU General Public License as published by  *
00008  *   the Free Software Foundation; either version 2 of the License, or     *
00009  *   (at your option) any later version.                                   *
00010  *                                                                         *
00011  ***************************************************************************/
00012 
00013 
00014 #ifndef _NR_EVENT_FACTORY_H_
00015 #define _NR_EVENT_FACTORY_H_
00016 
00017 //----------------------------------------------------------------------------------
00018 // Includes
00019 //----------------------------------------------------------------------------------
00020 #include "Prerequisities.h"
00021 #include "Event.h"
00022 
00023 namespace nrEngine{
00024 
00025         //! Event factories are used to create events of certain types
00026         /**
00027          * EventFatory is an object which is able to create events of certain
00028          * type. You can either create events by yourself or through such
00029          * a factory.
00030          *
00031          * We introduce the concept of a factory to enable sharing of new event
00032          * types through plugins. That means, that plugins provide the engine
00033          * such a factory to create an event object within the engine memory either
00034          * in the plugin (dynamic library) memory.
00035          *
00036          * \ingroup event
00037         **/
00038         class _NRExport EventFactory{
00039                 public:
00040 
00041                         /**
00042                          * Create a instance of a new factory.
00043                          **/
00044                         EventFactory(const std::string& name);
00045 
00046                         /**
00047                          * Release used memory and remove the list of supported event types
00048                          * from the event manager. So no new events of the supported types
00049                          * could be created throguh this factory
00050                          **/
00051                         virtual ~EventFactory();
00052 
00053 
00054                         /**
00055                          * Return true if the given event type is supported
00056                          **/
00057                         bool isSupported(const std::string& eventType) const;
00058 
00059                         /**
00060                          * Create a new instance of an event of the given type
00061                          *
00062                          * @param eventType Type name of the event to create
00063                          * @return NULL if the event could not been created or
00064                          *                              a valid smart pointer otherwise
00065                          **/
00066                         virtual SharedPtr<Event> create(const std::string& eventType) = 0;
00067 
00068                         /**
00069                          * Get the name
00070                          **/
00071                         const std::string& getName () const { return mName; }
00072                 protected:
00073 
00074                         //! List containing all supported event types by their names
00075                         typedef std::list<std::string> NameList;
00076 
00077                         //! Variabl eto hold all supported types
00078                         NameList mSupportedTypes;
00079 
00080                         //! Fill the list of supported event types
00081                         virtual void fillSupported() = 0;
00082 
00083                         //! Name of the factory
00084                         std::string mName;
00085 
00086         };
00087 
00088 }; // end namespace
00089 
00090 #endif

Generated on Wed Sep 12 23:19:42 2007 for nrEngine by  doxygen 1.5.1