Homepage Demos Overview Downloads Tutorials Reference
Credits

TextMsgEvent.h

Go to the documentation of this file.
00001 //-*-c++-*-
00002 #ifndef INCLUDED_TextMsgEvent_h
00003 #define INCLUDED_TextMsgEvent_h
00004 
00005 #include "EventBase.h"
00006 
00007 //! Extends EventBase to also include actual message text
00008 class TextMsgEvent : public EventBase {
00009  public:
00010   //! Constructor
00011   TextMsgEvent() : EventBase(EventBase::textmsgEGID,(unsigned int)-1, EventBase::statusETID,0),_text(""),_token(0) {  }
00012 
00013   //! Constructor, pass a text msg
00014   TextMsgEvent(const std::string& text) : EventBase(EventBase::textmsgEGID,(unsigned int)-1, EventBase::statusETID,0),_text(text),_token(0) { }
00015   
00016   std::string getText() const { return _text; } //!< returns the text
00017   TextMsgEvent& setText(const std::string& text) { _text=text; return *this; } //!< sets the text
00018   
00019   int getToken() const { return _token; } //!< returns the token
00020   TextMsgEvent& setToken(int token) { _token=token; return *this;} //!< sets the token
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; //!< the unmodified arguments passed to the command
00060   int _token;      //!< for future expansion, to support centralized parsing
00061 };
00062 
00063 /*! @file
00064  * @brief Defines TextMsgEvent, which extends EventBase to also include actual message text
00065  * @author ejt (Creator)
00066  *
00067  * $Author: ejt $
00068  * $Name: tekkotsu-2_1 $
00069  * $Revision: 1.9 $
00070  * $State: Exp $
00071  * $Date: 2003/12/05 20:26:42 $
00072  */
00073 
00074 #endif

Tekkotsu v2.1
Generated Tue Mar 16 23:19:15 2004 by Doxygen 1.3.5