OMK::PvmOutgoingMessage Class Reference

defining a sent message for a message passing architecture. More...

#include <OMKPvmOutgoingMessage.h>

Inheritance diagram for OMK::PvmOutgoingMessage:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual ~PvmOutgoingMessage ()
 Destructor.
 PvmOutgoingMessage ()
 default constructor for an outgoing message
virtual const DategetMessageDate () const
 The timestamp of the outgoing message.
virtual void send (PvmMessage::MessageTag tag)=0
 send all previously packed data and reinitiliase the send buffer
virtual bool isTimeStamped () const
 find out if the buffer has been timestamped
virtual void insertTimeStamp (const Date &date)
 insertTimeStamp associate a time stamp to the current message
virtual void pack (bool val)
 pack a bool in the message
virtual void pack (char val)
 pack a char in the message
virtual void pack (long val)
 pack a long in the message
virtual void pack (unsigned long val)
 pack an unsigned long in the message
virtual void pack (int val)
 pack an int in the message
virtual void pack (unsigned int val)
 pack an unsigned int in the message
virtual void pack (float val)
 pack a float in the message
virtual void pack (double val)
 pack a double in the message
virtual void pack (short val)
 pack a short in the message
virtual void pack (unsigned short val)
 pack an unsigned short in the message
virtual void pack (char *val)
 pack a C-style string in the message
virtual void pack (const char *val)
 pack a C-style string in the message
virtual void pack (const std::string &val)
 pack a string in the message
virtual void pack (const long *val, int cnt)
 pack an array of long in the message
virtual void pack (const unsigned long *val, int cnt)
 pack an array of unsigned long in the message
virtual void pack (const int *val, int cnt)
 pack an array of int in the message
virtual void pack (const unsigned int *val, int cnt)
 pack an array of unsigned int in the message
virtual void pack (const float *val, int cnt)
 pack an array of float in the message
virtual void pack (const double *val, int cnt)
 pack an array of double in the message
virtual void pack (const short *val, int cnt)
 pack an array of short in the message
virtual void pack (const unsigned short *val, int cnt)
 pack an array of unsigned short in the message
virtual void pack (long *val, int cnt)
 pack an array of long in the message
virtual void pack (unsigned long *val, int cnt)
 pack an array of unsigned long in the message
virtual void pack (int *val, int cnt)
 pack an array of int in the message
virtual void pack (unsigned int *val, int cnt)
 pack an array of unsigned int in the message
virtual void pack (float *val, int cnt)
 pack an array of float in the message
virtual void pack (double *val, int cnt)
 pack an array of double in the message
virtual void pack (short *val, int cnt)
 pack an array of short in the message
virtual void pack (unsigned short *val, int cnt)
 pack an array of unsigned short in the message
virtual void flushCurrentBuffer ()
 CHADI.

Protected Member Functions

virtual void reinitAndRevertPvmContext (int oldbuf)
 prepare the outgoing message for new data, and revert the pvm context
virtual void checkForPackErrors (int info)
 make sure the packing didn't return any error
virtual void checkForSendErrors (int info)
 make sure sending didn't return any error
virtual void checkForChangedBuffer (int info, int lineNumber, char *file)
 make sure changing active send buffer didn't return any error

Protected Attributes

bool _timeStamped
 make sure the message has been timestamped and is not empty
Date _timestamp
 the timestamp of the message

Detailed Description

defining a sent message for a message passing architecture.

Author:
Siames
Version:
2.2

Definition at line 16 of file OMKPvmOutgoingMessage.h.


Constructor & Destructor Documentation

PvmOutgoingMessage::~PvmOutgoingMessage (  )  [virtual]

Destructor.

Definition at line 208 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer.

00209 {
00210   pvm_freebuf ( _currentBuffer ) ;
00211 }

PvmOutgoingMessage::PvmOutgoingMessage (  ) 

default constructor for an outgoing message

Definition at line 192 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and OMK::PvmSvm::pvmDataEncoding.

