FIFE
2008.0
|
00001 /*************************************************************************** 00002 * Copyright (C) 2005-2008 by the FIFE team * 00003 * http://www.fifengine.de * 00004 * This file is part of FIFE. * 00005 * * 00006 * FIFE is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Lesser General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2.1 of the License, or (at your option) any later version. * 00010 * * 00011 * This library 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 GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library; if not, write to the * 00018 * Free Software Foundation, Inc., * 00019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 00020 ***************************************************************************/ 00021 /*************************************************************************** 00022 * Note! FIFE event channel borrows heavily from ideas pf Guichan library * 00023 * version 0.6 * 00024 ***************************************************************************/ 00025 00026 00027 #ifndef FIFE_EVENTCHANNEL_EVENT_H 00028 #define FIFE_EVENTCHANNEL_EVENT_H 00029 00030 // Standard C++ library includes 00031 // 00032 #include <string> 00033 #include <sstream> 00034 00035 // 3rd party library includes 00036 // 00037 #include <SDL.h> 00038 00039 // FIFE includes 00040 // These includes are split up in two parts, separated by one empty line 00041 // First block: files included from the FIFE root src directory 00042 // Second block: files included from the same folder 00043 // 00044 #include "eventchannel/source/ec_ieventsource.h" 00045 00046 namespace FIFE { 00049 class Event { 00050 public: 00053 Event(): 00054 m_isconsumed(false), 00055 m_eventsource(NULL), 00056 m_timestamp(SDL_GetTicks()) {} 00057 00060 virtual ~Event() {} 00061 00064 virtual void consume() { m_isconsumed = true; } 00065 00069 virtual bool isConsumed() const { return m_isconsumed; } 00070 00073 virtual IEventSource* getSource() const { return m_eventsource; } 00074 00077 virtual void setSource(IEventSource* source) { m_eventsource = source; } 00078 00081 virtual int getTimeStamp() const { return m_timestamp; } 00082 00085 virtual void setTimeStamp(int timestamp ) { m_timestamp = timestamp; } 00086 00089 virtual const std::string& getName() const { 00090 const static std::string eventName("Event"); 00091 return eventName; 00092 } 00093 00096 virtual std::string getAttrStr() const { 00097 std::stringstream ss; 00098 ss << "consumed = " << m_isconsumed << ", "; 00099 ss << "src = " << m_eventsource << ", "; 00100 ss << "timestamp = " << m_timestamp; 00101 return ss.str(); 00102 } 00103 00106 virtual std::string getDebugString() const { 00107 std::stringstream ss; 00108 ss << getName() << std::endl; 00109 ss << getAttrStr() << std::endl; 00110 return ss.str(); 00111 } 00112 00113 private: 00114 bool m_isconsumed; 00115 IEventSource* m_eventsource; 00116 int m_timestamp; 00117 }; 00118 00119 } //FIFE 00120 00121 #endif