Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PsnPvmIncomingMessage Class Reference

Defining a received message for a message passing architecture. More...

#include <PsnPvmIncomingMessage.h>

Inheritance diagram for PsnPvmIncomingMessage:

Inheritance graph
[legend]
Collaboration diagram for PsnPvmIncomingMessage:

Collaboration graph
[legend]
List of all members.

Public Methods

 PsnPvmIncomingMessage ()
 constructor with no associated message

 PsnPvmIncomingMessage (int bufId)
 constructor used to initialise by saving the receive buffer whithout interpretation of the contents of the buffer

const PsDategetMessageDate ()
 The timestamp of the incomming message.

virtual void initialise (int bufId)
 initialise the receive buffer with a received buffer

virtual bool hasMessage () const
 test to see if there is a message in the incoming buffer

virtual ~PsnPvmIncomingMessage ()
 Destructor.

virtual void get (bool &val)
 get a bool in the message

virtual void get (char &val)
 get a char in the message

virtual void get (long &val)
 get a long in the message

virtual void get (unsigned long &val)
 get an unsigned long in the message

virtual void get (int &val)
 get an int in the message

virtual void get (unsigned int &val)
 get an unsigned int in the message

virtual void get (float &val)
 get a float in the message

virtual void get (double &val)
 get a double in the message

virtual void get (short &val)
 get a short in the message

virtual void get (unsigned short &val)
 get an unsigned short in the message

virtual void get (char *val)
 get a C style string, whithout it's length which should be gotten first if the string isn't of constant length

virtual void get (string &val)
 get a string Warning : this isn't natively supported by PVM, so using this method, a copy of the string is first made from the buffer, then a copy to val !

virtual void get (char *val, int cnt)
 get a char in the message

virtual void get (long *val, int cnt)
 get a long in the message

virtual void get (unsigned long *val, int cnt)
 get an unsigned long in the message

virtual void get (int *val, int cnt)
 get an int in the message

virtual void get (unsigned int *val, int cnt)
 get an unsigned int in the message

virtual void get (float *val, int cnt)
 get a float in the message

virtual void get (double *val, int cnt)
 get a double in the message

virtual void get (short *val, int cnt)
 get a short in the message

virtual void get (unsigned short *val, int cnt)
 get an unsigned short in the message


Static Public Attributes

int pvmActiveBuffer = 0
 only used for debugging purposes, as this class serves as interface between the context sensitive notion of active buffers of Pvm and the context free incomingMessages


Protected Methods

void checkForGetErrors (int info)
 member function ensuring awarness of geting errors


Protected Attributes

PsDate _messageTimestamp
 date associated to the current message


Detailed Description

Defining a received message for a message passing architecture.

Author:
David Margery (version 1.0 by Siames)
Version:
2.2

Definition at line 15 of file PsnPvmIncomingMessage.h.


Constructor & Destructor Documentation

PsnPvmIncomingMessage::PsnPvmIncomingMessage  
 

constructor with no associated message

Definition at line 12 of file PsnPvmIncomingMessage.cxx.

00012                                              :
00013    PsIncomingSynchronisationMessage (),
00014    PsnPvmMessage (0)
00015 {
00016 
00017 }

PsnPvmIncomingMessage::PsnPvmIncomingMessage int    bufId
 

constructor used to initialise by saving the receive buffer whithout interpretation of the contents of the buffer

Definition at line 21 of file PsnPvmIncomingMessage.cxx.

References pvmActiveBuffer.

00021                                                       :
00022    PsIncomingSynchronisationMessage (),
00023    PsnPvmMessage (bufId)
00024 {
00025   pvmActiveBuffer = bufId ;
00026 }

PsnPvmIncomingMessage::~PsnPvmIncomingMessage   [virtual]
 

Destructor.

Definition at line 44 of file PsnPvmIncomingMessage.cxx.

00045 {
00046 }


Member Function Documentation

void PsnPvmIncomingMessage::checkForGetErrors int    info [protected]
 

member function ensuring awarness of geting errors

Definition at line 60 of file PsnPvmIncomingMessage.cxx.

References PsController::ExceptionOnWarnings, and PsController::warningLevel.

Referenced by get().

00061 {
00062   if (info < 0 )
00063     {
00064       cerr<<"PsnPvmIncomingMessage::checkForGetErrors ERROR ";
00065       assert ( false ) ;
00066       switch ( info ) 
00067         {
00068         case PvmNoData:
00069           cerr<<"Reading beyond the end of the receive buffer. Most likely cause is trying to get more items than were originally packed into the buffer. This can also happen if a new reception without buffer saving happened in the course of geting all the data of a previous message";
00070           break;
00071         case PvmNoBuf:
00072           cerr<<"There is no active receive buffer to get.";
00073           break;
00074         case PvmBadMsg:
00075            cerr<<"The received message can to be decoded. Most likely because the hosts are heterogeneous and the users specified an incompatible encoding.";
00076           break;
00077         default:
00078           cerr<<"unexpected error: ";
00079         }
00080       cerr<<endl;         
00081       if ( PsController::warningLevel >= PsController::ExceptionOnWarnings ) 
00082          {            
00083             throw PsPvmException ( info ) ; 
00084          }
00085     }
00086 }

