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

PsnPvmDuplicatedObjectHandle Class Reference

An object handle for duplicated objects. More...

#include <PsnPvmDuplicatedObjectHandle.h>

Inheritance diagram for PsnPvmDuplicatedObjectHandle:

Inheritance graph
[legend]
Collaboration diagram for PsnPvmDuplicatedObjectHandle:

Collaboration graph
[legend]
List of all members.

Public Methods

virtual ~PsnPvmDuplicatedObjectHandle ()
 destructor

 PsnPvmDuplicatedObjectHandle (PsSimulatedObject &, PsController &)
 constructor

virtual void addProcessOfDuplicate (const PsnProcess *process)
 add a process to the data structure storing the location of copies

virtual void unpack (PsIncomingSynchronisationMessage &)
 unpack from a pvm message


Protected Methods

virtual void broadcastEvent (const PsEvent &event)
 broadcast event


Protected Attributes

list< const PsnProcess * > _processesOfDuplicates
 The data structure used to store the processes to broadcast information to.


Detailed Description

An object handle for duplicated objects.

This object handle is a reference object handle for object who have more than one reference object ( duplicated objects and the controller). This implementation id concerned with the propagation of events to the other reference objects.

Author:
David Margery
Version:
1.0 (warning, not implementing dynamic discovery of sites the object is duplicated on. All sites are supposed)

Definition at line 30 of file PsnPvmDuplicatedObjectHandle.h.


Constructor & Destructor Documentation

PsnPvmDuplicatedObjectHandle::~PsnPvmDuplicatedObjectHandle   [virtual]
 

destructor

Definition at line 15 of file PsnPvmDuplicatedObjectHandle.cxx.

00016 {
00017 
00018 }

PsnPvmDuplicatedObjectHandle::PsnPvmDuplicatedObjectHandle PsSimulatedObject  ,
PsController  
 

constructor

Definition at line 7 of file PsnPvmDuplicatedObjectHandle.cxx.

00007                                                                                                           : 
00008    PsnDuplicatedObjectHandle ( obj, ctrl )
00009 {
00010    
00011 }


Member Function Documentation

void PsnPvmDuplicatedObjectHandle::addProcessOfDuplicate const PsnProcess   process [virtual]
 

add a process to the data structure storing the location of copies

Implements PsnDuplicatedObjectHandle.

Definition at line 71 of file PsnPvmDuplicatedObjectHandle.cxx.

References _processesOfDuplicates, and list< const PsnProcess * >::push_back().

00072 {
00073    _processesOfDuplicates.push_back( process ) ;
00074 }

void PsnPvmDuplicatedObjectHandle::broadcastEvent const PsEvent   event [protected, virtual]
 

broadcast event

Implements PsnDuplicatedObjectHandle.

Definition at line 22 of file PsnPvmDuplicatedObjectHandle.cxx.

References _processesOfDuplicates, list< const PsnProcess * >::begin(), PsEvent::clone(), list< const PsnProcess * >::end(), EventReceived, PsSimulatedObject::getController(), PsSimulatedObject::getName(), PsSimulatedObject::getObjectDescriptor(), PsObjectDescriptor::getProcess(), PsnObjectHandle::getSimulatedObject(), and PsnReferenceObjectHandle::receiveEvent().

00023 {
00024    PsnPvmOutgoingMessage * outgoingMessage ;
00025    //send the event to all copies of oneself
00026    for (list<const PsnProcess *>::const_iterator i = _processesOfDuplicates.begin() ;
00027         i != _processesOfDuplicates.end () ;
00028         ++i) 
00029       {
00030          if (getSimulatedObject().getController().getObjectDescriptor().getProcess() != (*i)->getProcessName() )
00031             {
00032                //cerr<<"sending "<<event<<" to "<<getSimulatedObject().getName ()<<" of process "<<(*i)->getProcessName()<<endl;
00033 #ifdef _DEBUGPVMMESS
00034                cerr<<"PsnPvmDuplicatedObjectHandle::broadcastEvent"<<endl;
00035 #endif
00036                (*i)->getSvmLink ()->getOutgoingBuffer()<< getSimulatedObject().getName ()  
00037                                                        << EventReceived   
00038                                                        << event  ;
00039             }
00040       }
00041    //receive the event oneself
00042    PsnReferenceObjectHandle::receiveEvent ( event.clone() ) ;
00043 }

void PsnPvmDuplicatedObjectHandle::unpack PsIncomingSynchronisationMessage   [virtual]
 

unpack from a pvm message

Reimplemented from PsFlowable.

Definition at line 47 of file PsnPvmDuplicatedObjectHandle.cxx.

References PsEventCreator::createEvent(), EventReceived, PsDate, PsnRequestType, PsnReferenceObjectHandle::receiveEvent(), and PsEvent::unpack().

00048 {
00049    PsnRequestType typeMess ;
00050    int messageType ;
00051 
00052    in >> messageType ;
00053    typeMess = static_cast <PsnRequestType> (messageType) ;
00054 
00055    if ( typeMess == EventReceived )
00056       {
00057          PsEvent * event ;
00058          PsName classToCreate ;
00059          PsEventIdentifier eventId;
00060          PsDate eventDate;
00061          PsName sender, receiver ;
00062          in >> classToCreate >> eventId>> eventDate>>sender>>receiver ;
00063          event = PsEventCreator::createEvent (classToCreate, eventId, eventDate, sender, receiver ) ;
00064          event->unpack ( in ) ;
00065          PsnReferenceObjectHandle::receiveEvent ( event ) ;
00066       }
00067 }


Member Data Documentation

list<const PsnProcess *> PsnPvmDuplicatedObjectHandle::_processesOfDuplicates [protected]
 

The data structure used to store the processes to broadcast information to.

Definition at line 52 of file PsnPvmDuplicatedObjectHandle.h.

Referenced by addProcessOfDuplicate(), and broadcastEvent().


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

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

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