/* 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/>. //*/
#include "Object.h"
#include "Event.h"
#include <assert.h>
#include <iostream>
#include <boost/thread/mutex.hpp>
std::queue<Event*> Object::eventqueue;
boost::try_mutex Object::m;
Object::Object(void)
{
}
Object::~Object(void)
{
}
void Object::push_Event(Event* e)
{//TODO bessere Locking Strategie
boost::try_mutex::scoped_try_lock loc(m,0);
loc.lock();
eventqueue.push(e);
loc.unlock();
}
Event* Object::handle(pEvent &e)
{
assert(std::cerr << "Object::handle(pEvent &e)" << std::endl);
e.failed = fEvent;
return e.accept(*this);
}
Event* Object::handle(pNullEvent &e)
{
assert(std::cerr << "Object::handle(pNullEvent &e)" << std::endl);
e.failed = fNullEvent;
return e.accept(*this);
}
Event* Object::handle(pQuitEvent &e)
{
assert(std::cerr << "Object::handle(pQuitEvent &e)" << std::endl);
e.failed = fQuitEvent;
return e.accept(*this);
}
Event* Object::handle(pDoneEvent &e)
{
assert(std::cerr << "Object::handle(pDoneEvent &e)" << std::endl);
e.failed = fDoneEvent;
return e.accept(*this);
}
Event* Object::handle(pInputEvent &e)
{
assert(std::cerr << "Object::handle(pInputEvent &e)" << std::endl);
e.failed = fInputEvent;
return e.accept(*this);
}
Event* Object::handle(pSwitchEvent &e)
{
assert(std::cerr << "Object::handle(pSwitchEvent &e)" << std::endl);
e.failed = fSwitchEvent;
return e.accept(*this);
}
Event* Object::handle(pMouseEvent &e)
{
assert(std::cerr << "Object::handle(pMouseEvent &e)" << std::endl);
e.failed = fMouseEvent;
return e.accept(*this);
}
Event* Object::handle(pKeyboardEvent &e)
{
assert(std::cerr << "Object::handle(pKeyboardEvent &e)" << std::endl);
e.failed = fKeyboardEvent;
return e.accept(*this);
}
Event* Object::handle(pTimedEvent &e)
{
assert(std::cerr << "Object::handle(pTimedEvent &e)" << std::endl);
e.failed = fTimedEvent;
return e.accept(*this);
}
Event* Object::handle(pRendererEvent &e)
{
assert(std::cerr << "Object::handle(pRendererEvent &e)" << std::endl);
e.failed = fRendererEvent;
return e.accept(*this);
}
Event* Object::handle(pDrawEvent &e)
{
assert(std::cerr << "Object::handle(pDrawEvent &e)" << std::endl);
e.failed = fDrawEvent;
return e.accept(*this);
}
Event* Object::handle(pUpdateEvent &e)
{
assert(std::cerr << "Object::handle(pUpdateEvent &e)" << std::endl);
e.failed = fUpdateEvent;
return e.accept(*this);
}
Event* Object::handle(pScreenResizeEvent &e)
{
assert(std::cerr << "Object::handle(pScreenResizeEvent &e)" << std::endl);
e.failed = fScreenResizeEvent;
return e.accept(*this);
}