00192                                          : 
00193 PvmMessage(0),
00194 _timeStamped ( false )
00195 {
00196 #ifdef _DEBUGPVMMESS
00197   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":PvmOutgoingMessage ()"<<endl;
00198 #endif
00199 
00200   _currentBuffer = pvm_mkbuf ( PvmSvm::pvmDataEncoding ) ;
00201 
00202 #ifdef _DEBUGPVMMESS
00203   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":PvmOutgoingMessage (): new send buffer"<<_currentBuffer<<endl;
00204 #endif
00205 }


Member Function Documentation

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

The timestamp of the outgoing message.

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 11 of file OMKPvmOutgoingMessage.cxx.

References _timestamp.

00012 {
00013   return _timestamp ;
00014 }

virtual void OMK::PvmOutgoingMessage::send ( PvmMessage::MessageTag  tag  )  [pure virtual]

send all previously packed data and reinitiliase the send buffer

Implemented in OMK::PvmMulticastMessage, and OMK::PvmUnicastMessage.

Referenced by OMK::Svm::addNewSiteToSimulation(), OMK::Svm::createDistributedSimulation(), and OMK::PvmSvmLink::send().

bool PvmOutgoingMessage::isTimeStamped (  )  const [virtual]

find out if the buffer has been timestamped

Definition at line 242 of file OMKPvmOutgoingMessage.cxx.

References _timeStamped.

00243 {
00244   return _timeStamped ;
00245 }

void PvmOutgoingMessage::insertTimeStamp ( const Date date  )  [virtual]

insertTimeStamp associate a time stamp to the current message

Definition at line 248 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, _timestamp, _timeStamped, and OMK::PvmMessage::getSize().

Referenced by OMK::Svm::addNewSiteRequest(), OMK::Svm::addNewSiteToSimulation(), OMK::Svm::broadcast(), OMK::Svm::createDistributedSimulation(), OMK::Svm::disconnectFromDistributedSimulation(), OMK::PvmMirrorObjectHandle::registerToReferenceObject(), OMK::PvmController::sendInitialValuesToMirror(), and OMK::PvmMirrorObjectHandle::sendRequestToReferenceObject().

00249 {
00250 
00251 #ifdef _DEBUGPVMMESS
00252   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":insertTimeStamp ("<<date<<") "<<_currentBuffer
00253     <<" of size "<<getSize()
00254     <<endl;
00255 #endif
00256 
00257   if ( !_timeStamped )
00258   {
00259     _timeStamped = true ;
00260 
00261     *this<<date;
00262 
00263     _timestamp = date ;
00264 
00265     assert ( getSize() == 4 ) ;
00266 
00267   }
00268   else
00269   {
00270     if ( date != _timestamp ) {
00271       //cerr<<"WARNING : timestamping at"<<date<<" message with timestamp "<<_timestamp<<endl;
00272       //assert ( date == _timestamp ) ;
00273     }
00274   }
00275 }

void PvmOutgoingMessage::pack ( bool  val  )  [virtual]

pack a bool in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 16 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00017 {
00018 #ifdef _DEBUGPVMMESS
00019   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack (bool val) "<<val << " Buffer " << _currentBuffer <<endl;
00020 #endif
00021   //assert ( _timeStamped ) ;
00022   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00023   char realVal = val ;
00024   int info = pvm_pkbyte (&realVal, 1, 1) ;
00025   checkForPackErrors ( info ) ;
00026   pvm_setsbuf ( oldbuf ) ;
00027 }

void PvmOutgoingMessage::pack ( char  val  )  [virtual]

pack a char in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 30 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00031 {
00032 #ifdef _DEBUGPVMMESS
00033   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack (char val) "<<val << " Buffer " << _currentBuffer <<endl;
00034 #endif
00035   //assert ( _timeStamped ) ;
00036   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00037   int info = pvm_pkbyte (&val, 1, 1) ;
00038   checkForPackErrors ( info ) ;
00039   pvm_setsbuf ( oldbuf ) ;
00040 }

void PvmOutgoingMessage::pack ( long  val  )  [virtual]

