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

PsnPvmSvmLink Class Reference

a Pvm communication chanel. More...

#include <PsnPvmSvmLink.h>

Inheritance diagram for PsnPvmSvmLink:

Inheritance graph
[legend]
Collaboration diagram for PsnPvmSvmLink:

Collaboration graph
[legend]
List of all members.

Public Methods

 PsnPvmSvmLink (int td)
 Constructor.

virtual ~PsnPvmSvmLink ()
 Destructor.

virtual void send (PsnPvmOutgoingMessage &m, PsnPvmMessage::MessageTag tag)
 send a specific outgoing message along the link

PsnPvmIncomingMessagewaitForMessage (PsnPvmMessage::MessageTag tag)
 wait for a message comming along the link and receive it

PsnPvmIncomingMessagetestForMessage (PsnPvmMessage::MessageTag tag)
 testForMessage.

virtual PsnPvmMessage::MessageTag testForAnyMessage (PsnPvmIncomingMessage &receiveBuffer)
 test for any message sent to this site from a specified site.

virtual void unpack (PsIncomingSynchronisationMessage &)
 unpack from a message

virtual void pack (PsOutgoingSynchronisationMessage &) const
 pack in a message

virtual PsnPvmOutgoingMessagegetOutgoingBuffer ()
 get the outgoing buffer which will be sent at the next call of sendOutgoingBuffer

void sendOutgoingBuffer (PsnPvmMessage::MessageTag tag)
 send the outgoingBuffer

int getTID ()
 get the site id of the process at the other end of the link

void printDebuggingInformation ()
 printDebugging information


Protected Attributes

PsnPvmUnicastMessage _outgoingBuffer
 standard outgoing buffer for that link

PsnPvmIncomingMessage _incomingBuffer
 standard incomming buffer for that link

int _distantSiteId
 distant workstation site id for that link


Detailed Description

a Pvm communication chanel.

Author:
Siames
Version:
2.0

Definition at line 28 of file PsnPvmSvmLink.h.


Constructor & Destructor Documentation

PsnPvmSvmLink::PsnPvmSvmLink int    td
 

Constructor.

Definition at line 30 of file PsnPvmSvmLink.cxx.

00030                                     : 
00031   PsnSvmLink(),
00032   _outgoingBuffer ( td ),
00033   _distantSiteId ( td ) 
00034 {
00035 }

PsnPvmSvmLink::~PsnPvmSvmLink   [virtual]
 

Destructor.

Definition at line 39 of file PsnPvmSvmLink.cxx.

00040 {
00041 }


Member Function Documentation

PsnPvmOutgoingMessage & PsnPvmSvmLink::getOutgoingBuffer   [virtual]
 

get the outgoing buffer which will be sent at the next call of sendOutgoingBuffer

Implements PsnSvmLink.

Definition at line 195 of file PsnPvmSvmLink.cxx.

References _outgoingBuffer.

00196 {
00197    return _outgoingBuffer ;
00198 }

int PsnPvmSvmLink::getTID   [virtual]
 

get the site id of the process at the other end of the link

Implements PsnSvmLink.

Definition at line 169 of file PsnPvmSvmLink.cxx.

References _distantSiteId.

00170 {
00171   return _distantSiteId ;
00172 }

void PsnPvmSvmLink::pack PsOutgoingSynchronisationMessage   const [virtual]
 

pack in a message

Implements PsPackable.

Definition at line 174 of file PsnPvmSvmLink.cxx.

References _distantSiteId.

00175 {
00176    out << _distantSiteId ;
00177 }

void PsnPvmSvmLink::printDebuggingInformation   [virtual]
 

printDebugging information

Implements PsnSvmLink.

Definition at line 162 of file PsnPvmSvmLink.cxx.

References _distantSiteId.

00163 {
00164    cerr << "PsnPvmSvmLink:"<<this<<":printDebuggingInformation:_distantSiteIdant : " << hex << _distantSiteId << dec << endl ;
00165 }

void PsnPvmSvmLink::send PsnPvmOutgoingMessage   m,
PsnPvmMessage::MessageTag    tag
[virtual]
 

send a specific outgoing message along the link

Parameters:
m the message to send
the tag associated to the message

Implements PsnSvmLink.

Definition at line 45 of file PsnPvmSvmLink.cxx.

References PsnPvmMessage::MessageTag, and PsnPvmOutgoingMessage::send().

00046 {
00047    m.send ( tag ) ;
00048 }

void PsnPvmSvmLink::sendOutgoingBuffer PsnPvmMessage::MessageTag    tag [virtual]
 

send the outgoingBuffer

Parameters:
tag the tag to send the outgoing message with

Implements PsnSvmLink.

Definition at line 52 of file PsnPvmSvmLink.cxx.

References _outgoingBuffer, PsnPvmMessage::MessageTag, and PsnPvmUnicastMessage::send().

00053 {
00054 #ifdef _DEBUGPVMMESS
00055   cerr << "PsnPvmSvmLink::sendOutgoingBuffer ("<< force << "," << tag <<") "<<endl;
00056 #endif
00057   _outgoingBuffer.send ( tag ) ;
00058 }

PsnPvmMessage::MessageTag PsnPvmSvmLink::testForAnyMessage PsnPvmIncomingMessage   receiveBuffer [virtual]
 

test for any message sent to this site from a specified site.

This call is non blocking

Parameters:
receiveBuffer : the user buffer to use to receive any message the tag of the received message

Implements PsnSvmLink.

Definition at line 97 of file PsnPvmSvmLink.cxx.

References _distantSiteId, PsController::FatalWarnings, PsnPvmIncomingMessage::initialise(), PsnPvmMessage::MessageTag, and PsController::warningLevel.

