Show keventhandlermanager.h syntax highlighted
/*
Copyright (C) 2003, 2004 by Luca Cappa
Written by Luca Cappa groton@users.sourceforge.net
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __KEVENTHANDLERMANAGER_H__
#define __KEVENTHANDLERMANAGER_H__
#include "csutil/scf.h"
#include "csutil/ref.h"
#include "iutil/eventh.h"
struct iEventHandler;
struct iEvent;
//-------------------------------------------------------------------------------------
//This structure holds the relevant datas intrinsic of an event handler.
struct KEventHandler
{
// The event handler itself.
csRef<iEventHandler> m_eH;
//The triggers that activate the event handler.
unsigned int m_trigger;
//The priority the event handler has.
unsigned int m_priority;
//
//Useful for sorting.
friend int operator< (KEventHandler const& p_ev1,
KEventHandler const& p_ev2)
{
if (p_ev1.m_priority > p_ev2.m_priority)
return 1;//ok
else
return -1;//swap
}
};
//-------------------------------------------------------------------------------------
struct KEventHandlerManager : public iEventHandler
{
private:
csArray<KEventHandler> m_eventHandlers;
public:
SCF_DECLARE_IBASE;
KEventHandlerManager ();
virtual ~KEventHandlerManager ();
virtual bool HandleEvent (iEvent& p_e);
bool AddEventHandler (iEventHandler*, unsigned int, unsigned int);
bool RemoveAllEventHandlers ();
};
#endif // __KEVENTHANDLERMANAGER_H__
See more files for this project here