SDL++
C++wrapperfortheSDLlibrary.

event/Event.h

Go to the documentation of this file.
00001 
00021 #ifndef SDL_EVENT_EVENT_H
00022 #define SDL_EVENT_EVENT_H
00023 
00024 #include <stdexcept>
00025 
00026 #include <SDL.h>
00027 
00028 namespace sdl {
00029 namespace event {
00030     using namespace misc;
00031 
00036     struct EventBase {
00042         EventBase (const SDL_Event* event) : event_ (event) {};
00043 
00044         protected:
00048             const SDL_Event* event_;
00049     }; //EventBase
00050 
00058     template<typename Comparator, typename Base>
00059     struct Event : public Base {
00067         static bool is (const SDL_Event* event) { return Comparator::compare (event); };
00068 
00076         explicit Event (const SDL_Event* event = 0) : Base (event) {
00077             if (event != 0)
00078                 if (!is (event)) throw std::runtime_error ("Mismatch");
00079         };
00080     }; //Event
00081 }; //event
00082 }; //sdl
00083 
00084 #endif //SDL_EVENT_EVENT_H
00085 
 All Classes Namespaces Files Functions Variables Typedefs