void PsnPvmIncomingMessage::get unsigned short *    val,
int    cnt
[virtual]
 

get an unsigned short in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 349 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00350 {
00351   assert ( pvmActiveBuffer == _currentBuffer );
00352   int info = pvm_upkushort ( val, cnt, 1 ) ;
00353 #ifdef _DEBUGPVMMESS
00354   cerr<<"PsnPvmIncomingMessage::get (unsigned short * "<<val<<" )"<<endl;
00355 #endif
00356   checkForGetErrors ( info ) ;
00357 }

void PsnPvmIncomingMessage::get short *    val,
int    cnt
[virtual]
 

get a short in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 337 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00338 {
00339   assert ( pvmActiveBuffer == _currentBuffer );
00340   int info = pvm_upkshort ( val, cnt, 1 ) ;
00341 #ifdef _DEBUGPVMMESS
00342   cerr<<"PsnPvmIncomingMessage::get (short * "<<val<<" )"<<endl;
00343 #endif
00344   checkForGetErrors ( info ) ;
00345 }

void PsnPvmIncomingMessage::get double *    val,
int    cnt
[virtual]
 

get a double in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 324 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00325 {
00326   assert ( pvmActiveBuffer == _currentBuffer );
00327   int info = pvm_upkdouble ( val, 1, 1 ) ;
00328 #ifdef _DEBUGPVMMESS
00329   cerr<<"PsnPvmIncomingMessage::get (double * "<<val<<" )"<<endl;
00330 #endif
00331   checkForGetErrors ( info ) ;
00332 }

void PsnPvmIncomingMessage::get float *    val,
int    cnt
[virtual]
 

get a float in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 311 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00312 {
00313   assert ( pvmActiveBuffer == _currentBuffer );
00314   int info = pvm_upkfloat ( val, cnt, 1 ) ;
00315 #ifdef _DEBUGPVMMESS
00316   cerr<<"PsnPvmIncomingMessage::get (float * "<<val<<" )"<<endl;
00317 #endif
00318   checkForGetErrors ( info ) ;
00319 }

void PsnPvmIncomingMessage::get unsigned int *    val,
int    cnt
[virtual]
 

get an unsigned int in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 298 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00299 {
00300   assert ( pvmActiveBuffer == _currentBuffer );
00301   int info = pvm_upkuint ( val, cnt, 1 ) ;
00302 #ifdef _DEBUGPVMMESS
00303   cerr<<"PsnPvmIncomingMessage::get (unsigned int * "<<val<<" )"<<endl;
00304 #endif
00305   checkForGetErrors ( info ) ;
00306 }

void PsnPvmIncomingMessage::get int *    val,
int    cnt
[virtual]
 

get an int in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 286 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00287 {
00288   assert ( pvmActiveBuffer == _currentBuffer );
00289   int info = pvm_upkint ( val, cnt, 1 ) ;
00290 #ifdef _DEBUGPVMMESS
00291   cerr<<"PsnPvmIncomingMessage::get (int * "<<val<<" )"<<endl;
00292 #endif
00293   checkForGetErrors ( info ) ;
00294 }

void PsnPvmIncomingMessage::get unsigned long *    val,
int    cnt
[virtual]
 

get an unsigned long in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 272 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00273 {
00274   assert ( pvmActiveBuffer == _currentBuffer );
00275   int info = pvm_upkulong ( val, cnt, 1 ) ;
00276 #ifdef _DEBUGPVMMESS
00277   cerr<<"PsnPvmIncomingMessage::get (unsigned long * "<<val<<" )"<<endl;
00278 #endif
00279   checkForGetErrors ( info ) ;
00280 }

void PsnPvmIncomingMessage::get long *    val,
int    cnt
[virtual]
 

get a long in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 259 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00260 {
00261    assert ( pvmActiveBuffer == _currentBuffer ) ;
00262    int info = pvm_upklong ( val, cnt, 1 ) ;
00263 #ifdef _DEBUGPVMMESS
00264   cerr<<"PsnPvmIncomingMessage::get (long * "<<val<<" )"<<endl;
00265 #endif
00266    checkForGetErrors ( info ) ;
00267 }

void PsnPvmIncomingMessage::get char *    val,
int    cnt
[virtual]
 