pack a long in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 42 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00043 {
00044 #ifdef _DEBUGPVMMESS
00045   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack (long val) "<<val << " Buffer " << _currentBuffer <<endl;
00046 
00047 #endif
00048   //assert ( _timeStamped ) ;
00049   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00050   int info = pvm_pklong (&val, 1, 1) ;
00051   checkForPackErrors ( info ) ;
00052   pvm_setsbuf ( oldbuf ) ;
00053 }

void PvmOutgoingMessage::pack ( unsigned long  val  )  [virtual]

pack an unsigned long in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 56 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00057 {
00058 #ifdef _DEBUGPVMMESS
00059   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack (unsigned long val) "<<val<< " Buffer " << _currentBuffer << endl;
00060 #endif
00061   //assert ( _timeStamped ) ;
00062   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00063   int info = pvm_pkulong (&val, 1, 1) ;
00064   checkForPackErrors ( info ) ;
00065   pvm_setsbuf ( oldbuf ) ;
00066 }

void PvmOutgoingMessage::pack ( int  val  )  [virtual]

pack an int in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 68 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00069 {
00070 #ifdef _DEBUGPVMMESS
00071   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack (int val) "<<val<< " Buffer " << _currentBuffer << endl;
00072 #endif
00073   //assert ( _timeStamped ) ;
00074   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00075   int info = pvm_pkint (&val, 1, 1) ;
00076   checkForPackErrors ( info ) ;
00077   pvm_setsbuf ( oldbuf ) ;
00078 }

void PvmOutgoingMessage::pack ( unsigned int  val  )  [virtual]

pack an unsigned int in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 81 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00082 {
00083 #ifdef _DEBUGPVMMESS
00084   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack (unsigned int val) "<<val<< " Buffer " << _currentBuffer << endl;
00085 #endif
00086   //assert ( _timeStamped ) ;
00087   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00088   int info = pvm_pkuint (&val, 1, 1) ;
00089   checkForPackErrors ( info ) ;
00090   pvm_setsbuf ( oldbuf ) ;
00091 }

void PvmOutgoingMessage::pack ( float  val  )  [virtual]

pack a float in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 93 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00094 {
00095 #ifdef _DEBUGPVMMESS
00096   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack (float val) "<<val<< " Buffer " << _currentBuffer << endl;
00097 #endif
00098   //assert ( _timeStamped ) ;
00099   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00100   int info = pvm_pkfloat (&val, 1, 1) ;
00101   checkForPackErrors ( info ) ;
00102   pvm_setsbuf ( oldbuf ) ;
00103 }

void PvmOutgoingMessage::pack ( double  val  )  [virtual]

pack a double in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 106 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00107 {
00108 #ifdef _DEBUGPVMMESS
00109   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack (double val) "<<val<< " Buffer " << _currentBuffer << endl;
00110 #endif
00111   //assert ( _timeStamped ) ;
00112   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00113   int info = pvm_pkdouble (&val, 1, 1) ;
00114   checkForPackErrors ( info ) ;
00115   pvm_setsbuf ( oldbuf ) ;
00116 }

void PvmOutgoingMessage::pack ( short  val  )  [virtual]

pack a short in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 120 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00121 {
00122 #ifdef _DEBUGPVMMESS
00123   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack (short val) "<<val<< " Buffer " << _currentBuffer << endl;
00124 #endif
00125   //assert ( _timeStamped ) ;
00126   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00127   int info = pvm_pkshort (&val, 1, 1) ;
00128   checkForPackErrors ( info ) ;
00129   pvm_setsbuf ( oldbuf ) ;
00130 }

void PvmOutgoingMessage::pack ( unsigned short  val  )  [virtual]

pack an unsigned short in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 134 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00135 {
00136 #ifdef _DEBUGPVMMESS
00137   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack (unsigned short val) "<<val<< " Buffer " << _currentBuffer << endl;
00138 #endif
00139   //assert ( _timeStamped ) ;
00140   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00141   int info = pvm_pkushort (&val, 1, 1) ;
00142   checkForPackErrors ( info ) ;
00143   pvm_setsbuf ( oldbuf ) ;
00144 }

