OMK::PvmIncomingMessage Class Reference

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

#include <OMKPvmIncomingMessage.h>

Inheritance diagram for OMK::PvmIncomingMessage:

Inheritance graph
[legend]
Collaboration diagram for OMK::PvmIncomingMessage:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 PvmIncomingMessage ()
 constructor with no associated message
 PvmIncomingMessage (int bufId)
 constructor used to initialise by saving the receive buffer whithout interpretation of the contents of the buffer
virtual const DategetMessageDate ()
 The timestamp of the incomming message.
virtual void initialise (int bufId)
 initialise the receive buffer with a received buffer
virtual void deleteCurrentBuffer ()
 delete a received buffer
virtual bool hasMessage () const
 test to see if there is a message in the incoming buffer
virtual ~PvmIncomingMessage ()
 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 (std::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

static int pvmActiveBuffer
 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 Member Functions

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

Protected Attributes

OMK::Type::SimpleTypeT< Date_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 21 of file OMKPvmIncomingMessage.h.


Constructor & Destructor Documentation

PvmIncomingMessage::PvmIncomingMessage (  ) 

constructor with no associated message

Definition at line 15 of file OMKPvmIncomingMessage.cxx.

00015                                        :
00016    IncomingSynchronisationMessage (),
00017    PvmMessage (0)
00018 {
00019 
00020 }

PvmIncomingMessage::PvmIncomingMessage ( int  bufId  ) 

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

Definition at line 24 of file OMKPvmIncomingMessage.cxx.

References pvmActiveBuffer.

00024                                                 :
00025    IncomingSynchronisationMessage (),
00026    PvmMessage (bufId)
00027 {
00028   pvmActiveBuffer = bufId ;
00029 }

PvmIncomingMessage::~PvmIncomingMessage (  )  [virtual]

Destructor.

Definition at line 52 of file OMKPvmIncomingMessage.cxx.

00053 {
00054 
00055 }


Member Function Documentation

const Date & PvmIncomingMessage::getMessageDate (  )  [virtual]

The timestamp of the incomming message.

Implements OMK::IncomingSynchronisationMessage.

Definition at line 57 of file OMKPvmIncomingMessage.cxx.

References _messageTimestamp.

Referenced by OMK::Svm::processReceivedMessages(), OMK::Svm::serveNameRequestsUntilEnd(), and OMK::Svm::waitForAnswerToBlockingRequest().

00058 {
00059    return _messageTimestamp ;
00060 }

void PvmIncomingMessage::initialise ( int  bufId  )  [virtual]

initialise the receive buffer with a received buffer

Definition at line 33 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, _messageTimestamp, OMK::IncomingSynchronisationMessage::_myis, and pvmActiveBuffer.

Referenced by OMK::PvmSvmLink::testForAnyMessage(), OMK::PvmSvmLink::testForMessage(), OMK::PvmSvmLink::testIfRequestUpdateProcessTable(), OMK::PvmSvm::waitForAnyRequests(), and OMK::PvmSvmLink::waitForMessage().

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

void PvmIncomingMessage::deleteCurrentBuffer (  )  [virtual]

delete a received buffer

Definition at line 45 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer.

00046 {
00047   pvm_freebuf(_currentBuffer);
00048 }

bool PvmIncomingMessage::hasMessage (  )  const [virtual]

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

Definition at line 62 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer.

Referenced by OMK::Svm::processReceivedMessages(), OMK::Svm::relaxedSynchroniseReceiveAndProcessMessages(), OMK::Svm::synchroniseReceiveAndProcessMessages(), and OMK::Svm::waitForMessage().

00063 {
00064    return _currentBuffer != 0 ;
00065 }

void PvmIncomingMessage::get ( bool val  )  [virtual]

get a bool in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 96 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00097 {
00098    assert ( pvmActiveBuffer == _currentBuffer ) ;
00099    char realVal ;
00100    int info = pvm_upkbyte ( &realVal, 1, 1 ) ;
00101    val = realVal ;
00102 #ifdef _DEBUGPVMMESS
00103   cerr<<"PvmIncomingMessage::get (char & "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00104 #endif
00105    checkForGetErrors ( info ) ;
00106 }

void PvmIncomingMessage::get ( char &  val  )  [virtual]

get a char in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 109 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00110 {
00111    assert ( pvmActiveBuffer == _currentBuffer ) ;
00112    int info = pvm_upkbyte ( &val, 1, 1 ) ;
00113 #ifdef _DEBUGPVMMESS
00114   cerr<<"PvmIncomingMessage::get (char & "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00115 #endif
00116    checkForGetErrors ( info ) ;
00117 }

void PvmIncomingMessage::get ( long &  val  )  [virtual]

get a long in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 120 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00121 {
00122    assert ( pvmActiveBuffer == _currentBuffer ) ;
00123    int info = pvm_upklong ( &val, 1, 1 ) ;
00124 #ifdef _DEBUGPVMMESS
00125   cerr<<"PvmIncomingMessage::get (long & "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00126 #endif
00127    checkForGetErrors ( info ) ;
00128 }

void PvmIncomingMessage::get ( unsigned long &  val  )  [virtual]

get an unsigned long in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 133 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00134 {
00135   assert ( pvmActiveBuffer == _currentBuffer );
00136   int info = pvm_upkulong ( &val, 1, 1 ) ;
00137 #ifdef _DEBUGPVMMESS
00138   cerr<<"PvmIncomingMessage::get (unsigned long & "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00139 #endif
00140   checkForGetErrors ( info ) ;
00141 }

void PvmIncomingMessage::get ( int val  )  [virtual]

get an int in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 147 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00148 {
00149   assert ( pvmActiveBuffer == _currentBuffer );
00150   int info = pvm_upkint ( &val, 1, 1 ) ;
00151 #ifdef _DEBUGPVMMESS
00152   cerr<<"PvmIncomingMessage::get (int & "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00153 #endif
00154   checkForGetErrors ( info ) ;
00155 }

void PvmIncomingMessage::get ( unsigned int val  )  [virtual]

get an unsigned int in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 159 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00160 {
00161   assert ( pvmActiveBuffer == _currentBuffer );
00162   int info = pvm_upkuint ( &val, 1, 1 ) ;
00163 #ifdef _DEBUGPVMMESS
00164   cerr<<"PvmIncomingMessage::get (unsigned int & "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00165 #endif
00166   checkForGetErrors ( info ) ;
00167 }

void PvmIncomingMessage::get ( float &  val  )  [virtual]

get a float in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 172 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00173 {
00174   assert ( pvmActiveBuffer == _currentBuffer );
00175   int info = pvm_upkfloat ( &val, 1, 1 ) ;
00176 #ifdef _DEBUGPVMMESS
00177   cerr<<"PvmIncomingMessage::get (float & "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00178 #endif
00179   checkForGetErrors ( info ) ;
00180 }

void PvmIncomingMessage::get ( double &  val  )  [virtual]

get a double in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 185 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00186 {
00187   assert ( pvmActiveBuffer == _currentBuffer );
00188   int info = pvm_upkdouble ( &val, 1, 1 ) ;
00189 #ifdef _DEBUGPVMMESS
00190   cerr<<"PvmIncomingMessage::get (double & "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00191 #endif
00192   checkForGetErrors ( info ) ;
00193 }

void PvmIncomingMessage::get ( short &  val  )  [virtual]

get a short in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 198 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00199 {
00200   assert ( pvmActiveBuffer == _currentBuffer );
00201   int info = pvm_upkshort ( &val, 1, 1 ) ;
00202 #ifdef _DEBUGPVMMESS
00203   cerr<<"PvmIncomingMessage::get (short & "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00204 #endif
00205   checkForGetErrors ( info ) ;
00206 }

void PvmIncomingMessage::get ( unsigned short &  val  )  [virtual]

get an unsigned short in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 210 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00211 {
00212   assert ( pvmActiveBuffer == _currentBuffer );
00213   int info = pvm_upkushort ( &val, 1, 1 ) ;
00214 #ifdef _DEBUGPVMMESS
00215   cerr<<"PvmIncomingMessage::get (unsigned short & "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00216 #endif
00217   checkForGetErrors ( info ) ;
00218 }

void PvmIncomingMessage::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 OMK::IncomingSynchronisationMessage.

Definition at line 222 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00223 {
00224   assert ( pvmActiveBuffer == _currentBuffer );
00225   int info = pvm_upkstr ( ch ) ;
00226 #ifdef _DEBUGPVMMESS
00227   cerr<<"PvmIncomingMessage::get (char * "<<ch<<" )"<< " Buffer " << _currentBuffer << endl;
00228 #endif
00229   checkForGetErrors ( info ) ;
00230 }

void PvmIncomingMessage::get ( std::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 OMK::IncomingSynchronisationMessage.

Definition at line 233 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00234 {
00235   assert ( pvmActiveBuffer == _currentBuffer );
00236 
00237   unsigned int stringSize ;
00238   int info = pvm_upkuint ( &stringSize, 1, 1 ) ;
00239   checkForGetErrors ( info ) ;
00240 
00241   char * Cstr = new char [stringSize] ;
00242 
00243   info = pvm_upkstr ( Cstr ) ;
00244   checkForGetErrors ( info ) ;
00245   assert (Cstr[stringSize-1] == '\0' ) ;
00246 
00247   str = Cstr ;
00248 #ifdef _DEBUGPVMMESS
00249   cerr<<"PvmIncomingMessage::get (std::string & "<<str<<" )"<< " Buffer " << _currentBuffer << endl;
00250 #endif
00251   delete [] Cstr ;
00252 
00253 }

void PvmIncomingMessage::get ( char *  val,
int  cnt 
) [virtual]

get a char in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 254 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00255 {
00256    assert ( pvmActiveBuffer == _currentBuffer ) ;
00257    int info = pvm_upkbyte ( val, cnt, 1 ) ;
00258 #ifdef _DEBUGPVMMESS
00259   cerr<<"PvmIncomingMessage::get (char * "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00260 #endif
00261    checkForGetErrors ( info ) ;
00262 }

void PvmIncomingMessage::get ( long *  val,
int  cnt 
) [virtual]

get a long in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 265 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00266 {
00267    assert ( pvmActiveBuffer == _currentBuffer ) ;
00268    int info = pvm_upklong ( val, cnt, 1 ) ;
00269 #ifdef _DEBUGPVMMESS
00270   cerr<<"PvmIncomingMessage::get (long * "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00271 #endif
00272    checkForGetErrors ( info ) ;
00273 }

void PvmIncomingMessage::get ( unsigned long *  val,
int  cnt 
) [virtual]

get an unsigned long in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 278 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00279 {
00280   assert ( pvmActiveBuffer == _currentBuffer );
00281   int info = pvm_upkulong ( val, cnt, 1 ) ;
00282 #ifdef _DEBUGPVMMESS
00283   cerr<<"PvmIncomingMessage::get (unsigned long * "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00284 #endif
00285   checkForGetErrors ( info ) ;
00286 }

void PvmIncomingMessage::get ( int val,
int  cnt 
) [virtual]

get an int in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 292 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00293 {
00294   assert ( pvmActiveBuffer == _currentBuffer );
00295   int info = pvm_upkint ( val, cnt, 1 ) ;
00296 #ifdef _DEBUGPVMMESS
00297   cerr<<"PvmIncomingMessage::get (int * "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00298 #endif
00299   checkForGetErrors ( info ) ;
00300 }

void PvmIncomingMessage::get ( unsigned int val,
int  cnt 
) [virtual]

get an unsigned int in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 304 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00305 {
00306   assert ( pvmActiveBuffer == _currentBuffer );
00307   int info = pvm_upkuint ( val, cnt, 1 ) ;
00308 #ifdef _DEBUGPVMMESS
00309   cerr<<"PvmIncomingMessage::get (unsigned int * "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00310 #endif
00311   checkForGetErrors ( info ) ;
00312 }

void PvmIncomingMessage::get ( float *  val,
int  cnt 
) [virtual]

get a float in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 317 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00318 {
00319   assert ( pvmActiveBuffer == _currentBuffer );
00320   int info = pvm_upkfloat ( val, cnt, 1 ) ;
00321 #ifdef _DEBUGPVMMESS
00322   cerr<<"PvmIncomingMessage::get (float * "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00323 #endif
00324   checkForGetErrors ( info ) ;
00325 }

void PvmIncomingMessage::get ( double *  val,
int  cnt 
) [virtual]

get a double in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 330 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00331 {
00332   assert ( pvmActiveBuffer == _currentBuffer );
00333   int info = pvm_upkdouble ( val, 1, 1 ) ;
00334 #ifdef _DEBUGPVMMESS
00335   cerr<<"PvmIncomingMessage::get (double * "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00336 #endif
00337   checkForGetErrors ( info ) ;
00338 }

void PvmIncomingMessage::get ( short *  val,
int  cnt 
) [virtual]

get a short in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 343 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00344 {
00345   assert ( pvmActiveBuffer == _currentBuffer );
00346   int info = pvm_upkshort ( val, cnt, 1 ) ;
00347 #ifdef _DEBUGPVMMESS
00348   cerr<<"PvmIncomingMessage::get (short * "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00349 #endif
00350   checkForGetErrors ( info ) ;
00351 }

void PvmIncomingMessage::get ( unsigned short *  val,
int  cnt 
) [virtual]

get an unsigned short in the message

Implements OMK::IncomingSynchronisationMessage.

Definition at line 355 of file OMKPvmIncomingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, checkForGetErrors(), and pvmActiveBuffer.

00356 {
00357   assert ( pvmActiveBuffer == _currentBuffer );
00358   int info = pvm_upkushort ( val, cnt, 1 ) ;
00359 #ifdef _DEBUGPVMMESS
00360   cerr<<"PvmIncomingMessage::get (unsigned short * "<<val<<" )"<< " Buffer " << _currentBuffer << endl;
00361 #endif
00362   checkForGetErrors ( info ) ;
00363 }

void PvmIncomingMessage::checkForGetErrors ( int  info  )  [protected, virtual]

member function ensuring awarness of geting errors

Definition at line 69 of file OMKPvmIncomingMessage.cxx.

References OMASSERT.

Referenced by get().

00070 {
00071   if (info < 0 )
00072     {
00073       cerr<<"PvmIncomingMessage::checkForGetErrors ERROR ";
00074       assert ( false ) ;
00075       switch ( info ) 
00076         {
00077         case PvmNoData:
00078           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";
00079           break;
00080         case PvmNoBuf:
00081           cerr<<"There is no active receive buffer to get.";
00082           break;
00083         case PvmBadMsg:
00084            cerr<<"The received message can to be decoded. Most likely because the hosts are heterogeneous and the users specified an incompatible encoding.";
00085           break;
00086         default:
00087           cerr<<"unexpected error: ";
00088         }
00089       cerr<<endl;         
00090         OMASSERT( false ) ;
00091     }
00092 }


Member Data Documentation

int PvmIncomingMessage::pvmActiveBuffer [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 122 of file OMKPvmIncomingMessage.h.

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

OMK::Type::SimpleTypeT< Date > OMK::PvmIncomingMessage::_messageTimestamp [protected]

date associated to the current message

Definition at line 129 of file OMKPvmIncomingMessage.h.

Referenced by getMessageDate(), and initialise().


logo OpenMask

Documentation generated on Mon Jun 9 11:46:03 2008

Generated with doxygen by Dimitri van Heesch ,   1997-2007