source: nrEngine/include/EventFactory.h @ 1

Revision 1, 2.9 KB checked in by art, 14 years ago (diff)
Line 
1/***************************************************************************
2 *                                                                         *
3 *   (c) Art Tevs, MPI Informatik Saarbruecken                             *
4 *       mailto: <tevs@mpi-sb.mpg.de>                                      *
5 *                                                                         *
6 *   This program is free software; you can redistribute it and/or modify  *
7 *   it under the terms of the GNU General Public License as published by  *
8 *   the Free Software Foundation; either version 2 of the License, or     *
9 *   (at your option) any later version.                                   *
10 *                                                                         *
11 ***************************************************************************/
12
13
14#ifndef _NR_EVENT_FACTORY_H_
15#define _NR_EVENT_FACTORY_H_
16
17//----------------------------------------------------------------------------------
18// Includes
19//----------------------------------------------------------------------------------
20#include "Prerequisities.h"
21#include "Event.h"
22
23namespace nrEngine{
24
25        //! Event factories are used to create events of certain types
26        /**
27         * EventFatory is an object which is able to create events of certain
28         * type. You can either create events by yourself or through such
29         * a factory.
30         *
31         * We introduce the concept of a factory to enable sharing of new event
32         * types through plugins. That means, that plugins provide the engine
33         * such a factory to create an event object within the engine memory either
34         * in the plugin (dynamic library) memory.
35         *
36         * \ingroup event
37        **/
38        class _NRExport EventFactory{
39                public:
40
41                        /**
42                         * Create a instance of a new factory.
43                         **/
44                        EventFactory(const std::string& name);
45
46                        /**
47                         * Release used memory and remove the list of supported event types
48                         * from the event manager. So no new events of the supported types
49                         * could be created throguh this factory
50                         **/
51                        virtual ~EventFactory();
52
53
54                        /**
55                         * Return true if the given event type is supported
56                         **/
57                        bool isSupported(const std::string& eventType) const;
58
59                        /**
60                         * Create a new instance of an event of the given type
61                         *
62                         * @param eventType Type name of the event to create
63                         * @return NULL if the event could not been created or
64                         *                              a valid smart pointer otherwise
65                         **/
66                        virtual SharedPtr<Event> create(const std::string& eventType) = 0;
67
68                        /**
69                         * Get the name
70                         **/
71                        const std::string& getName () const { return mName; }
72                protected:
73
74                        //! List containing all supported event types by their names
75                        typedef std::list<std::string> NameList;
76
77                        //! Variabl eto hold all supported types
78                        NameList mSupportedTypes;
79
80                        //! Fill the list of supported event types
81                        virtual void fillSupported() = 0;
82
83                        //! Name of the factory
84                        std::string mName;
85
86        };
87
88}; // end namespace
89
90#endif
Note: See TracBrowser for help on using the repository browser.