xmario/xSDL/xController.h

32 lines
522 B
C
Raw Normal View History

#ifndef DEF_XCONTROLLER_H
#define DEF_XCONTROLLER_H
#include "SDL.h"
#include <mutex>
#include <set>
#include "xEventHandler.h"
using namespace std;
class xController{
public:
xController();
~xController();
// called in scheduling
void handleEvent(SDL_Event* event);
// manage handlers
void attachEvent(xEventHandler* handler);
void detachEvent(xEventHandler* handler);
private:
// event handlers
set<xEventHandler*> _handlers;
// thread safety
mutex _mutex;
};
#endif