Blender  V2.59
SCA_EventManager.h
Go to the documentation of this file.
00001 /*
00002  * $Id: SCA_EventManager.h 35063 2011-02-22 10:33:14Z jesterking $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028  */
00029 
00034 #ifndef __KX_EVENTMANAGER
00035 #define __KX_EVENTMANAGER
00036 
00037 #include <vector>
00038 #include <set>
00039 #include <algorithm>
00040 
00041 #include "SG_DList.h"
00042 
00043 class SCA_EventManager
00044 {
00045 protected:
00046         class SCA_LogicManager* m_logicmgr; /* all event manager subclasses use this (other then TimeEventManager) */
00047 
00048         // use a set to speed-up insertion/removal
00049         //std::set <class SCA_ISensor*>                         m_sensors;
00050         SG_DList                m_sensors;
00051 
00052 public:
00053         enum EVENT_MANAGER_TYPE {
00054                 KEYBOARD_EVENTMGR = 0,
00055                 MOUSE_EVENTMGR,
00056                 ALWAYS_EVENTMGR, 
00057                 TOUCH_EVENTMGR, 
00058                 PROPERTY_EVENTMGR,
00059                 TIME_EVENTMGR,
00060                 RANDOM_EVENTMGR,
00061                 RAY_EVENTMGR,
00062                 NETWORK_EVENTMGR,
00063                 JOY_EVENTMGR,
00064                 ACTUATOR_EVENTMGR,
00065                 BASIC_EVENTMGR
00066         };
00067 
00068         SCA_EventManager(SCA_LogicManager* logicmgr, EVENT_MANAGER_TYPE mgrtype);
00069         virtual ~SCA_EventManager();
00070         
00071         virtual void    RemoveSensor(class SCA_ISensor* sensor);
00072         virtual void    NextFrame(double curtime, double fixedtime);
00073         virtual void    NextFrame();
00074         virtual void    UpdateFrame();
00075         virtual void    EndFrame();
00076         virtual void    RegisterSensor(class SCA_ISensor* sensor);
00077         int             GetType();
00078         //SG_DList &GetSensors() { return m_sensors; }
00079 
00080 
00081         void                    Replace_LogicManager(SCA_LogicManager* logicmgr) { m_logicmgr= logicmgr; }
00082         virtual void    Replace_PhysicsScene(class PHY_IPhysicsEnvironment* env) { } /* only for event managers that use one */
00083 
00084 protected:
00085         EVENT_MANAGER_TYPE              m_mgrtype;
00086 
00087 
00088 #ifdef WITH_CXX_GUARDEDALLOC
00089 public:
00090         void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:SCA_EventManager"); }
00091         void operator delete( void *mem ) { MEM_freeN(mem); }
00092 #endif
00093 };
00094 
00095 #endif
00096