00098 {
00099   PsnPvmMessage::MessageTag result ;
00100   
00101   int bufid = pvm_nrecv  ( _distantSiteId, -1 ) ; //test if any message has arrived from distantDiteId
00102 
00103   if ( bufid < 0 ) 
00104     {
00105       cerr<<"PsnSvm::waitForAnyRequests ERROR ";
00106       switch (bufid)
00107         {
00108         case PvmBadParam:
00109           cerr<<"giving an invalid tid value, or msgtag < -1";
00110           break;
00111         case PvmSysErr:
00112           cerr<<"pvmd not responding";
00113           break;
00114         default:
00115           cerr<<"unexpected error";
00116           if (PsController::warningLevel >=  PsController::FatalWarnings) 
00117             {         
00118               exit (2) ;
00119             }
00120         }
00121       cerr<<endl;
00122     }
00123 
00124   if ( bufid != 0 )
00125      {
00126         int bytes ;
00127         int senderSiteId ;
00128         int msgtag ;
00129         int info = pvm_bufinfo( bufid, &bytes , &msgtag , &senderSiteId  ) ;
00130         
00131         result = static_cast<PsnPvmMessage::MessageTag>(msgtag) ;
00132         
00133         if ( info < 0 ) 
00134            {
00135               cerr<<"PsnSvm::waitForAnyRequests ERROR in pvm_bufinfo ";
00136               switch (info)
00137                  {
00138                  case PvmBadParam:
00139                     cerr<<"invalid argument";
00140                     break;
00141                  case PvmNoSuchBuf:
00142                     cerr<<"specified buffer does not exist";
00143                     break;
00144                  default:
00145                     cerr<<"unexpected error";
00146                     if (PsController::warningLevel >=  PsController::FatalWarnings) 
00147                        {              
00148                           exit (2) ;
00149                        }
00150                  }
00151               cerr<<endl;
00152            }
00153      }
00154 
00155   receiveBuffer.initialise ( bufid ) ;
00156   
00157   return result ;
00158 }

PsnPvmIncomingMessage * PsnPvmSvmLink::testForMessage PsnPvmMessage::MessageTag    tag [virtual]
 

testForMessage.

Test to see if a message has arrived and receive it

Parameters:
tag the tag of the message to wait for
Returns:
NULL if no message was present, a incoming buffer with the message otherwise. This incoming buffer should not be deleted

Implements PsnSvmLink.

Definition at line 77 of file PsnPvmSvmLink.cxx.

References _distantSiteId, _incomingBuffer, PsnPvmIncomingMessage::initialise(), and PsnPvmMessage::MessageTag.

00078 {
00079 #ifdef _DEBUGPVMMESS
00080          cerr << "PsnPvmSvmLink::testForMessage: tag  " <<tag<<endl;
00081 #endif        
00082 
00083    int res = pvm_nrecv (_distantSiteId, tag) ;
00084 
00085    if (res >= 0) 
00086       { 
00087          _incomingBuffer.initialise ( res );
00088          return &_incomingBuffer ;
00089       } 
00090    else 
00091       {
00092          return NULL ;
00093       }
00094 }

void PsnPvmSvmLink::unpack PsIncomingSynchronisationMessage   [virtual]
 

unpack from a message

Implements PsPackable.

Definition at line 180 of file PsnPvmSvmLink.cxx.

References _distantSiteId, _outgoingBuffer, and PsnPvmUnicastMessage::setDistantSiteId().

00181 {
00182 #ifdef _DEBUGPVMMESS
00183   cerr<<"PsnPvmSvmLink::unpack: ";
00184 #endif
00185    in >> _distantSiteId ;
00186 
00187    _outgoingBuffer.setDistantSiteId ( _distantSiteId ) ;
00188 #ifdef _DEBUGPVMMESS
00189    cerr<<"distant site Id: "<<_distantSiteId<<endl;
00190 #endif
00191 }

PsnPvmIncomingMessage & PsnPvmSvmLink::waitForMessage PsnPvmMessage::MessageTag    tag [virtual]
 

wait for a message comming along the link and receive it

Parameters:
tag the tag of the message to wait for

Implements PsnSvmLink.

Definition at line 62 of file PsnPvmSvmLink.cxx.

References _distantSiteId, _incomingBuffer, PsnPvmIncomingMessage::initialise(), and PsnPvmMessage::MessageTag.

00063 {
00064    // attente en reception
00065    int res = pvm_recv (_distantSiteId, tag) ;
00066    
00067    _incomingBuffer.initialise ( res ) ;
00068 #ifdef _DEBUGPVMMESS
00069    cerr << "waitForMessage : On recoit un message  tag: " << tag << " de " << hex << _distantSiteId << dec << endl;
00070 #endif
00071    // On renvoie le message
00072    return _incomingBuffer ;
00073 }


Member Data Documentation

int PsnPvmSvmLink::_distantSiteId [protected]
 

distant workstation site id for that link

Definition at line 98 of file PsnPvmSvmLink.h.

Referenced by getTID(), pack(), printDebuggingInformation(), testForAnyMessage(), testForMessage(), unpack(), and waitForMessage().

PsnPvmIncomingMessage PsnPvmSvmLink::_incomingBuffer [protected]
 

standard incomming buffer for that link

Definition at line 95 of file PsnPvmSvmLink.h.

Referenced by testForMessage(), and waitForMessage().

PsnPvmUnicastMessage PsnPvmSvmLink::_outgoingBuffer [protected]
 

standard outgoing buffer for that link

Definition at line 92 of file PsnPvmSvmLink.h.

Referenced by getOutgoingBuffer(), sendOutgoingBuffer(), and unpack().


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