00001 #ifndef INCLUDED_LocomotionEvent_h_
00002 #define INCLUDED_LocomotionEvent_h_
00003
00004 #include "EventBase.h"
00005
00006
00007
00008
00009
00010
00011
00012
00013 class LocomotionEvent : public EventBase {
00014 public:
00015
00016
00017
00018
00019 LocomotionEvent() : EventBase(),x(0),y(0),a(0) {}
00020 LocomotionEvent(EventGeneratorID_t gid, unsigned int sid, EventTypeID_t tid, unsigned int dur=0) : EventBase(gid,sid,tid,dur),x(0),y(0),a(0) {}
00021 LocomotionEvent(EventGeneratorID_t gid, unsigned int sid, EventTypeID_t tid, unsigned int dur, const std::string& n, float mag) : EventBase(gid,sid,tid,dur,n,mag),x(0),y(0),a(0) {}
00022
00023
00024
00025 LocomotionEvent& setXYA(float X, float Y, float A) {
00026 x=X;
00027 y=Y;
00028 a=A;
00029 return *this;
00030 }
00031
00032 virtual unsigned int getBinSize() const {
00033 unsigned int used=EventBase::getBinSize();
00034 used+=creatorSize("EventBase::LocomotionEvent");
00035 used+=sizeof(x);
00036 used+=sizeof(y);
00037 used+=sizeof(a);
00038 return used;
00039 }
00040
00041 virtual unsigned int LoadBuffer(const char buf[], unsigned int len) {
00042 unsigned int origlen=len;
00043 unsigned int used;
00044 if(0==(used=EventBase::LoadBuffer(buf,len))) return 0;
00045 len-=used; buf+=used;
00046 if(0==(used=checkCreator("EventBase::LocomotionEvent",buf,len,true))) return 0;
00047 len-=used; buf+=used;
00048 if(0==(used=decode(x,buf,len))) return 0;
00049 len-=used; buf+=used;
00050 if(0==(used=decode(y,buf,len))) return 0;
00051 len-=used; buf+=used;
00052 if(0==(used=decode(a,buf,len))) return 0;
00053 len-=used; buf+=used;
00054 return origlen-len;
00055 }
00056
00057 virtual unsigned int SaveBuffer(char buf[], unsigned int len) const {
00058 unsigned int origlen=len;
00059 unsigned int used;
00060 if(0==(used=EventBase::SaveBuffer(buf,len))) return 0;
00061 len-=used; buf+=used;
00062 if(0==(used=saveCreator("EventBase::LocomotionEvent",buf,len))) return 0;
00063 len-=used; buf+=used;
00064 if(0==(used=encode(x,buf,len))) return 0;
00065 len-=used; buf+=used;
00066 if(0==(used=encode(y,buf,len))) return 0;
00067 len-=used; buf+=used;
00068 if(0==(used=encode(a,buf,len))) return 0;
00069 len-=used; buf+=used;
00070 return origlen-len;
00071 }
00072
00073 float x;
00074 float y;
00075 float a;
00076 };
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 #endif