Tekkotsu Homepage
Demos
Overview
Downloads
Dev. Resources
Reference
Credits

KoduGiveEvent.cc

Go to the documentation of this file.
00001 #include "Events/Kodu/KoduGiveEvent.h"
00002 
00003 const char* KoduGiveEvent::classID = "KoduEventBase::KoduGiveEvent";
00004 
00005 std::string KoduGiveEvent::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) << "Give";
00010   return logdata.str();
00011 }
00012 
00013 unsigned int KoduGiveEvent::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(KoduGiveEvent::classID);
00020   return used;
00021 }
00022 
00023 unsigned int KoduGiveEvent::saveBinaryBuffer(char buf[], unsigned int len) const {
00024   unsigned int origlen = len;
00025   if (!checkInc(KoduEventBase::saveBinaryBuffer(buf,len),buf,len)) return 0;
00026   if (!saveCreatorInc(KoduGiveEvent::classID,buf,len)) return 0;
00027     if (!encodeInc(_turn,buf,len)) return 0;
00028     if (!encodeInc(_objType,buf,len)) return 0;
00029   return origlen-len;
00030 }
00031 
00032 unsigned int KoduGiveEvent::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(KoduGiveEvent::classID,buf,len,true)) return 0;
00036     if (!decodeInc(_turn,buf,len)) return 0;
00037     if (!decodeInc(_objType,buf,len)) return 0;
00038   return origlen-len;
00039 }
00040 
00041 void KoduGiveEvent::setTurnAndObject(float turn, std::string objType) {
00042     _turn = turn;
00043     _objType = objType;
00044 }
00045 
00046 float KoduGiveEvent::getTurn() const {
00047     return _turn;
00048 }
00049 
00050 std::string KoduGiveEvent::getObjType() const {
00051     return _objType;
00052 }
00053 
00054 /*! @file
00055  *
00056  * @brief Kodu gives something to another robot
00057  *
00058  * @author afranchu
00059  * @author medee
00060  */

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