Main Page   Class Hierarchy   Compound List   File List   Compound Members  

CAVERNnet_datapack_c.hxx

00001 /******************************************************************
00002  * CAVERNsoft
00003  * Copyright (C) 1994-2000 Electronic Visualization Laboratory,
00004  * all rights reserved
00005  * By Jason Leigh, Yong-joo Cho, Naveen Krishnaprasad, Chris Scharver,
00006  * Stuart Bailey, Atul Nayak, Shalini Venkataraman
00007  * University of Illinois at Chicago
00008  * 
00009  * This publication and its text and code may not be copied for commercial 
00010  * use without the express written permission of the University of Illinois
00011  * at Chicago
00012  * The contributors disclaim any representation of warranty: use this
00013  * code at your own risk.
00014  * Direct questions, comments etc to cavern@evl.uic.edu
00015  ******************************************************************/
00016 #ifndef _CAVERN_DATAPACK_C_H
00017 #define _CAVERN_DATAPACK_C_H
00018 
00019 #ifdef CAVERN_USE_GLOBUS_DATA_PACK
00020 #include "globus_dc.h"
00021 #include "globus_config.h"
00022 #else
00023 #define FLOAT_SIZE 4
00024 #define DOUBLE_SIZE 8
00025 #define INT_SIZE 4
00026 #if (_MIPS_SZLONG==64)
00027 #define LONG_SIZE 8
00028 #else
00029 #define LONG_SIZE 4
00030 #endif
00031 #define INT32_SIZE 4
00032 #define INT64_SIZE 8
00033 #define CHAR_SIZE 1
00034 #endif
00035 
00036 typedef int int32;
00037 
00038 #ifdef WIN32 
00039 typedef __int64 int64;
00040 #elif (_MIPS_SZLONG==64)
00041 typedef long int64;
00042 #else 
00043 typedef long long int64;
00044 #endif
00045 
00092 class CAVERNnet_datapack_c {
00093 
00094 
00095 public:
00096         CAVERNnet_datapack_c() {
00097                 running = 0; size = 0;
00098                 start = 0;
00099         }
00100 
00101         
00103 
00104 
00105         static const int OK/* = 0*/;
00107         static const int FAILED/* = -1*/;
00109 
00119         void initPack(char *buffer, int buffersize);
00120 
00130         void initUnpack(char *buffer, int buffersize);
00131 
00140         char *getBuffer() { return (char *)start;}
00141 
00149         int getBufferMaxSize() { return size;}
00150 
00157         int getBufferFilledSize() {return running - start;}
00158 
00168         int packFloat(float val);
00169 
00179         int packInt(int val) ;
00180 
00191         int packInt32(int32 val);
00192 
00203         int packLong(long val) ;
00204 
00214         int packInt64(int64 val);
00215 
00225         int packDouble(double val);
00226 
00227 
00237         int packChar(char val) ;
00238 
00250         int pack(char* val, int sz) ;
00251         
00263         int packFloatArray(float* val, int sz) ;
00264 
00276         int packDoubleArray(double* val, int sz) ;
00277 
00289         int packIntArray(int* val, int sz) ;
00290 
00302         int packInt32Array(int32* val, int sz) ;
00303    
00315         int packInt64Array(int64* val, int sz) ;
00316 
00328         int packLongArray(long* val, int sz) ;
00329     
00339         int unpackFloat(float *Answer) ;
00340 
00350         int unpackInt(int *Answer) ;
00351 
00361         int unpackInt32(int32 *Answer) ;
00362 
00372         int unpackLong(long *Answer) ;
00373 
00383         int unpackInt64(int64 *Answer) ;
00384 
00394         int unpackDouble(double *Answer)  ;
00395 
00405         int unpackChar(char *Answer) ;
00406 
00416         int unpack(char *Answer, int sz) ;
00417 
00430     int unpackFloatArray(float* Answer, int sz);
00431    
00444     int unpackDoubleArray(double* Answer, int sz);
00445    
00458     int unpackIntArray(int* Answer, int sz);
00459    
00472     int unpackInt32Array(int32* Answer, int sz);
00473 
00486     int unpackInt64Array(int64* Answer, int sz);
00487    
00500     int unpackLongArray(long* Answer, int sz);
00501     
00510         int checkspace(unsigned int incoming_size);
00511 
00518 #ifdef CAVERN_USE_GLOBUS_DATA_PACK
00519         static int sizeof_float(unsigned int cnt=1){return 1+nexus_dc_sizeof_float(cnt);};
00520 #else
00521         static int sizeof_float(unsigned int cnt=1){return FLOAT_SIZE * cnt;};
00522 #endif
00523 
00529 #ifdef CAVERN_USE_GLOBUS_DATA_PACK
00530         static int sizeof_int(unsigned int cnt=1){return 1+nexus_dc_sizeof_int(cnt);};
00531 #else
00532         static int sizeof_int(unsigned int cnt=1){return INT_SIZE * cnt;};
00533 #endif
00534 
00541 #ifndef CAVERN_USE_GLOBUS_DATA_PACK
00542         static int sizeof_int64(unsigned int cnt=1){return INT64_SIZE * cnt;};
00543 #endif
00544 
00551 #ifndef CAVERN_USE_GLOBUS_DATA_PACK
00552         static int sizeof_int32(unsigned int cnt=1){return INT32_SIZE * cnt;};
00553 #endif
00554         
00561 #ifdef CAVERN_USE_GLOBUS_DATA_PACK
00562         static int sizeof_long(unsigned int cnt=1){return 1+nexus_dc_sizeof_long(cnt);};
00563 #else
00564         static int sizeof_long(unsigned int cnt=1){return LONG_SIZE * cnt;};
00565 #endif
00566 
00573 #ifdef CAVERN_USE_GLOBUS_DATA_PACK
00574         static int sizeof_char(unsigned int cnt=1){return 1+nexus_dc_sizeof_char(cnt);};
00575 #else
00576         static int sizeof_char(unsigned int cnt=1){return CHAR_SIZE * cnt;};
00577 #endif
00578 
00585 #ifdef CAVERN_USE_GLOBUS_DATA_PACK
00586         static int sizeof_double(unsigned int cnt=1){return 1+nexus_dc_sizeof_double(cnt);};
00587 #else
00588         static int sizeof_double(unsigned int cnt=1){return DOUBLE_SIZE * cnt;};
00589 #endif
00590 
00591 
00592 
00593 
00594 private:
00595         unsigned long size;
00596 #ifdef CAVERN_USE_GLOBUS_DATA_PACK
00597         nexus_byte_t *running;
00598         nexus_byte_t *start;
00599         int sender_format;
00600 #else
00601         unsigned char *running;
00602         unsigned char *start;
00603 #endif
00604 
00605 };
00606 
00607 #endif

Generated at Mon Jul 2 14:24:42 2001 for CAVERNsoft by doxygen1.2.8-20010617 written by Dimitri van Heesch, © 1997-2001