get a char in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 248 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00249 {
00250    assert ( pvmActiveBuffer == _currentBuffer ) ;
00251    int info = pvm_upkbyte ( val, cnt, 1 ) ;
00252 #ifdef _DEBUGPVMMESS
00253   cerr<<"PsnPvmIncomingMessage::get (char * "<<val<<" )"<<endl;
00254 #endif
00255    checkForGetErrors ( info ) ;
00256 }

void PsnPvmIncomingMessage::get string &    val [virtual]
 

get a string Warning : this isn't natively supported by PVM, so using this method, a copy of the string is first made from the buffer, then a copy to val !

Implements PsIncomingSynchronisationMessage.

Definition at line 227 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00228 {
00229   assert ( pvmActiveBuffer == _currentBuffer );
00230 
00231   unsigned int stringSize ;
00232   int info = pvm_upkuint ( &stringSize, 1, 1 ) ;
00233   checkForGetErrors ( info ) ;
00234 
00235   char * Cstr = new char [stringSize] ;
00236 
00237   info = pvm_upkstr ( Cstr ) ;
00238   checkForGetErrors ( info ) ;
00239   assert (Cstr[stringSize-1] == '\0' ) ;
00240 
00241   str = Cstr ;
00242 #ifdef _DEBUGPVMMESS
00243   cerr<<"PsnPvmIncomingMessage::get (string & "<<str<<" )"<<endl;
00244 #endif
00245   delete [] Cstr ;
00246 
00247 }

void PsnPvmIncomingMessage::get char *    val [virtual]
 

get a C style string, whithout it's length which should be gotten first if the string isn't of constant length

Implements PsIncomingSynchronisationMessage.

Definition at line 216 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00217 {
00218   assert ( pvmActiveBuffer == _currentBuffer );
00219   int info = pvm_upkstr ( ch ) ;
00220 #ifdef _DEBUGPVMMESS
00221   cerr<<"PsnPvmIncomingMessage::get (char * "<<ch<<" )"<<endl;
00222 #endif
00223   checkForGetErrors ( info ) ;
00224 }

void PsnPvmIncomingMessage::get unsigned short &    val [virtual]
 

get an unsigned short in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 204 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00205 {
00206   assert ( pvmActiveBuffer == _currentBuffer );
00207   int info = pvm_upkushort ( &val, 1, 1 ) ;
00208 #ifdef _DEBUGPVMMESS
00209   cerr<<"PsnPvmIncomingMessage::get (unsigned short & "<<val<<" )"<<endl;
00210 #endif
00211   checkForGetErrors ( info ) ;
00212 }

void PsnPvmIncomingMessage::get short &    val [virtual]
 

get a short in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 192 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00193 {
00194   assert ( pvmActiveBuffer == _currentBuffer );
00195   int info = pvm_upkshort ( &val, 1, 1 ) ;
00196 #ifdef _DEBUGPVMMESS
00197   cerr<<"PsnPvmIncomingMessage::get (short & "<<val<<" )"<<endl;
00198 #endif
00199   checkForGetErrors ( info ) ;
00200 }

void PsnPvmIncomingMessage::get double &    val [virtual]
 

get a double in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 179 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00180 {
00181   assert ( pvmActiveBuffer == _currentBuffer );
00182   int info = pvm_upkdouble ( &val, 1, 1 ) ;
00183 #ifdef _DEBUGPVMMESS
00184   cerr<<"PsnPvmIncomingMessage::get (double & "<<val<<" )"<<endl;
00185 #endif
00186   checkForGetErrors ( info ) ;
00187 }

void PsnPvmIncomingMessage::get float &    val [virtual]
 

get a float in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 166 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00167 {
00168   assert ( pvmActiveBuffer == _currentBuffer );
00169   int info = pvm_upkfloat ( &val, 1, 1 ) ;
00170 #ifdef _DEBUGPVMMESS
00171   cerr<<"PsnPvmIncomingMessage::get (float & "<<val<<" )"<<endl;
00172 #endif
00173   checkForGetErrors ( info ) ;
00174 }

void PsnPvmIncomingMessage::get unsigned int &    val [virtual]
 

get an unsigned int in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 153 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00154 {
00155   assert ( pvmActiveBuffer == _currentBuffer );
00156   int info = pvm_upkuint ( &val, 1, 1 ) ;
00157 #ifdef _DEBUGPVMMESS
00158   cerr<<"PsnPvmIncomingMessage::get (unsigned int & "<<val<<" )"<<endl;
00159 #endif
00160   checkForGetErrors ( info ) ;
00161 }

void PsnPvmIncomingMessage::get int &    val [virtual]
 

get an int in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 141 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00142 {
00143   assert ( pvmActiveBuffer == _currentBuffer );
00144   int info = pvm_upkint ( &val, 1, 1 ) ;
00145 #ifdef _DEBUGPVMMESS
00146   cerr<<"PsnPvmIncomingMessage::get (int & "<<val<<" )"<<endl;
00147 #endif
00148   checkForGetErrors ( info ) ;
00149 }

