00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef ARBASEPACKET_H
00028 #define ARBASEPACKET_H
00029
00030
00031 #include <string>
00032 #include "ariaTypedefs.h"
00033
00035
00069 class ArBasePacket
00070 {
00071 public:
00072
00074 ArBasePacket(ArTypes::UByte2 bufferSize = 0,
00075 ArTypes::UByte2 headerLength = 0,
00076 char * buf = NULL,
00077 ArTypes::UByte2 footerLength = 0);
00078
00080 virtual ~ArBasePacket();
00081
00083 virtual void empty(void);
00084
00086 virtual void finalizePacket(void) {}
00087
00089 virtual void log(void);
00091 virtual void printHex(void);
00092
00093
00094
00095
00097 virtual void byteToBuf(ArTypes::Byte val);
00099 virtual void byte2ToBuf(ArTypes::Byte2 val);
00101 virtual void byte4ToBuf(ArTypes::Byte4 val);
00102
00104 virtual void uByteToBuf(ArTypes::UByte val);
00106 virtual void uByte2ToBuf(ArTypes::UByte2 val);
00108 virtual void uByte4ToBuf(ArTypes::UByte4 val);
00109
00111 virtual void strToBuf(const char *str);
00113 virtual void strNToBuf(const char *str, int length);
00115 virtual void strToBufPadded(const char *str, int length);
00117 virtual void dataToBuf(const char *data, int length);
00118
00119
00120
00122 virtual ArTypes::Byte bufToByte(void);
00124 virtual ArTypes::Byte2 bufToByte2(void);
00126 virtual ArTypes::Byte4 bufToByte4(void);
00127
00129 virtual ArTypes::UByte bufToUByte(void);
00131 virtual ArTypes::UByte2 bufToUByte2(void);
00133 virtual ArTypes::UByte4 bufToUByte4(void);
00134
00136 virtual void bufToStr(char *buf, int len);
00138 virtual void bufToData(char * data, int length);
00139
00141 virtual void resetRead(void);
00142
00143
00144
00146 virtual ArTypes::UByte2 getLength(void) { return myLength; }
00148 virtual ArTypes::UByte2 getDataLength(void) { return myLength - myHeaderLength - myFooterLength; }
00149
00151 virtual ArTypes::UByte2 getReadLength(void) { return myReadLength; }
00153 virtual ArTypes::UByte2 getDataReadLength(void) { return myReadLength - myHeaderLength; }
00155 virtual ArTypes::UByte2 getHeaderLength(void)
00156 { return myHeaderLength; }
00158 virtual ArTypes::UByte2 getFooterLength(void)
00159 { return myFooterLength; }
00160
00162 virtual ArTypes::UByte2 getMaxLength(void) { return myMaxLength; }
00163
00165 virtual const char * getBuf(void);
00166
00168 virtual void setBuf(char *buf, ArTypes::UByte2 bufferSize);
00170 virtual void ArBasePacket::setMaxLength(ArTypes::UByte2 bufferSize);
00172 virtual bool setLength(ArTypes::UByte2 length);
00174 virtual void setReadLength(ArTypes::UByte2 readLength);
00176 virtual bool setHeaderLength(ArTypes::UByte2 length);
00178 virtual void duplicatePacket(ArBasePacket *packet);
00179 protected:
00180
00181 bool isNextGood(int bytes);
00182
00183
00184 ArTypes::UByte2 myHeaderLength;
00185 ArTypes::UByte2 myFooterLength;
00186 ArTypes::UByte2 myMaxLength;
00187
00188 ArTypes::UByte2 myReadLength;
00189 bool myOwnMyBuf;
00190
00191
00192 char *myBuf;
00193 ArTypes::UByte2 myLength;
00194 };
00195
00196
00197 #endif // ARPACKET_H