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
00028
00029 #include "Message.h"
00030 #include <OPS_Globals.h>
00031
00032 #ifndef _WIN32
00033 #include <strings.h>
00034 #endif
00035
00036 Message::Message()
00037 :length(0),data(0)
00038 {
00039
00040 }
00041
00042 Message::Message(double *Ptr, int size)
00043 {
00044 length = size*sizeof(double);
00045 data = (char *)Ptr;
00046 }
00047
00048 Message::Message(int *Ptr, int size)
00049 {
00050 length = size*sizeof(int);
00051 data = (char *)Ptr;
00052 }
00053
00054 Message::Message(char *Ptr, int size)
00055 {
00056 length = size*sizeof(char);
00057 data = Ptr;
00058 }
00059
00060 Message::~Message()
00061 {
00062
00063 }
00064
00065 #ifdef _WIN32
00066 extern "C" void bcopy(const char *scource, char *dest, int length);
00067 #include <winsock.h>
00068 #define bcopy(s,d,l) memmove(d,s,l)
00069 #endif
00070
00071 int
00072 Message::putData(char *theData, int startLoc, int endLoc)
00073 {
00074 if (startLoc > 0 && startLoc <= length &&
00075 endLoc <= length && endLoc > startLoc) {
00076 int theLength = endLoc - startLoc;
00077 char *dataPos = &data[startLoc];
00078 bcopy(theData, dataPos, theLength);
00079 return 0;
00080 } else {
00081 opserr << "Message::putData() - invalid length of data given\n";
00082 return -1;
00083 }
00084 }
00085
00086 const char *
00087 Message::getData(void)
00088 {
00089 return data;
00090 }
00091
00092 int
00093 Message::getSize()
00094 {
00095 return length;
00096 }
00097
00098