void PvmOutgoingMessage::pack ( char *  val  )  [virtual]

pack a C-style string in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 148 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00149 {
00150 #ifdef _DEBUGPVMMESS
00151   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack (char * val) "<<val<< " Buffer " << _currentBuffer << endl;
00152 #endif
00153   //assert ( _timeStamped ) ;
00154   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00155   int info = pvm_pkstr ( val ) ;
00156   checkForPackErrors ( info ) ;
00157   pvm_setsbuf ( oldbuf ) ;
00158 }

void PvmOutgoingMessage::pack ( const char *  val  )  [virtual]

pack a C-style string in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 160 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00161 {
00162 #ifdef _DEBUGPVMMESS
00163   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack (char * val) "<<val<< " Buffer " << _currentBuffer << endl;
00164 #endif
00165   //assert ( _timeStamped ) ;
00166   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00167   int info = pvm_pkstr ( const_cast<char *>( val ) ) ;
00168   checkForPackErrors ( info ) ;
00169   pvm_setsbuf ( oldbuf ) ;
00170 }

void PvmOutgoingMessage::pack ( const std::string &  val  )  [virtual]

pack a string in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 172 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00173 {
00174 #ifdef _DEBUGPVMMESS
00175   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack (const std::string & val) "<<val<< " Buffer " << _currentBuffer << endl;
00176 #endif
00177   //assert ( _timeStamped ) ;
00178   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00179   //the string is packed, with the length needed for unpacking
00180   unsigned int strSize =   val.size() + 1 ;
00181   int info = pvm_pkuint (  &strSize, 1, 1 ) ;
00182 
00183   checkForPackErrors ( info ) ;
00184 
00185   info = pvm_pkstr (  const_cast<char *>( val.c_str() ) ) ;
00186   checkForPackErrors ( info ) ;
00187 
00188   pvm_setsbuf ( oldbuf ) ;
00189 }

void PvmOutgoingMessage::pack ( const long *  val,
int  cnt 
) [virtual]

pack an array of long in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 348 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00349 {
00350 #ifdef _DEBUGPVMMESS
00351   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack ( const long * val, int cnt) "<<val<<endl;
00352 #endif
00353   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00354   int info = pvm_pklong ( const_cast<long *>(val), cnt, 1) ;
00355   checkForPackErrors ( info ) ;
00356   pvm_setsbuf ( oldbuf ) ;
00357 }

void PvmOutgoingMessage::pack ( const unsigned long *  val,
int  cnt 
) [virtual]

pack an array of unsigned long in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 359 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00360 {
00361 #ifdef _DEBUGPVMMESS
00362   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack ( const unsigned long * val, int cnt) "<<val<<endl;
00363 #endif
00364   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00365   int info = pvm_pkulong ( const_cast<unsigned long *>(val), cnt, 1) ;
00366   checkForPackErrors ( info ) ;
00367   pvm_setsbuf ( oldbuf ) ;
00368 }

void PvmOutgoingMessage::pack ( const int val,
int  cnt 
) [virtual]

pack an array of int in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 370 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00371 {
00372 #ifdef _DEBUGPVMMESS
00373   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack ( const int * val, int cnt) "<<val<<endl;
00374 #endif
00375   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00376   int info = pvm_pkint ( const_cast<int *>(val), cnt, 1) ;
00377   checkForPackErrors ( info ) ;
00378   pvm_setsbuf ( oldbuf ) ;
00379 }

void PvmOutgoingMessage::pack ( const unsigned int val,
int  cnt 
) [virtual]

pack an array of unsigned int in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 381 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00382 {
00383 #ifdef _DEBUGPVMMESS
00384   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack ( const unsigned int * val, int cnt) "<<val<<endl;
00385 #endif
00386   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00387   int info = pvm_pkuint ( const_cast<unsigned int *>(val), cnt, 1) ;
00388   checkForPackErrors ( info ) ;
00389   pvm_setsbuf ( oldbuf ) ;
00390 }

