#include <PsnMirrorObjectHandle.h>
Inheritance diagram for PsnMirrorObjectHandle:


Public Methods | |
| PsnMirrorObjectHandle (PsSimulatedObject &objetSimul) | |
| constructor | |
| virtual | ~PsnMirrorObjectHandle () |
| destructor | |
| void | registerToReferenceObject () |
| Register the mirror to the reference object for regular updates of outputs. | |
| void | cancelRegistrationToReferenceObject () |
| cancel registration of the mirror object to the reference object | |
| virtual void | insertInStream (ostream &=cout) const |
| should be obsoleted | |
| virtual void | extract (istream &=cin) |
| should be obsoleted | |
| virtual void | unpack (PsIncomingSynchronisationMessage &in) |
| unpack update information packed in the incoming message by the reference object | |
| virtual void | receiveEvent (const PsEvent &event) |
| implement receive event so that the event is transfered to the reference object | |
| virtual void | receiveEvent (PsEvent *event) |
| implement receive event so that the event is transfered to the reference object | |
| virtual void | sendEventsForSignal (PsEvent &event, const PsEventIdentifier &sigId) |
| send events for a signal emitted by the reference object. | |
| virtual bool | receiveRegistrationForSignal (const PsEventIdentifier &sigId, const PsName ®istrant, const PsEventIdentifier &eventId) |
| receive the registration for signal sigId by registrant, and forward it to the reference object. | |
| virtual bool | cancelRegistrationForSignal (const PsEventIdentifier &sigId, const PsName ®istrant) |
| cancel the registration made by registrant for sigId | |
Protected Methods | |
| virtual void | attributeRead () |
| called when an attribute is read | |
| void | sendRequestToReferenceObject (PsnRequestType typeMess) |
| send a request or an event to the reference object | |
Protected Attributes | |
| bool | _registered |
| boolean indicating if the mirror is presently registered to the referential | |
| PsnSvmLink * | _linkToReferencesProcess |
| keep a reference to the link to the process of the reference object | |
| PsDate | _dateOfLastUse |
| date of the last time attributes of the objects were positively tested for use | |
Definition at line 44 of file PsnMirrorObjectHandle.h.
|
|
constructor
Definition at line 29 of file PsnMirrorObjectHandle.cxx. References _linkToReferencesProcess, PsSimulatedObject::getController(), PsSimulatedObject::getObjectDescriptor(), PsObjectDescriptor::getProcess(), and PsnObjectHandle::getSimulatedObject().
00029 : 00030 PsnObjectHandle (objetSimul), 00031 _dateOfLastUse ( objetSimul.getController().getSimulatedDate() ), 00032 _registered ( false ) 00033 { 00034 PsName processOfReferenceObject = getSimulatedObject().getObjectDescriptor ().getProcess () ; 00035 00036 _linkToReferencesProcess = dynamic_cast<PsPvmController &>(getSimulatedObject().getController()).getDistributedVirtualMachine()->getLinkToProcessNamed (processOfReferenceObject) ; 00037 00038 assert ( _linkToReferencesProcess != NULL ) ; 00039 } |
|
|
destructor
Definition at line 43 of file PsnMirrorObjectHandle.cxx.
00043 {
00044
00045 }
|
|
|
called when an attribute is read
Reimplemented from PsnObjectHandle. Definition at line 47 of file PsnMirrorObjectHandle.cxx. References _registered, PsnObjectHandle::attributeRead(), and registerToReferenceObject().
00048 {
00049 PsnObjectHandle::attributeRead() ;
00050 if ( ! _registered )
00051 {
00052 //cerr<<"PsnMirrorObjectHandle::attributeRead : new registration needed"<<endl;
00053 registerToReferenceObject () ;
00054 }
00055 }
|
|
||||||||||||
|
cancel the registration made by registrant for sigId
Implements PsnObjectHandle. Definition at line 193 of file PsnMirrorObjectHandle.cxx. References _linkToReferencesProcess, CancelRegistrationForSignal, PsObjectDescriptor::getName(), PsSimulatedObject::getObjectDescriptor(), PsnSvmLink::getOutgoingBuffer(), and PsnObjectHandle::getSimulatedObject().
00195 {
00196 _linkToReferencesProcess->getOutgoingBuffer () << getSimulatedObject().getObjectDescriptor().getName () << " "
00197 << PsString ("EV")
00198 << (int) CancelRegistrationForSignal
00199 << sigId
00200 << registrant ;
00201 return true ;
00202 }
|
|
|
cancel registration of the mirror object to the reference object
Definition at line 88 of file PsnMirrorObjectHandle.cxx. References _registered, CancelRegistration, and sendRequestToReferenceObject(). Referenced by unpack().
00089 {
00090 #ifdef _DEBUGPVMSYNCHRO
00091 cout << "PsnMirrorObjectHandle::cancelRegistrationToReferenceObject" << endl ;
00092 #endif
00093 sendRequestToReferenceObject (CancelRegistration) ;
00094 _registered = false ;
00095 }
|
|
|
should be obsoleted
Implements PsFlowable. Definition at line 145 of file PsnMirrorObjectHandle.cxx.
00146 {
00147 assert (false) ; //use of extract deprecated
00148 }
|
|
|
should be obsoleted
Implements PsFlowable. Definition at line 99 of file PsnMirrorObjectHandle.cxx.
00099 {
00100 out << "PsnMirrorObjectHandle::insertInStream nothing to insert" << endl ;
00101 }
|
|
|
implement receive event so that the event is transfered to the reference object
Implements PsnObjectHandle. Reimplemented in PsnMomeMirrorObjectHandle. Definition at line 163 of file PsnMirrorObjectHandle.cxx. References _linkToReferencesProcess, EventReceived, PsObjectDescriptor::getName(), PsSimulatedObject::getObjectDescriptor(), PsnSvmLink::getOutgoingBuffer(), and PsnObjectHandle::getSimulatedObject().
00164 {
00165 #ifdef _DEBUGPVMMESS
00166 cerr<<"PsnMirrorObjectHandle::receiveEvent (PsEvent * event) "<<endl;
00167 #endif
00168
00169 _linkToReferencesProcess->getOutgoingBuffer () << getSimulatedObject().getObjectDescriptor ().getName ()
00170 << EventReceived
00171 << *event ;
00172
00173 delete event ;
00174 }
|
|
|
implement receive event so that the event is transfered to the reference object
Implements PsnObjectHandle. Reimplemented in PsnMomeMirrorObjectHandle. Definition at line 151 of file PsnMirrorObjectHandle.cxx. References _linkToReferencesProcess, EventReceived, PsObjectDescriptor::getName(), PsSimulatedObject::getObjectDescriptor(), PsnSvmLink::getOutgoingBuffer(), and PsnObjectHandle::getSimulatedObject().
00152 {
00153 #ifdef _DEBUGPVMMESS
00154 cerr<<"PsnMirrorObjectHandle::receiveEvent (const PsEvent & event) "<<endl;
00155 #endif
00156 _linkToReferencesProcess->getOutgoingBuffer () << getSimulatedObject().getObjectDescriptor ().getName ()
00157 << EventReceived
00158 << event ;
00159 }
|
|
||||||||||||||||
|
receive the registration for signal sigId by registrant, and forward it to the reference object.
Implements PsnObjectHandle. Definition at line 179 of file PsnMirrorObjectHandle.cxx. References _linkToReferencesProcess, PsObjectDescriptor::getName(), PsSimulatedObject::getObjectDescriptor(), PsnSvmLink::getOutgoingBuffer(), PsnObjectHandle::getSimulatedObject(), and RegisterForSignal.
00182 {
00183
00184 _linkToReferencesProcess->getOutgoingBuffer ()<< getSimulatedObject().getObjectDescriptor().getName ()
00185 << PsString ("EV")
00186 << (int) RegisterForSignal
00187 << sigId
00188 << registrant
00189 << eventId ;
00190 return true;
00191 }
|
|
|
Register the mirror to the reference object for regular updates of outputs.
Definition at line 60 of file PsnMirrorObjectHandle.cxx. References _linkToReferencesProcess, PsnObjectHandle::_myObject, _registered, PsSimulatedObject::getController(), PsSimulatedObject::getName(), PsPvmController::getProcessName(), PsnObjectHandle::getSimulatedObject(), PsnSvmLink::getTID(), PsnPvmMessage::InitialValuesForMirror, PsnPvmOutgoingMessage::insertTimeStamp(), PsnPvmMessage::MirrorNeedsInitialValues, PsName::pack(), Registration, PsnPvmUnicastMessage::send(), sendRequestToReferenceObject(), and PsPvmController::waitForAnswerToBlockingRequest(). Referenced by attributeRead().
00061 {
00062 // should only be called once by the creator of the mirror
00063 assert ( _registered == false ) ;
00064 #ifdef _DEBUGPVMSYNCHRO
00065 cerr << "PsnMirrorObjectHandle::registerToReferenceObject: mirror registering to referential" << endl ;
00066 #endif
00067 sendRequestToReferenceObject (Registration) ;
00068 _registered = true ;
00069
00070 // until SGI Perfomer becomes compatible with exception handling, request initial values from the referential immediatly, and wait for answer
00071 PsnPvmUnicastMessage * urgentRequest = new PsnPvmUnicastMessage ( _linkToReferencesProcess->getTID() ) ;
00072
00073 urgentRequest->insertTimeStamp( getSimulatedObject().getController().getSimulatedDate() ) ;
00074
00075 getSimulatedObject().getName().pack ( *urgentRequest ) ;
00076
00077 PsPvmController & realController = dynamic_cast<PsPvmController & > ( _myObject.getController() ) ;
00078
00079 realController.getProcessName ().pack ( *urgentRequest ) ;
00080
00081 urgentRequest->send ( PsnPvmMessage::MirrorNeedsInitialValues ) ;
00082
00083 realController.waitForAnswerToBlockingRequest(PsnPvmMessage::InitialValuesForMirror) ;
00084 }
|
|
||||||||||||
|
send events for a signal emitted by the reference object. shouldn't be called, because registration for signals are forwarded to the reference object wich fires them and sends the corresponding event to a miror of the registrant. This algorithm could be re-written to send the signam to the miror which would then fire the signals locally. Implements PsnObjectHandle. Definition at line 204 of file PsnMirrorObjectHandle.cxx.
00205 {
00206 assert ( false ) ;
00207 }
|
|
|
send a request or an event to the reference object
Definition at line 209 of file PsnMirrorObjectHandle.cxx. References _linkToReferencesProcess, PsnObjectHandle::_myObject, CancelRegistration, PsSimulatedObject::getController(), PsSimulatedObject::getName(), PsSimulatedObject::getObjectDescriptor(), PsnSvmLink::getOutgoingBuffer(), PsSimulatedObject::getPeriod(), PsObjectDescriptor::getProcess(), PsController::getSimulatedDate(), PsnPvmOutgoingMessage::insertTimeStamp(), and PsnRequestType. Referenced by cancelRegistrationToReferenceObject(), and registerToReferenceObject().
00210 {
00211 //cerr<<"PsnMirrorObjectHandle::sendRequestToReferenceObject("<<typeMess<<")"<<endl;
00212 PsnPvmOutgoingMessage * sendBuffer = & _linkToReferencesProcess->getOutgoingBuffer () ;
00213
00214 // as no garanty can be made on the validity of the buffer, timestamp it
00215 if ( typeMess == CancelRegistration )
00216 {
00217 sendBuffer->insertTimeStamp ( _myObject.getController().getSimulatedDate() + _myObject.getController().getPeriod()*1000 ) ;
00218 }
00219 // send the name of the object
00220 *sendBuffer << _myObject.getName () ;
00221
00222 // send the request
00223 *sendBuffer << (int)typeMess ;
00224
00225 #ifdef _DEBGUPVMMESS
00226 cerr<<"PsnMirrorObjectHandle::sendRequestToReferenceObject adding "<<_myObject.getController ().getObjectDescriptor().getProcess ()<<" to the synchronisation message for object "<<_myObject.getName()<<endl;
00227 #endif
00228 // send the requesting process
00229 *sendBuffer << _myObject.getController ().getObjectDescriptor().getProcess () ;
00230 }
|
|
|
unpack update information packed in the incoming message by the reference object
Reimplemented from PsFlowable. Definition at line 104 of file PsnMirrorObjectHandle.cxx. References _dateOfLastUse, PsnObjectHandle::_myObject, cancelRegistrationToReferenceObject(), PsnObjectHandle::getAttributeRead(), PsSimulatedObject::getController(), PsController::getCyclePeriod(), PsController::getSimulatedDate(), InitialValuesMessage, PsnRequestType, SynchronisationMessage, PsSimulatedObject::unpack(), and PsSimulatedObject::unpackAllValues().
00105 {
00106 PsnRequestType typeMess ;
00107 int messageType ;
00108
00109 //make sure the mirror is still needed
00110 if ( getAttributeRead() )
00111 {
00112 _dateOfLastUse = _myObject.getController().getSimulatedDate() ;
00113 }
00114 else
00115 {
00116 if ( _myObject.getController().getSimulatedDate() > _dateOfLastUse + 2 * _myObject.getController().getCyclePeriod() )
00117 {
00118 cancelRegistrationToReferenceObject () ;
00119 }
00120 }
00121
00122 in >> messageType ;
00123 typeMess = static_cast <PsnRequestType> (messageType) ;
00124
00125 switch ( typeMess )
00126 {
00127 case SynchronisationMessage:
00128 {
00129 _myObject.unpack ( in ) ;
00130 }
00131 break;
00132 case InitialValuesMessage:
00133 {
00134 _myObject.unpackAllValues ( in ) ;
00135 }
00136 break;
00137 default:
00138 cerr<<"PsnMirrorObjectHandle::unpack: WARNING: uninterpreted message"<<endl;
00139 break;
00140 }
00141 }
|
|
|
date of the last time attributes of the objects were positively tested for use
Definition at line 118 of file PsnMirrorObjectHandle.h. Referenced by unpack(). |
|
|
keep a reference to the link to the process of the reference object
Definition at line 115 of file PsnMirrorObjectHandle.h. Referenced by cancelRegistrationForSignal(), PsnMirrorObjectHandle(), receiveEvent(), receiveRegistrationForSignal(), registerToReferenceObject(), and sendRequestToReferenceObject(). |
|
|
boolean indicating if the mirror is presently registered to the referential
Definition at line 109 of file PsnMirrorObjectHandle.h. Referenced by attributeRead(), cancelRegistrationToReferenceObject(), and registerToReferenceObject(). |
| Documentation generated on Mon Nov 25 15:26:09 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |