C:/Users/Mike/Documents/Visual Studio Projects/GameEngine/include/Event.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 Copyright (C) 2006 Michael Harnetty
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00018 -----------------------------------------------------------------------------
00019 */
00020 
00021 #ifndef IEVENT_H
00022 #define IEVENT_H
00023 
00024 #include "GameEnginePrerequisites.h"
00025 #include "EventType.h"
00026 
00027 namespace GameEngine{
00028 
00031         class ENGINE_DECL IEventData {
00032                 public:
00033                         virtual ~IEventData() {}
00034         };
00035 
00036         typedef boost::shared_ptr<IEventData> IEventDataPtr;
00037 
00038 
00041         class ENGINE_DECL Event {
00042         public:
00043                 Event(EventType eventType, double eventTime = 0, IEventDataPtr userData = IEventDataPtr((IEventData*)NULL) )
00044                         :       mEventType(eventType),
00045                                 mEventTime(eventTime),
00046                                 mUserData(userData)
00047                 {
00048 
00049                 }
00050 
00051                 virtual ~Event() {}
00052 
00053                 const EventType& getEventType() const { return mEventType; }
00054                 double getEventTime() const { return mEventTime; }
00055                 IEventDataPtr getData() const { return mUserData; }
00056 
00057                 void setId(const std::string& id) { mId = id; }
00058                 const std::string& getId() const { return mId; }
00059 
00060                 template<typename T>
00061                         T* getDataPtr() const { return reinterpret_cast<T*>( mUserData.get() ); }
00062 
00063         private:
00064                 EventType mEventType;
00065                 double mEventTime;
00066                 IEventDataPtr mUserData;
00067                 std::string mId;
00068         };
00069 
00070         typedef boost::shared_ptr<Event> EventPtr;
00071 }
00072 
00073 #endif

Generated on Thu Apr 19 09:47:02 2007 for GameEngine by  doxygen 1.5.2