void PvmOutgoingMessage::pack ( const float *  val,
int  cnt 
) [virtual]

pack an array of float in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 392 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00393 {
00394 #ifdef _DEBUGPVMMESS
00395   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack ( const float * val, int cnt) "<<val<<endl;
00396 #endif
00397   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00398   int info = pvm_pkfloat ( const_cast<float *>(val), cnt, 1) ;
00399   checkForPackErrors ( info ) ;
00400   pvm_setsbuf ( oldbuf ) ;
00401 }

void PvmOutgoingMessage::pack ( const double *  val,
int  cnt 
) [virtual]

pack an array of double in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 403 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00404 {
00405 #ifdef _DEBUGPVMMESS
00406   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack ( const double * val, int cnt) "<<val<<endl;
00407 #endif
00408   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00409   int info = pvm_pkdouble ( const_cast<double *>(val), cnt, 1) ;
00410   checkForPackErrors ( info ) ;
00411   pvm_setsbuf ( oldbuf ) ;
00412 }

void PvmOutgoingMessage::pack ( const short *  val,
int  cnt 
) [virtual]

pack an array of short in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 415 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00416 {
00417 #ifdef _DEBUGPVMMESS
00418   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack ( const short * val, int cnt) "<<val<<endl;
00419 #endif
00420   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00421   int info = pvm_pkshort ( const_cast< short *>(val), cnt, 1) ;
00422   checkForPackErrors ( info ) ;
00423   pvm_setsbuf ( oldbuf ) ;
00424 }

void PvmOutgoingMessage::pack ( const unsigned short *  val,
int  cnt 
) [virtual]

pack an array of unsigned short in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 426 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00427 {
00428 #ifdef _DEBUGPVMMESS
00429   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack (const unsigned short * val, int cnt) "<<val<<endl;
00430 #endif
00431   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00432   int info = pvm_pkushort ( const_cast<unsigned short *>(val), cnt, 1) ;
00433   checkForPackErrors ( info ) ;
00434   pvm_setsbuf ( oldbuf ) ;
00435 }

void PvmOutgoingMessage::pack ( long *  val,
int  cnt 
) [virtual]

pack an array of long in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 439 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00440 {
00441 #ifdef _DEBUGPVMMESS
00442   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack ( long * val, int cnt) "<<val<<endl;
00443 #endif
00444   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00445   int info = pvm_pklong ( val, cnt, 1) ;
00446   checkForPackErrors ( info ) ;
00447   pvm_setsbuf ( oldbuf ) ;
00448 }

void PvmOutgoingMessage::pack ( unsigned long *  val,
int  cnt 
) [virtual]

pack an array of unsigned long in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 450 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00451 {
00452 #ifdef _DEBUGPVMMESS
00453   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack ( unsigned long * val, int cnt) "<<val<<endl;
00454 #endif
00455   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00456   int info = pvm_pkulong ( val, cnt, 1) ;
00457   checkForPackErrors ( info ) ;
00458   pvm_setsbuf ( oldbuf ) ;
00459 }

void PvmOutgoingMessage::pack ( int val,
int  cnt 
) [virtual]

pack an array of int in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 461 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00462 {
00463 #ifdef _DEBUGPVMMESS
00464   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack ( int * val, int cnt) "<<val<<endl;
00465 #endif
00466   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00467   int info = pvm_pkint ( val, cnt, 1) ;
00468   checkForPackErrors ( info ) ;
00469   pvm_setsbuf ( oldbuf ) ;
00470 }

void PvmOutgoingMessage::pack ( unsigned int val,
int  cnt 
) [virtual]

pack an array of unsigned int in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 472 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00473 {
00474 #ifdef _DEBUGPVMMESS
00475   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack ( unsigned int * val, int cnt) "<<val<<endl;
00476 #endif
00477   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00478   int info = pvm_pkuint ( val, cnt, 1) ;
00479   checkForPackErrors ( info ) ;
00480   pvm_setsbuf ( oldbuf ) ;
00481 }

void PvmOutgoingMessage::pack ( float *  val,
int  cnt 
) [virtual]

