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

PsnPvmOutgoingMessage Class Reference

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

#include <PsnPvmOutgoingMessage.h>

Inheritance diagram for PsnPvmOutgoingMessage:

Inheritance graph
[legend]
Collaboration diagram for PsnPvmOutgoingMessage:

Collaboration graph
[legend]
List of all members.

Public Methods

virtual ~PsnPvmOutgoingMessage ()
 Destructor.

 PsnPvmOutgoingMessage ()
 default constructor for an outgoing message

virtual const PsDategetMessageDate () const
 The timestamp of the outgoing message.

virtual void send (PsnPvmMessage::MessageTag tag)=0
 send all previously packed data and reinitiliase the send buffer

virtual void insertTimeStamp (const PsDate &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 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


Protected Methods

virtual void reinitAndRevertPvmContext (int oldbuf)
 prepare the outgoing message for new data, and revert the pvm context

void checkForPackErrors (int info)
 make sure the packing didn't return any error

void checkForSendErrors (int info)
 make sure sending didn't return any error

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

PsDate _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 PsnPvmOutgoingMessage.h.


Constructor & Destructor Documentation

PsnPvmOutgoingMessage::~PsnPvmOutgoingMessage   [virtual]
 

Destructor.

Definition at line 192 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer.

00193 {
00194   pvm_freebuf ( _currentBuffer ) ;
00195 }

PsnPvmOutgoingMessage::PsnPvmOutgoingMessage  
 

default constructor for an outgoing message

Definition at line 176 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and PsnPvmSvm::pvmDataEncoding.

00176                                                : 
00177   PsnPvmMessage(0),
00178   _timeStamped ( false )
00179 {
00180 #ifdef _DEBUGPVMMESS
00181   cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":PsnPvmOutgoingMessage ()"<<endl;
00182 #endif
00183 
00184   _currentBuffer = pvm_mkbuf ( PsnPvmSvm::pvmDataEncoding ) ;
00185 
00186 #ifdef _DEBUGPVMMESS
00187   cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":PsnPvmOutgoingMessage (): new send buffer"<<_currentBuffer<<endl;
00188 #endif
00189 }


Member Function Documentation

void PsnPvmOutgoingMessage::checkForChangedBuffer int    info,
int    lineNumber,
char *    file
[protected]
 

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 256 of file PsnPvmOutgoingMessage.cxx.

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

Referenced by reinitAndRevertPvmContext(), and PsnPvmUnicastMessage::send().

00257 {
00258   if ( info < 0 )
00259     {
00260       cerr<<"PsnPvmOutgoingMessage::checkForChangedBuffer line "<<lineNumber<<" of "<<file<<" ";
00261       switch ( info ) 
00262         {
00263         case PvmSysErr:
00264           cerr<<"pvmd not responding";
00265           break;
00266         case PvmBadParam:
00267           cerr<<"giving an invalid bufid.";
00268            break;
00269         case PvmNoSuchBuf:
00270            cerr<<"Switching to a nonexistent message buffer.";
00271            break;
00272         default:
00273           cerr<<"unexpected error: ";
00274         }
00275       cerr<<endl;         
00276       if ( PsController::warningLevel >= PsController::ExceptionOnWarnings ) 
00277          {            
00278             throw PsPvmException ( info ) ; 
00279          }
00280     } 
00281 }

void PsnPvmOutgoingMessage::checkForPackErrors int    info [protected]
 

make sure the packing didn't return any error

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

Definition at line 311 of file PsnPvmOutgoingMessage.cxx.

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

Referenced by pack().

00312 {
00313    if (info < 0 )
00314      {
00315        cerr<<"PsnPvmOutgoingMessage::checkForPackErrors ERROR";
00316        switch ( info ) 
00317          {
00318          case PvmNoMem:
00319            cerr<<"Malloc has failed. Message buffer size has exceeded the available memory on this host.";
00320            break;
00321          case PvmNoBuf:
00322            cerr<<"There is no active send buffer to pack into. Try calling pvm_initsend before packing message.";
00323            break;
00324          default:
00325            cerr<<"unexpected error: ";
00326          }
00327        cerr<<endl;        
00328        if ( PsController::warningLevel >= PsController::ExceptionOnWarnings ) 
00329           {           
00330              throw PsPvmException ( info ) ; 
00331           }
00332     }
00333 }

void PsnPvmOutgoingMessage::checkForSendErrors int    info [protected]
 

make sure sending didn't return any error

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

Definition at line 284 of file PsnPvmOutgoingMessage.cxx.

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

Referenced by PsnPvmUnicastMessage::send(), and PsnPvmMulticastMessage::send().

00285 {
00286   if ( info < 0 )
00287     {
00288       cerr<<"PsnPvmOutgoingMessage::checkForSendErrors ERROR";
00289       switch ( info ) 
00290         {
00291         case PvmSysErr:
00292           cerr<<"pvmd not responding";
00293           break;
00294         case PvmBadParam:
00295           cerr<<"giving an invalid tid or a msgtag.";
00296            break;
00297         case PvmNoBuf:
00298            cerr<<"There is no active send buffer to pack into. Try calling pvm_initsend before sending.";
00299            break;
00300         default:
00301           cerr<<"unexpected error: ";
00302         }
00303       cerr<<endl;         
00304       if ( PsController::warningLevel >= PsController::ExceptionOnWarnings ) 
00305          {            
00306             throw PsPvmException ( info ) ; 
00307          }
00308     } 
00309 }

const PsDate & PsnPvmOutgoingMessage::getMessageDate   const [virtual]
 

The timestamp of the outgoing message.

Implements PsOutgoingSynchronisationMessage.

Definition at line 9 of file PsnPvmOutgoingMessage.cxx.

References _timestamp, and PsDate.

00010 {
00011    return _timestamp ;
00012 }

void PsnPvmOutgoingMessage::insertTimeStamp const PsDate   date [virtual]
 

insertTimeStamp associate a time stamp to the current message

Definition at line 229 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, _timestamp, _timeStamped, PsnPvmMessage::getSize(), and PsDate.

Referenced by PsnSvm::broadcast(), PsnSvm::createDistributedSimulation(), PsnSvm::disconnectFromDistributedSimulation(), PsnMirrorObjectHandle::registerToReferenceObject(), and PsnMirrorObjectHandle::sendRequestToReferenceObject().

00230 {
00231    
00232 #ifdef _DEBUGPVMMESS
00233    cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":insertTimeStamp ("<<date<<") "<<_currentBuffer
00234        <<" of size "<<getSize()
00235        <<endl;
00236 #endif
00237 
00238    if ( !_timeStamped )
00239       {
00240          *this<<date;
00241          
00242          _timestamp = date ;
00243          
00244          assert ( getSize() == 4 ) ;
00245          
00246          _timeStamped = true ;
00247       }
00248    else
00249       {
00250          if ( date != _timestamp )
00251             cerr<<"WARNING : timestamping at"<<date<<" message with timestamp "<<_timestamp<<endl;
00252          //assert ( date == _timestamp ) ;
00253       }
00254 }

void PsnPvmOutgoingMessage::pack unsigned short *    val,
int    cnt
[virtual]
 

pack an array of unsigned short in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 505 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

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

void PsnPvmOutgoingMessage::pack short *    val,
int    cnt
[virtual]
 

pack an array of short in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 494 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

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

void PsnPvmOutgoingMessage::pack double *    val,
int    cnt
[virtual]
 

pack an array of double in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 482 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

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

void PsnPvmOutgoingMessage::pack float *    val,
int    cnt
[virtual]
 

pack an array of float in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 471 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

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

void PsnPvmOutgoingMessage::pack unsigned int *    val,
int    cnt
[virtual]
 

pack an array of unsigned int in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 460 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

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

void PsnPvmOutgoingMessage::pack int *    val,
int    cnt
[virtual]
 

pack an array of int in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 449 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

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

void PsnPvmOutgoingMessage::pack unsigned long *    val,
int    cnt
[virtual]
 

pack an array of unsigned long in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 438 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

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

void PsnPvmOutgoingMessage::pack long *    val,
int    cnt
[virtual]
 

pack an array of long in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 427 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

00428 {
00429 #ifdef _DEBUGPVMMESS
00430    cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":pack ( long * val, int cnt) "<<val<<endl;
00431 #endif
00432   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00433   int info = pvm_pklong ( val, cnt, 1) ;
00434   checkForPackErrors ( info ) ;
00435   pvm_setsbuf ( oldbuf ) ;
00436 }

void PsnPvmOutgoingMessage::pack const unsigned short *    val,
int    cnt
[virtual]
 

pack an array of unsigned short in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 414 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

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

void PsnPvmOutgoingMessage::pack const short *    val,
int    cnt
[virtual]
 

pack an array of short in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 403 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

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

void PsnPvmOutgoingMessage::pack const double *    val,
int    cnt
[virtual]
 

pack an array of double in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 391 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

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

void PsnPvmOutgoingMessage::pack const float *    val,
int    cnt
[virtual]
 

pack an array of float in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 380 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

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

void PsnPvmOutgoingMessage::pack const unsigned int *    val,
int    cnt
[virtual]
 

pack an array of unsigned int in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 369 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

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

void PsnPvmOutgoingMessage::pack const int *    val,
int    cnt
[virtual]
 

pack an array of int in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 358 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

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

void PsnPvmOutgoingMessage::pack const unsigned long *    val,
int    cnt
[virtual]
 

pack an array of unsigned long in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 347 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

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

void PsnPvmOutgoingMessage::pack const long *    val,
int    cnt
[virtual]
 

pack an array of long in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 336 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

00337 {
00338 #ifdef _DEBUGPVMMESS
00339    cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":pack ( const long * val, int cnt) "<<val<<endl;
00340 #endif
00341   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00342   int info = pvm_pklong ( const_cast<long *>(val), cnt, 1) ;
00343   checkForPackErrors ( info ) ;
00344   pvm_setsbuf ( oldbuf ) ;
00345 }

void PsnPvmOutgoingMessage::pack const string &    val [virtual]
 

pack a string in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 157 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

00158 {
00159 #ifdef _DEBUGPVMMESS
00160    cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":pack (const string & val) "<<val<<endl;
00161 #endif
00162    int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00163    //the string is packed, with the length needed for unpacking
00164    unsigned int strSize =   val.size() + 1 ;
00165    int info = pvm_pkuint (  &strSize, 1, 1 ) ;
00166 
00167    checkForPackErrors ( info ) ;
00168 
00169    info = pvm_pkstr (  const_cast<char *>( val.c_str() ) ) ;
00170    checkForPackErrors ( info ) ;
00171 
00172    pvm_setsbuf ( oldbuf ) ;
00173 }

void PsnPvmOutgoingMessage::pack const char *    val [virtual]
 

pack a C-style string in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 146 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

00147 {
00148 #ifdef _DEBUGPVMMESS
00149    cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":pack (char * val) "<<val<<endl;
00150 #endif
00151    int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00152    int info = pvm_pkstr ( const_cast<char *>( val ) ) ;
00153    checkForPackErrors ( info ) ;
00154    pvm_setsbuf ( oldbuf ) ;
00155 }

void PsnPvmOutgoingMessage::pack char *    val [virtual]
 

pack a C-style string in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 135 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

00136 {
00137 #ifdef _DEBUGPVMMESS
00138    cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":pack (char * val) "<<val<<endl;
00139 #endif
00140    int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00141    int info = pvm_pkstr ( val ) ;
00142    checkForPackErrors ( info ) ;
00143    pvm_setsbuf ( oldbuf ) ;
00144 }

void PsnPvmOutgoingMessage::pack unsigned short    val [virtual]
 

pack an unsigned short in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 122 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

00123 {
00124 #ifdef _DEBUGPVMMESS
00125    cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":pack (unsigned short val) "<<val<<endl;
00126 #endif
00127   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00128   int info = pvm_pkushort (&val, 1, 1) ;
00129   checkForPackErrors ( info ) ;
00130   pvm_setsbuf ( oldbuf ) ;
00131 }

void PsnPvmOutgoingMessage::pack short    val [virtual]
 

pack a short in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 109 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

00110 {
00111 #ifdef _DEBUGPVMMESS
00112    cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":pack (short val) "<<val<<endl;
00113 #endif
00114   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00115   int info = pvm_pkshort (&val, 1, 1) ;
00116   checkForPackErrors ( info ) ;
00117   pvm_setsbuf ( oldbuf ) ;
00118 }

void PsnPvmOutgoingMessage::pack double    val [virtual]
 

pack a double in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 96 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

00097 {
00098 #ifdef _DEBUGPVMMESS
00099    cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":pack (double val) "<<val<<endl;
00100 #endif
00101   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00102   int info = pvm_pkdouble (&val, 1, 1) ;
00103   checkForPackErrors ( info ) ;
00104   pvm_setsbuf ( oldbuf ) ;
00105 }

void PsnPvmOutgoingMessage::pack float    val [virtual]
 

pack a float in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 84 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

00085 {
00086 #ifdef _DEBUGPVMMESS
00087    cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":pack (float val) "<<val<<endl;
00088 #endif
00089   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00090   int info = pvm_pkfloat (&val, 1, 1) ;
00091   checkForPackErrors ( info ) ;
00092   pvm_setsbuf ( oldbuf ) ;
00093 }

void PsnPvmOutgoingMessage::pack unsigned int    val [virtual]
 

pack an unsigned int in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 73 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

00074 {
00075 #ifdef _DEBUGPVMMESS
00076    cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":pack (unsigned int val) "<<val<<endl;
00077 #endif
00078   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00079   int info = pvm_pkuint (&val, 1, 1) ;
00080   checkForPackErrors ( info ) ;
00081   pvm_setsbuf ( oldbuf ) ;
00082 }

void PsnPvmOutgoingMessage::pack int    val [virtual]
 

pack an int in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 61 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

00062 {
00063 #ifdef _DEBUGPVMMESS
00064    cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":pack (int val) "<<val<<endl;
00065 #endif
00066   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00067   int info = pvm_pkint (&val, 1, 1) ;
00068   checkForPackErrors ( info ) ;
00069   pvm_setsbuf ( oldbuf ) ;
00070 }

void PsnPvmOutgoingMessage::pack unsigned long    val [virtual]
 

pack an unsigned long in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 50 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

00051 {
00052 #ifdef _DEBUGPVMMESS
00053    cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":pack (unsigned long val) "<<val<<endl;
00054 #endif
00055   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00056   int info = pvm_pkulong (&val, 1, 1) ;
00057   checkForPackErrors ( info ) ;
00058   pvm_setsbuf ( oldbuf ) ;
00059 }

void PsnPvmOutgoingMessage::pack long    val [virtual]
 

pack a long in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 38 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

00039 {
00040 #ifdef _DEBUGPVMMESS
00041    cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":pack (long val) "<<val<<endl;
00042 #endif
00043   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00044   int info = pvm_pklong (&val, 1, 1) ;
00045   checkForPackErrors ( info ) ;
00046   pvm_setsbuf ( oldbuf ) ;
00047 }

void PsnPvmOutgoingMessage::pack char    val [virtual]
 

pack a char in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 27 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

00028 {
00029 #ifdef _DEBUGPVMMESS
00030    cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":pack (char val) "<<val<<endl;
00031 #endif
00032   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00033   int info = pvm_pkbyte (&val, 1, 1) ;
00034   checkForPackErrors ( info ) ;
00035   pvm_setsbuf ( oldbuf ) ;
00036 }

void PsnPvmOutgoingMessage::pack bool    val [virtual]
 

pack a bool in the message

Implements PsOutgoingSynchronisationMessage.

Definition at line 14 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, and checkForPackErrors().

00015 {
00016 #ifdef _DEBUGPVMMESS
00017    cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":pack (bool val) "<<val<<endl;
00018 #endif
00019   int oldbuf = pvm_setsbuf ( _currentBuffer ) ;
00020   char realVal = val ;
00021   int info = pvm_pkbyte (&realVal, 1, 1) ;
00022   checkForPackErrors ( info ) ;
00023   pvm_setsbuf ( oldbuf ) ;
00024 }

void PsnPvmOutgoingMessage::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 199 of file PsnPvmOutgoingMessage.cxx.

References PsnPvmMessage::_currentBuffer, _timeStamped, checkForChangedBuffer(), PsnPvmSvm::pvmDataEncoding, and PsOutgoingSynchronisationMessage::reinit().

Referenced by PsnPvmUnicastMessage::send(), and PsnPvmMulticastMessage::send().

00200 {
00201   assert (oldbuf != 0 ) ;
00202 #ifdef _DEBUGPVMMESS
00203   cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":reinitAndRevertPvmContext () send buffer "<<_currentBuffer<<endl;
00204 #endif
00205 
00206   // As send has been done, reinitialise everything
00207   PsOutgoingSynchronisationMessage::reinit() ;
00208 
00209   _timeStamped = false ;
00210 
00211   pvm_freebuf ( _currentBuffer ) ;
00212 
00213   _currentBuffer = pvm_mkbuf ( PsnPvmSvm::pvmDataEncoding ) ;
00214 
00215   // remplaced by the prepeceeding lines, because init_send changes the current buffer
00216   // _currentBuffer = pvm_initsend ( PsnPvmSvm::pvmDataEncoding ) ; changes _currentBuffer )
00217   
00218   int info = pvm_setsbuf ( oldbuf ) ;
00219 
00220   checkForChangedBuffer ( info, __LINE__, __FILE__ ) ;
00221 #ifdef _DEBUGPVMMESS
00222   cerr<<"PsnPvmOutgoingMessage:"<<(void *)this<<":new send buffer "<<_currentBuffer<<endl;
00223 #endif
00224 }

virtual void PsnPvmOutgoingMessage::send PsnPvmMessage::MessageTag    tag [pure virtual]
 

send all previously packed data and reinitiliase the send buffer

Implemented in PsnPvmMulticastMessage, and PsnPvmUnicastMessage.

Referenced by PsnSvm::createDistributedSimulation(), and PsnPvmSvmLink::send().


Member Data Documentation

PsDate PsnPvmOutgoingMessage::_timestamp [protected]
 

the timestamp of the message

Definition at line 148 of file PsnPvmOutgoingMessage.h.

Referenced by getMessageDate(), and insertTimeStamp().

bool PsnPvmOutgoingMessage::_timeStamped [protected]
 

make sure the message has been timestamped and is not empty

Definition at line 145 of file PsnPvmOutgoingMessage.h.

Referenced by insertTimeStamp(), reinitAndRevertPvmContext(), and PsnPvmUnicastMessage::send().


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

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

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