00001
00002 #ifndef INCLUDED_TextMsgEvent_h
00003 #define INCLUDED_TextMsgEvent_h
00004
00005 #include "EventBase.h"
00006
00007
00008 class TextMsgEvent : public EventBase {
00009 public:
00010
00011 TextMsgEvent() : EventBase(EventBase::textmsgEGID,(unsigned int)-1, EventBase::activateETID,0),_text(""),_token(0) { }
00012
00013
00014 TextMsgEvent(const std::string& text) : EventBase(EventBase::textmsgEGID,(unsigned int)-1, EventBase::activateETID,0),_text(text),_token(0) { }
00015
00016 std::string getText() const { return _text; }
00017 TextMsgEvent& setText(const std::string& text) { _text=text; return *this; }
00018
00019 int getToken() const { return _token; }
00020 TextMsgEvent& setToken(int token) { _token=token; return *this;}
00021
00022 virtual unsigned int getBinSize() const {
00023 unsigned int used=EventBase::getBinSize();
00024 used+=creatorSize("EventBase::TextMsgEvent");
00025 used+=_text.size()+stringpad;
00026 used+=sizeof(_token);
00027 return used;
00028 }
00029
00030 virtual unsigned int LoadBuffer(const char buf[], unsigned int len) {
00031 unsigned int origlen=len;
00032 unsigned int used;
00033 if(0==(used=EventBase::LoadBuffer(buf,len))) return 0;
00034 len-=used; buf+=used;
00035 if(0==(used=checkCreator("EventBase::TextMsgEvent",buf,len,true))) return 0;
00036 len-=used; buf+=used;
00037 if(0==(used=decode(_text,buf,len))) return 0;
00038 len-=used; buf+=used;
00039 if(0==(used=decode(_token,buf,len))) return 0;
00040 len-=used; buf+=used;
00041 return origlen-len;
00042 }
00043
00044 virtual unsigned int SaveBuffer(char buf[], unsigned int len) const {
00045 unsigned int origlen=len;
00046 unsigned int used;
00047 if(0==(used=EventBase::SaveBuffer(buf,len))) return 0;
00048 len-=used; buf+=used;
00049 if(0==(used=saveCreator("EventBase::TextMsgEvent",buf,len))) return 0;
00050 len-=used; buf+=used;
00051 if(0==(used=encode(_text,buf,len))) return 0;
00052 len-=used; buf+=used;
00053 if(0==(used=encode(_token,buf,len))) return 0;
00054 len-=used; buf+=used;
00055 return origlen-len;
00056 }
00057
00058 protected:
00059 std::string _text;
00060 int _token;
00061 };
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074 #endif