ec_event.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef FIFE_EVENTCHANNEL_EVENT_H
00028 #define FIFE_EVENTCHANNEL_EVENT_H
00029
00030
00031
00032 #include <string>
00033 #include <sstream>
00034
00035
00036
00037 #include <SDL.h>
00038
00039
00040
00041
00042
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 }
00120
00121 #endif