pack an array of float in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 483 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00484 {
00485 #ifdef _DEBUGPVMMESS
00486   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack ( float * val, int cnt) "<<val<<endl;
00487 #endif
00488   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00489   int info = pvm_pkfloat ( val, cnt, 1) ;
00490   checkForPackErrors ( info ) ;
00491   pvm_setsbuf ( oldbuf ) ;
00492 }

void PvmOutgoingMessage::pack ( double *  val,
int  cnt 
) [virtual]

pack an array of double in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 494 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00495 {
00496 #ifdef _DEBUGPVMMESS
00497   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack ( double * val, int cnt) "<<val<<endl;
00498 #endif
00499   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00500   int info = pvm_pkdouble ( val, cnt, 1) ;
00501   checkForPackErrors ( info ) ;
00502   pvm_setsbuf ( oldbuf ) ;
00503 }

void PvmOutgoingMessage::pack ( short *  val,
int  cnt 
) [virtual]

pack an array of short in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 506 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00507 {
00508 #ifdef _DEBUGPVMMESS
00509   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack ( short * val, int cnt) "<<val<<endl;
00510 #endif
00511   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00512   int info = pvm_pkshort ( val, cnt, 1) ;
00513   checkForPackErrors ( info ) ;
00514   pvm_setsbuf ( oldbuf ) ;
00515 }

void PvmOutgoingMessage::pack ( unsigned short *  val,
int  cnt 
) [virtual]

pack an array of unsigned short in the message

Implements OMK::OutgoingSynchronisationMessage.

Definition at line 517 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, and checkForPackErrors().

00518 {
00519 #ifdef _DEBUGPVMMESS
00520   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":pack (unsigned short * val, int cnt) "<<val<<endl;
00521 #endif
00522   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00523   int info = pvm_pkushort ( val, cnt, 1) ;
00524   checkForPackErrors ( info ) ;
00525   pvm_setsbuf ( oldbuf ) ;
00526 }

void PvmOutgoingMessage::flushCurrentBuffer (  )  [virtual]

CHADI.

Definition at line 530 of file OMKPvmOutgoingMessage.cxx.

References OMK::OutgoingSynchronisationMessage::reinit().

Referenced by OMK::Svm::sendCurrentBuffersWithTag().

00531 {
00532   // TDTD remplacement par un simple reinit
00533   //int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00534   //reinitAndRevertPvmContext ( oldbuf ) ;
00535   reinit () ;
00536 }

void PvmOutgoingMessage::reinitAndRevertPvmContext ( int  oldbuf  )  [protected, virtual]

prepare the outgoing message for new data, and revert the pvm context

Parameters:
odlbuf the active buffer before a public method was called

Definition at line 215 of file OMKPvmOutgoingMessage.cxx.

References OMK::PvmMessage::_currentBuffer, _timeStamped, checkForChangedBuffer(), OMK::PvmSvm::pvmDataEncoding, and OMK::OutgoingSynchronisationMessage::reinit().

Referenced by OMK::PvmUnicastMessage::send(), and OMK::PvmMulticastMessage::send().

00216 {
00217   assert (oldbuf != 0 ) ;
00218 #ifdef _DEBUGPVMMESS
00219   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":reinitAndRevertPvmContext () send buffer "<<_currentBuffer<<endl;
00220 #endif
00221 
00222   // As send has been done, reinitialise everything
00223   OutgoingSynchronisationMessage::reinit() ;
00224 
00225   _timeStamped = false ;
00226 
00227   pvm_freebuf ( _currentBuffer ) ;
00228 
00229   _currentBuffer = pvm_mkbuf ( PvmSvm::pvmDataEncoding ) ;
00230 
00231   // remplaced by the prepeceeding lines, because init_send changes the current buffer
00232   // _currentBuffer = pvm_initsend ( PvmSvm::pvmDataEncoding ) ; changes _currentBuffer )
00233 
00234   int info = pvm_setsbuf ( oldbuf ) ;
00235 
00236   checkForChangedBuffer ( info, __LINE__, __FILE__ ) ;
00237 #ifdef _DEBUGPVMMESS
00238   cerr<<"PvmOutgoingMessage:"<<(void *)this<<":new send buffer "<<_currentBuffer<<endl;
00239 #endif
00240 }

