Initial commit. Not even a game yet :P
[cToan.git] / src / SDLWrap_EventHandler.hpp
blob4dbb774b6c7b59fa56e9d5ad3bc41ff1df5a722d
1 #ifndef _SDLWRAP_EVENTHANDLER_H_
2 #define _SDLWRAP_EVENTHANDLER_H_
4 #include "SDL/SDL.h"
6 namespace SDLWrap {
8 /* This class takes care of all events, reading them, handling them etc. The plan is to have the game singleton inherit
9 * from this class so all actual event handling is taken care by the derived class. This class simply acts as a wrapper
10 * around the SDL_PollEvent() function and all the On* functions that detect and handle the individual unique events.
11 * Since I don't know what they'll be doing yet, the plan is to declare all On* functions that I need as pure virtual
12 * functions. This class won't be using any of them, it's all up to the singleton.
14 class EventHandler
16 public:
17 /* Empty constructor and destructor... */
18 EventHandler();
19 ~EventHandler();
21 /* This function is responsible for handling all calls to the On*() functions. Since they're all virtual for
22 * now, it's not like it's gonna be doing much, but once the singleton overrides the pure virtual functions
23 * then it can take control of any through this function. Well, more like this function will call the On*()
24 * functions, which are all defined by the singleton.
26 void HandleEvent();
28 /* Just a cheap wrapper around SDL_PollEvent. Just doing it to not type SDL_ :P */
29 bool PollEvent();
31 /* And... the virtuals :P Pretty much self explanatory as well. */
32 /* Actually wait, seems I misunderstood pure virtual and virtual functions. If it's just simply virtual, like
33 * what I'm doing here with my On*() functions, then they may be overridden, but pure virtual functions MUST be
34 * overridden, which is not what I'm looking for...
36 virtual void OnQuit() {};
38 protected:
39 SDL_Event *Event;
44 #endif