Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

KoduSayEvent.cc

Go to the documentation of this file.
00001 #include "Events/Kodu/KoduSayEvent.h"
00002 
00003 const char* KoduSayEvent::classID = "KoduEventBase::KoduSayEvent";
00004 
00005 std::string KoduSayEvent::getDescription(bool showTypeSpecific, unsigned int verbosity) const {
00006   if (!showTypeSpecific)
00007     return KoduEventBase::getDescription(showTypeSpecific,verbosity);
00008   std::ostringstream logdata;
00009   logdata << KoduEventBase::getDescription(showTypeSpecific,verbosity) << '\t' << _phrase;
00010   return logdata.str();
00011 }
00012 
00013 unsigned int KoduSayEvent::getBinSize() const {
00014   unsigned int used = KoduEventBase::getBinSize();
00015   // If using XML, the XMLLoadSave::getBinSize (called by EventBase::getBinSize) is all we need.
00016   if (saveFormat==XML)
00017     return used;
00018   // Otherwise need to add our own fields.
00019   used += creatorSize(KoduSayEvent::classID);
00020   used += getSerializedSize(_phrase);
00021   return used;
00022 }
00023 
00024 unsigned int KoduSayEvent::saveBinaryBuffer(char buf[], unsigned int len) const {
00025   unsigned int origlen = len;
00026   if (!checkInc(KoduEventBase::saveBinaryBuffer(buf,len),buf,len)) return 0;
00027   if (!saveCreatorInc(KoduSayEvent::classID,buf,len)) return 0;
00028   if (!encodeInc(_phrase,buf,len)) return 0;
00029   return origlen-len;
00030 }
00031 
00032 unsigned int KoduSayEvent::loadBinaryBuffer(const char buf[], unsigned int len) {
00033   unsigned int origlen = len;
00034   if (!checkInc(KoduEventBase::loadBinaryBuffer(buf,len),buf,len)) return 0;
00035   if (!checkCreatorInc(KoduSayEvent::classID,buf,len,true)) return 0;
00036   if (!decodeInc(_phrase,buf,len)) return 0;
00037   return origlen-len; 
00038 }
00039 
00040 std::string KoduSayEvent::getPhrase() const {
00041   return _phrase;
00042 }
00043 
00044 /*! @file
00045  * 
00046  * @brief Kodu says something in the world
00047  *
00048  * @author afranchu
00049  * @author medee
00050  */

Tekkotsu v5.1CVS
Generated Mon May 9 04:58:43 2016 by Doxygen 1.6.3