void PvmOutgoingMessage::checkForPackErrors ( int  info  )  [protected, virtual]

make sure the packing didn't return any error

Parameters:
info : the error code returned by the pack instruction used

Definition at line 326 of file OMKPvmOutgoingMessage.cxx.

References OMASSERT.

Referenced by pack().

00327 {
00328   if (info < 0 )
00329   {
00330     cerr<<"PvmOutgoingMessage::checkForPackErrors ERROR";
00331     switch ( info ) 
00332     {
00333     case PvmNoMem:
00334       cerr<<"Malloc has failed. Message buffer size has exceeded the available memory on this host.";
00335       break;
00336     case PvmNoBuf:
00337       cerr<<"There is no active send buffer to pack into. Try calling pvm_initsend before packing message.";
00338       break;
00339     default:
00340       cerr<<"unexpected error: ";
00341     }
00342     cerr<<endl;   
00343     OMASSERT( false ) ;
00344   }
00345 }

void PvmOutgoingMessage::checkForSendErrors ( int  info  )  [protected, virtual]

make sure sending didn't return any error

Parameters:
info : the error code returned by the send instruction used

Definition at line 302 of file OMKPvmOutgoingMessage.cxx.

References OMASSERT.

Referenced by OMK::PvmUnicastMessage::send(), and OMK::PvmMulticastMessage::send().

00303 {
00304   if ( info < 0 )
00305   {
00306     cerr<<"PvmOutgoingMessage::checkForSendErrors ERROR";
00307     switch ( info ) 
00308     {
00309     case PvmSysErr:
00310       cerr<<"pvmd not responding";
00311       break;
00312     case PvmBadParam:
00313       cerr<<"giving an invalid tid or a msgtag.";
00314       break;
00315     case PvmNoBuf:
00316       cerr<<"There is no active send buffer to pack into. Try calling pvm_initsend before sending.";
00317       break;
00318     default:
00319       cerr<<"unexpected error: ";
00320     }
00321     cerr<<endl;   
00322     OMASSERT( false ) ;
00323   } 
00324 }

void PvmOutgoingMessage::checkForChangedBuffer ( int  info,
int  lineNumber,
char *  file 
) [protected, virtual]

make sure changing active send buffer didn't return any error

Parameters:
info : the error code returned by the send instruction used

Definition at line 277 of file OMKPvmOutgoingMessage.cxx.

References OMASSERT.

Referenced by reinitAndRevertPvmContext(), and OMK::PvmUnicastMessage::send().

00278 {
00279   if ( info < 0 )
00280   {
00281     cerr<<"PvmOutgoingMessage::checkForChangedBuffer line "<<lineNumber<<" of "<<file<<" ";
00282     switch ( info ) 
00283     {
00284     case PvmSysErr:
00285       cerr<<"pvmd not responding";
00286       break;
00287     case PvmBadParam:
00288       cerr<<"giving an invalid bufid.";
00289       break;
00290     case PvmNoSuchBuf:
00291       cerr<<"Switching to a nonexistent message buffer.";
00292       break;
00293     default:
00294       cerr<<"unexpected error: ";
00295     }
00296     cerr<<endl;   
00297     OMASSERT( false ) ;
00298   } 
00299 }


Member Data Documentation

bool OMK::PvmOutgoingMessage::_timeStamped [protected]

make sure the message has been timestamped and is not empty

Definition at line 152 of file OMKPvmOutgoingMessage.h.

Referenced by insertTimeStamp(), isTimeStamped(), reinitAndRevertPvmContext(), and OMK::PvmUnicastMessage::send().

Date OMK::PvmOutgoingMessage::_timestamp [protected]

the timestamp of the message

Definition at line 155 of file OMKPvmOutgoingMessage.h.

Referenced by getMessageDate(), and insertTimeStamp().


logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007