Blender V2.61 - r43446

SCA_EventManager.h

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