Message.cpp

Go to the documentation of this file.
00001 /* ****************************************************************** **
00002 **    OpenSees - Open System for Earthquake Engineering Simulation    **
00003 **          Pacific Earthquake Engineering Research Center            **
00004 **                                                                    **
00005 **                                                                    **
00006 ** (C) Copyright 1999, The Regents of the University of California    **
00007 ** All Rights Reserved.                                               **
00008 **                                                                    **
00009 ** Commercial use of this program without express permission of the   **
00010 ** University of California, Berkeley, is strictly prohibited.  See   **
00011 ** file 'COPYRIGHT'  in main directory for information on usage and   **
00012 ** redistribution,  and for a DISCLAIMER OF ALL WARRANTIES.           **
00013 **                                                                    **
00014 ** Developed by:                                                      **
00015 **   Frank McKenna (fmckenna@ce.berkeley.edu)                         **
00016 **   Gregory L. Fenves (fenves@ce.berkeley.edu)                       **
00017 **   Filip C. Filippou (filippou@ce.berkeley.edu)                     **
00018 **                                                                    **
00019 ** ****************************************************************** */
00020                                                                         
00021 // $Revision: 1.6 $
00022 // $Date: 2004/11/25 00:54:09 $
00023 // $Source: /usr/local/cvs/OpenSees/SRC/actor/message/Message.cpp,v $
00024                                                                         
00025                                                                         
00026 // File: ~/actor/Message.C
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 

Generated on Mon Oct 23 15:04:56 2006 for OpenSees by doxygen 1.5.0