/* Copyright 2007 Arne Schober
//
// This file is part of Valen3d.
//
// Valen3d is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Valen3d is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. //*/
#pragma once
//#include <boost/intrusive_ptr.hpp>
//#include <boost/shared_ptr.hpp>
//typedef boost::intrusive_ptr<Event> pEvent;
//typedef boost::intrusive_ptr<QuitEvent> pQuitEvent;
//typedef boost::shared_ptr<Event> pEvent;
//typedef boost::shared_ptr<NullEvent> pNullEvent;
//typedef boost::shared_ptr<QuitEvent> pQuitEvent;
#include <queue>
#include <boost/thread/mutex.hpp>
enum EventFailture
{
fNoFailture,
fEvent,
fNullEvent,
fQuitEvent,
fDoneEvent,
fInputEvent,
fSwitchEvent,
fMouseEvent,
fKeyboardEvent,
fTimedEvent,
fRendererEvent,
fDrawEvent,
fUpdateEvent,
fScreenResizeEvent
};
struct Event;
struct NullEvent;
struct QuitEvent;
struct DoneEvent;
struct InputEvent;
struct SwitchEvent;
struct MouseEvent;
struct KeyboardEvent;
struct TimedEvent;
struct RendererEvent;
struct DrawEvent;
struct UpdateEvent;
struct ScreenResizeEvent;
typedef Event pEvent;
typedef NullEvent pNullEvent;
typedef QuitEvent pQuitEvent;
typedef DoneEvent pDoneEvent;
typedef InputEvent pInputEvent;
typedef SwitchEvent pSwitchEvent;
typedef MouseEvent pMouseEvent;
typedef KeyboardEvent pKeyboardEvent;
typedef TimedEvent pTimedEvent;
typedef RendererEvent pRendererEvent;
typedef DrawEvent pDrawEvent;
typedef UpdateEvent pUpdateEvent;
typedef ScreenResizeEvent pScreenResizeEvent;
class SDLApplication;
/** Event handler Interface
*
*/
class Object
{
friend class SDLApplication;
friend struct Event;
public:
Object(void);
virtual ~Object(void);
virtual Event* handle(pEvent &e);
virtual Event* handle(pDoneEvent &e);
virtual Event* handle(pNullEvent &e);
virtual Event* handle(pQuitEvent &e);
virtual Event* handle(pInputEvent &e);
virtual Event* handle(pSwitchEvent &e);
virtual Event* handle(pMouseEvent &e);
virtual Event* handle(pKeyboardEvent &e);
virtual Event* handle(pTimedEvent &e);
virtual Event* handle(pRendererEvent &e);
virtual Event* handle(pDrawEvent &e);
virtual Event* handle(pUpdateEvent &e);
virtual Event* handle(pScreenResizeEvent &e);
protected:
static boost::try_mutex m;
static void push_Event(Event* e);
static std::queue<Event*> eventqueue; //TODO bessere Locking Strategie
private:
virtual void pop_Event(){}
};