void PsnPvmIncomingMessage::get unsigned long &    val [virtual]
 

get an unsigned long in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 127 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00128 {
00129   assert ( pvmActiveBuffer == _currentBuffer );
00130   int info = pvm_upkulong ( &val, 1, 1 ) ;
00131 #ifdef _DEBUGPVMMESS
00132   cerr<<"PsnPvmIncomingMessage::get (unsigned long & "<<val<<" )"<<endl;
00133 #endif
00134   checkForGetErrors ( info ) ;
00135 }

void PsnPvmIncomingMessage::get long &    val [virtual]
 

get a long in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 114 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00115 {
00116    assert ( pvmActiveBuffer == _currentBuffer ) ;
00117    int info = pvm_upklong ( &val, 1, 1 ) ;
00118 #ifdef _DEBUGPVMMESS
00119   cerr<<"PsnPvmIncomingMessage::get (long & "<<val<<" )"<<endl;
00120 #endif
00121    checkForGetErrors ( info ) ;
00122 }

void PsnPvmIncomingMessage::get char &    val [virtual]
 

get a char in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 103 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00104 {
00105    assert ( pvmActiveBuffer == _currentBuffer ) ;
00106    int info = pvm_upkbyte ( &val, 1, 1 ) ;
00107 #ifdef _DEBUGPVMMESS
00108   cerr<<"PsnPvmIncomingMessage::get (char & "<<val<<" )"<<endl;
00109 #endif
00110    checkForGetErrors ( info ) ;
00111 }

void PsnPvmIncomingMessage::get bool &    val [virtual]
 

get a bool in the message

Implements PsIncomingSynchronisationMessage.

Definition at line 90 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00091 {
00092    assert ( pvmActiveBuffer == _currentBuffer ) ;
00093    char realVal ;
00094    int info = pvm_upkbyte ( &realVal, 1, 1 ) ;
00095    val = realVal ;
00096 #ifdef _DEBUGPVMMESS
00097   cerr<<"PsnPvmIncomingMessage::get (char & "<<val<<" )"<<endl;
00098 #endif
00099    checkForGetErrors ( info ) ;
00100 }

const PsDate & PsnPvmIncomingMessage::getMessageDate   [virtual]
 

The timestamp of the incomming message.

Implements PsIncomingSynchronisationMessage.

Definition at line 48 of file PsnPvmIncomingMessage.cxx.

References _messageTimestamp, and PsDate.

Referenced by PsnSvm::serveNameRequestsUntilEnd(), PsnSvm::synchroniseReceiveAndProcessMessages(), and PsnSvm::waitForAnswerToBlockingRequest().

00049 {
00050    return _messageTimestamp ;
00051 }

bool PsnPvmIncomingMessage::hasMessage   const [virtual]
 

test to see if there is a message in the incoming buffer

Definition at line 53 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer.

Referenced by PsnSvm::processReceivedMessages(), PsnSvm::synchroniseReceiveAndProcessMessages(), and PsnSvm::waitForMessage().

00054 {
00055    return _currentBuffer != 0 ;
00056 }

void PsnPvmIncomingMessage::initialise int    bufId [virtual]
 

initialise the receive buffer with a received buffer

Definition at line 30 of file PsnPvmIncomingMessage.cxx.

References PsnPvmMessage::_currentBuffer, _messageTimestamp, PsIncomingSynchronisationMessage::_myis, and pvmActiveBuffer.

Referenced by PsnPvmSvmLink::testForAnyMessage(), PsnPvmSvmLink::testForMessage(), and PsnPvmSvmLink::waitForMessage().

00031 {
00032   _currentBuffer = bufId ;
00033   pvmActiveBuffer = bufId ;
00034   if (_myis != 0 )
00035     {
00036       delete _myis ;
00037       _myis = 0 ;
00038     }
00039   if (_currentBuffer != 0) _messageTimestamp.unpack(*this) ;
00040 }


Member Data Documentation

PsDate PsnPvmIncomingMessage::_messageTimestamp [protected]
 

date associated to the current message

Definition at line 115 of file PsnPvmIncomingMessage.h.

Referenced by getMessageDate(), and initialise().

int PsnPvmIncomingMessage::pvmActiveBuffer = 0 [static]
 

only used for debugging purposes, as this class serves as interface between the context sensitive notion of active buffers of Pvm and the context free incomingMessages

Definition at line 8 of file PsnPvmIncomingMessage.cxx.

Referenced by get(), initialise(), and PsnPvmIncomingMessage().


The documentation for this class was generated from the following files:
logo OpenMask

Documentation generated on Mon Nov 25 15:26:21 2002

Generated with doxygen 1.2.12 by Dimitri van Heesch ,   1997-2001