MStream.h

Go to the documentation of this file.
00001 
00007 #ifndef MSTREAM_H
00008 #define MSTREAM_H
00009 
00010 #include "Vector.h"
00011 #include <string.h>
00012 
00013 class StreamMessage;
00014 class Communicate;
00015 
00016 class MIStream {
00017   private:
00018     int PE, tag;
00019     StreamMessage *msg;
00020     size_t currentPos;
00021     int currentIndex;
00022     StreamMessage *early;
00023     Communicate *cobj;
00024     unsigned int checksum;
00025     MIStream *Get(char *buf, size_t len);  // get len bytes from message to buf
00026   public:
00027     MIStream(Communicate *c, int pe, int tag);
00028     ~MIStream();
00029     MIStream *get(char &data) { 
00030       return Get(&data,sizeof(char)); 
00031     }
00032     MIStream *get(unsigned char &data) { 
00033       return Get((char *)&data,sizeof(unsigned char)); 
00034     }
00035     MIStream *get(short &data) { 
00036       return Get((char *)&data, sizeof(short)); 
00037     }
00038     MIStream *get(unsigned short &data) { 
00039       return Get((char *)&data, sizeof(unsigned short)); 
00040     }
00041     MIStream *get(int &data) { 
00042       return Get((char *)&data, sizeof(int)); 
00043     }
00044     MIStream *get(unsigned int &data) { 
00045       return Get((char *)&data, sizeof(unsigned int)); 
00046     }
00047     MIStream *get(long &data) { 
00048       return Get((char *)&data, sizeof(long)); 
00049     }
00050     MIStream *get(unsigned long &data) { 
00051       return Get((char *)&data, sizeof(unsigned long)); 
00052     }
00053     MIStream *get(float &data) { 
00054       return Get((char *)&data, sizeof(float)); 
00055     }
00056     MIStream *get(double &data) { 
00057       return Get((char *)&data, sizeof(double)); 
00058     }
00059     MIStream *get(size_t len, char *data) { 
00060       return Get(data,len*sizeof(char)); 
00061     }
00062     MIStream *get(size_t len, unsigned char *data) { 
00063       return Get((char *)data,len*sizeof(unsigned char)); 
00064     }
00065     MIStream *get(size_t len, short *data) { 
00066       return Get((char *)data,len*sizeof(short)); 
00067     }
00068     MIStream *get(size_t len, unsigned short *data) { 
00069       return Get((char *)data,len*sizeof(unsigned short)); 
00070     }
00071     MIStream *get(size_t len, int *data) { 
00072       return Get((char *)data,len*sizeof(int)); 
00073     }
00074     MIStream *get(size_t len, unsigned int *data) { 
00075       return Get((char *)data,len*sizeof(unsigned int)); 
00076     }
00077     MIStream *get(size_t len, long *data) { 
00078       return Get((char *)data,len*sizeof(long)); 
00079     }
00080     MIStream *get(size_t len, unsigned long *data) { 
00081       return Get((char *)data,len*sizeof(unsigned long)); 
00082     }
00083     MIStream *get(size_t len, float *data) { 
00084       return Get((char *)data,len*sizeof(float)); 
00085     }
00086     MIStream *get(size_t len, double *data) { 
00087       return Get((char *)data,len*sizeof(double)); 
00088     }
00089     MIStream *get(size_t len, Vector *data) {
00090       return Get((char *)data, len*sizeof(Vector));
00091     }
00092     MIStream *get(Vector *data) {
00093       return Get((char *)data, sizeof(Vector));
00094     }
00095 };
00096 
00097 class MOStream {
00098   private:
00099     int PE, tag;
00100     unsigned int bufLen;
00101     StreamMessage *msgBuf;
00102     Communicate *cobj;
00103     MOStream *Put(char *buf, size_t len); // put len bytes from buf into message
00104   public:
00105     MOStream(Communicate *c, int pe, int tag, size_t bufSize);
00106     ~MOStream();
00107     void end(void);
00108     MOStream *put(char data) { 
00109       return Put(&data,sizeof(char)); 
00110     }
00111     MOStream *put(unsigned char data) { 
00112       return Put((char *)&data,sizeof(unsigned char)); 
00113     }
00114     MOStream *put(short data) { 
00115       return Put((char *)&data, sizeof(short)); 
00116     }
00117     MOStream *put(unsigned short data) { 
00118       return Put((char *)&data, sizeof(unsigned short)); 
00119     }
00120     MOStream *put(int data) { 
00121       return Put((char *)&data, sizeof(int)); 
00122     }
00123     MOStream *put(unsigned int data) { 
00124       return Put((char *)&data, sizeof(unsigned int)); 
00125     }
00126     MOStream *put(long data) { 
00127       return Put((char *)&data, sizeof(long)); 
00128     }
00129     MOStream *put(unsigned long data) { 
00130       return Put((char *)&data, sizeof(unsigned long)); 
00131     }
00132     MOStream *put(float data) { 
00133       return Put((char *)&data, sizeof(float)); 
00134     }
00135     MOStream *put(double data) { 
00136       return Put((char *)&data, sizeof(double)); 
00137     }
00138     MOStream *put(size_t len, char *data) { 
00139       return Put(data,len*sizeof(char)); 
00140     }
00141     MOStream *put(size_t len, unsigned char *data) { 
00142       return Put((char *)data,len*sizeof(unsigned char)); 
00143     }
00144     MOStream *put(size_t len, short *data) { 
00145       return Put((char *)data,len*sizeof(short)); 
00146     }
00147     MOStream *put(size_t len, unsigned short *data) { 
00148       return Put((char *)data,len*sizeof(unsigned short)); 
00149     }
00150     MOStream *put(size_t len, int *data) { 
00151       return Put((char *)data,len*sizeof(int)); 
00152     }
00153     MOStream *put(size_t len, unsigned int *data) { 
00154       return Put((char *)data,len*sizeof(unsigned int)); 
00155     }
00156     MOStream *put(size_t len, long *data) { 
00157       return Put((char *)data,len*sizeof(long)); 
00158     }
00159     MOStream *put(size_t len, unsigned long *data) { 
00160       return Put((char *)data,len*sizeof(unsigned long)); 
00161     }
00162     MOStream *put(size_t len, float *data) { 
00163       return Put((char *)data,len*sizeof(float)); 
00164     }
00165     MOStream *put(size_t len, double *data) { 
00166       return Put((char *)data,len*sizeof(double)); 
00167     }
00168     MOStream *put(Vector *data) { 
00169       return Put((char *)data,sizeof(Vector)); 
00170     }
00171     MOStream *put(size_t len, Vector *data) { 
00172       return Put((char *)data,len*sizeof(Vector)); 
00173     }
00174     MOStream *put(char *data) {
00175       size_t length = strlen(data);
00176       put((int)length);
00177       return put(length, data);
00178     }
00179 };
00180 
00181 #endif

Generated on Fri Sep 22 01:17:13 2017 for NAMD by  doxygen 1.4.7