00001
00002
00003
00004
00005
00006 #ifndef __OSL_PUP_TONETWORK4_H
00007 #define __OSL_PUP_TONETWORK4_H
00008
00009 #include "pup.h"
00010
00011 class PUP_toNetwork4_sizer : public PUP::er {
00012 size_t nBytes;
00013 virtual void bytes(void *p,size_t n,size_t itemSize,PUP::dataType t);
00014 public:
00015 PUP_toNetwork4_sizer(void) :PUP::er(IS_SIZING) {nBytes=0;}
00016 size_t size(void) const {return nBytes;}
00017
00018 };
00019
00020 class PUP_toNetwork4_pack : public PUP::er {
00021 unsigned char *buf,*start;
00022
00023 inline void w(float f) {
00024
00025
00026
00027 union { float f; CMK_TYPEDEF_INT4 i; } uaw;
00028 uaw.f=f;
00029 w(uaw.i);
00030 }
00031 inline void w(int i) {
00032
00033 *buf++=(unsigned char)(i>>24);
00034 *buf++=(unsigned char)(i>>16);
00035 *buf++=(unsigned char)(i>>8);
00036 *buf++=(unsigned char)(i>>0);
00037 }
00038
00039 virtual void bytes(void *p,size_t n,size_t itemSize,PUP::dataType t);
00040 public:
00041 PUP_toNetwork4_pack(void *dest) :PUP::er(IS_PACKING) {
00042 start=buf=(unsigned char *)dest;
00043 }
00044 PUP_toNetwork4_pack(const PUP_toNetwork4_pack &p);
00045 void operator=(const PUP_toNetwork4_pack &p);
00046 inline size_t size(void) const {return buf-start;}
00047 };
00048
00049 class PUP_toNetwork4_unpack : public PUP::er {
00050 const unsigned char *buf,*start;
00051
00052 inline float read_float(void) {
00053
00054
00055
00056 union { float f; CMK_TYPEDEF_INT4 i; } uaw;
00057 uaw.i=read_int();
00058 return uaw.f;
00059 }
00060 inline int read_int(void) {
00061
00062 int ret=(buf[0]<<24)|(buf[1]<<16)|(buf[2]<<8)|(buf[3]);
00063 buf+=4;
00064 return ret;
00065 }
00066
00067 virtual void bytes(void *p,size_t n,size_t itemSize,PUP::dataType t);
00068 public:
00069 PUP_toNetwork4_unpack(const void *src) :PUP::er(IS_UNPACKING) {
00070 start=buf=(const unsigned char *)src;
00071 }
00072 PUP_toNetwork4_unpack(const PUP_toNetwork4_unpack &p);
00073 void operator=(const PUP_toNetwork4_unpack &p);
00074 inline size_t size(void) const {return buf-start;}
00075 };
00076
00077 #endif
00078