OMK::ObjectHandle Class Reference

An object handle is the data structure used by controllers to access simulated objects. More...

#include <OMKObjectHandle.h>

Inheritance diagram for OMK::ObjectHandle:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ObjectHandle (SimulatedObject &objet)
 the contructor
virtual ~ObjectHandle ()
 destructor
virtual void notifyChangeInControlParameter (OutputNT *)
 receive notification of a change in a control parameter the produced information could be used to synchronize control parameter data only when it's relevent
virtual bool controlParametersChanged (bool keepChanged=false)
 has a least one control parameter changed since last query where keepChanged was false
virtual void receiveEvent (const Event &event)=0
 receive an event a clone of that event will be stored
virtual void receiveEvent (Event *event)=0
 receive an event responsability of deleting the evnt passed as parameter is transfered to the object handle
virtual void registerEventListenerForEvent (EventListener &eventListener, const EventIdentifier &eventId)
 registration of an event listener for the simulation objet
virtual void unregisterEventListener (EventListener &eventListener)
 Unregistration of an event listener for the simulation object.
virtual void sendEventsForSignal (Event &event, const EventIdentifier &sigId)=0
 send events to simulated objects registered for sigId
virtual bool receiveRegistrationForSignal (const EventIdentifier &sigId, const Name &registrant, const EventIdentifier &eventId)=0
 receive the registration for signal sigId by registrant.
virtual bool cancelRegistrationForSignal (const EventIdentifier &sigId, const Name &registrant)=0
 cancel the registration made by registrant for sigId
const SimulatedObjectgetSimulatedObject () const
 get a reference to the encapsulated simulated object
SimulatedObjectgetSimulatedObject ()
 get a reference to the encapsulated simulated object

Protected Member Functions

virtual void attributeRead ()
 called when an attribute is read
virtual bool getAttributeRead (bool keepChanged=false)
 test to see if an attribute was read.

Protected Attributes

SimulatedObject_myObject
 a reference to the encapsulated object
bool _attributeRead
 a boolean indicating if an attribute of the handled object was read since last call to getAttributeRead ( true )
bool _aControlParameterHasChanged
 memorise changes to a control parameter of the controlled object
bool _migrationCase
 CHADI.

Friends

class KernelAttribute

Detailed Description

An object handle is the data structure used by controllers to access simulated objects.

in particular, objects handle comme in two flavors : reference object handles and mirror handles, depending on whether the controller is manipulating a reference object or a miror of a reference object. an object handle, once created, is responsible for the destruction of the correspondong simulated object; after having obtained responsability for this destruction in the constructor.

Definition at line 50 of file OMKObjectHandle.h.


Constructor & Destructor Documentation

ObjectHandle::ObjectHandle ( SimulatedObject objet  ) 

the contructor

Definition at line 24 of file OMKObjectHandle.cpp.

References OMK::ObjectDescriptor::_destroySimulatedObject, _myObject, OMK::SimulatedObject::getObjectDescriptor(), and OMK::SimulatedObject::setObjectHandle().

00024                                                     :
00025    _myObject (objet),
00026    _attributeRead ( false ),
00027    _aControlParameterHasChanged (false),
00028 /*CHADI*/
00029    _migrationCase ( false )
00030 /*End CHADI*/
00031 {
00032    _myObject.setObjectHandle(this) ;
00033    _myObject.getObjectDescriptor()._destroySimulatedObject = false ;
00034 }

ObjectHandle::~ObjectHandle (  )  [virtual]

destructor

CHADI

End CHADI

Definition at line 37 of file OMKObjectHandle.cpp.

References _migrationCase, _myObject, and OMK::SimulatedObject::getController().

00038 {
00039    // don't delete the controller when it deletes it's object handle
00040    if (& _myObject.getController() != &_myObject )
00041       {
00043         if (!_migrationCase)
00044           {
00045             delete &_myObject ;
00046           }
00048         //delete &_myObject ;
00049       }
00050 }


Member Function Documentation

void ObjectHandle::notifyChangeInControlParameter ( OutputNT  )  [virtual]

receive notification of a change in a control parameter the produced information could be used to synchronize control parameter data only when it's relevent

Definition at line 64 of file OMKObjectHandle.cpp.

References _aControlParameterHasChanged.

Referenced by OMK::GenericControlParameter< T, AncestorClass >::realSet().

00065 {
00066    _aControlParameterHasChanged = true;
00067 }

bool ObjectHandle::controlParametersChanged ( bool  keepChanged = false  )  [virtual]

has a least one control parameter changed since last query where keepChanged was false

Parameters:
keepChanged if true, the query doesn't change the state of the object

Definition at line 69 of file OMKObjectHandle.cpp.

References _aControlParameterHasChanged.

Referenced by OMK::SimulatedObject::insertInStream(), and OMK::SimulatedObject::pack().

00070 {
00071    bool result ;
00072    result = _aControlParameterHasChanged ;
00073    _aControlParameterHasChanged = keepChanged && _aControlParameterHasChanged ;
00074    return result;
00075 }

virtual void OMK::ObjectHandle::receiveEvent ( const Event event  )  [pure virtual]

receive an event a clone of that event will be stored

Implemented in OMK::DuplicatedObjectHandle, OMK::LocalObjectHandle, OMK::MirrorObjectHandle, OMK::ReferenceObjectHandle, and OMK::PvmMirrorObjectHandle.

Referenced by OMK::SimulatedObject::sendEvent(), OMK::SignalDispatcher::sendEventsForSignal(), and OMK::SimulatedObject::sendValuedEvent().

virtual void OMK::ObjectHandle::receiveEvent ( Event event  )  [pure virtual]

receive an event responsability of deleting the evnt passed as parameter is transfered to the object handle

Implemented in OMK::DuplicatedObjectHandle, OMK::LocalObjectHandle, OMK::MirrorObjectHandle, OMK::ReferenceObjectHandle, and OMK::PvmMirrorObjectHandle.

void ObjectHandle::registerEventListenerForEvent ( EventListener eventListener,
const EventIdentifier eventId 
) [virtual]

registration of an event listener for the simulation objet

Reimplemented in OMK::ReferenceObjectHandle.

Definition at line 77 of file OMKObjectHandle.cpp.

Referenced by OMK::SimulatedObject::registerEventListenerForEvent().

00079 {
00080   // Do nothing, is only implemented in OMKReferenceObjectHandle
00081 }

void ObjectHandle::unregisterEventListener ( EventListener eventListener  )  [virtual]

Unregistration of an event listener for the simulation object.

Parameters:
eventListener The event listener to unreference.
This method is called, indirectly through the object, in the destructor of the event listener to clear the reference to the listener in the event processing of the object.

Reimplemented in OMK::ReferenceObjectHandle.

Definition at line 82 of file OMKObjectHandle.cpp.

Referenced by OMK::SimulatedObject::unregisterEventListener().

00083 {
00084   // Do nothing, is only implemented in OMKReferenceObjectHandle
00085 }

virtual void OMK::ObjectHandle::sendEventsForSignal ( Event event,
const EventIdentifier sigId 
) [pure virtual]

send events to simulated objects registered for sigId

Parameters:
event the prototype of the event to send : only receiver and eventId is changed for each simulated object receiving the event
sigId the signal to take into account

Implemented in OMK::MirrorObjectHandle, OMK::ReferenceObjectHandle, and OMK::PvmMirrorObjectHandle.

Referenced by OMK::SimulatedObject::fireSignal(), and OMK::SimulatedObject::fireValuedSignal().

virtual bool OMK::ObjectHandle::receiveRegistrationForSignal ( const EventIdentifier sigId,
const Name registrant,
const EventIdentifier eventId 
) [pure virtual]

receive the registration for signal sigId by registrant.

Parameters:
eventId the eventId of the event sent to registrant when sigId is fired
Returns:
registration was successful

Implemented in OMK::MirrorObjectHandle, OMK::ReferenceObjectHandle, and OMK::PvmMirrorObjectHandle.

Referenced by OMK::SimulatedObject::registerForSignalBy().

virtual bool OMK::ObjectHandle::cancelRegistrationForSignal ( const EventIdentifier sigId,
const Name registrant 
) [pure virtual]

cancel the registration made by registrant for sigId

Returns:
cancellation was successful

Implemented in OMK::MirrorObjectHandle, OMK::ReferenceObjectHandle, and OMK::PvmMirrorObjectHandle.

Referenced by OMK::SimulatedObject::cancelRegistrationForSignalBy().

const SimulatedObject & ObjectHandle::getSimulatedObject (  )  const

get a reference to the encapsulated simulated object

Definition at line 53 of file OMKObjectHandle.cpp.

References _myObject.

Referenced by OMK::FrameScheduler::addToScheduable(), OMK::PvmLocalObjectHandle::broadcastEvent(), OMK::PvmDuplicatedObjectHandle::broadcastEvent(), OMK::PvmMirrorObjectHandle::cancelRegistrationForSignal(), OMK::Controller::deleteObjectHandle(), OMK::Controller::getPointerToSimulatedObjectNamed(), OMK::Controller::hasEventsToProcess(), OMK::PvmMirrorObjectHandle::linkToNewReferential(), OMK::PvmReferenceObjectHandle::makeSynchronisationMessage(), OMK::Controller::processDeleteEventOf(), OMK::DistributedController::processEvent(), OMK::ReferenceObjectHandle::processEvents(), OMK::DistributedController::processStartEventOf(), OMK::PvmMirrorObjectHandle::PvmMirrorObjectHandle(), OMK::PvmMirrorObjectHandle::receiveEvent(), OMK::PvmMirrorObjectHandle::receiveRegistrationForSignal(), OMK::PvmMirrorObjectHandle::registerToReferenceObject(), OMK::FrameScheduler::removeFromScheduable(), OMK::FrameScheduler::runStep(), OMK::FrameScheduler::schedule(), OMK::Controller::sendInitialEventsTo(), OMK::PvmReferenceObjectHandle::unpack(), and OMK::FrameScheduler::unschedule().

00054 {
00055    return _myObject ;
00056 }

SimulatedObject & ObjectHandle::getSimulatedObject (  ) 

get a reference to the encapsulated simulated object

Definition at line 58 of file OMKObjectHandle.cpp.

References _myObject.

00059 {
00060    return _myObject ;
00061 }

void ObjectHandle::attributeRead (  )  [protected, virtual]

called when an attribute is read

Reimplemented in OMK::MirrorObjectHandle, and OMK::PvmMirrorObjectHandle.

Definition at line 87 of file OMKObjectHandle.cpp.

References _attributeRead.

Referenced by OMK::PvmMirrorObjectHandle::attributeRead(), and OMK::KernelAttribute::touch().

00088 {
00089    _attributeRead = true ;
00090 }

bool ObjectHandle::getAttributeRead ( bool  keepChanged = false  )  [protected, virtual]

test to see if an attribute was read.

Definition at line 92 of file OMKObjectHandle.cpp.

References _attributeRead.

Referenced by OMK::PvmMirrorObjectHandle::unpack().

00093 {
00094    bool result = _attributeRead ;
00095    if ( _attributeRead ) _attributeRead = keepChanged ;
00096    return result ;
00097 }


Friends And Related Function Documentation

friend class KernelAttribute [friend]

Definition at line 127 of file OMKObjectHandle.h.


Member Data Documentation

SimulatedObject& OMK::ObjectHandle::_myObject [protected]

a reference to the encapsulated object

Definition at line 137 of file OMKObjectHandle.h.

Referenced by OMK::ReferenceObjectHandle::compute(), getSimulatedObject(), OMK::ReferenceObjectHandle::init(), OMK::ReferenceObjectHandle::initAfterMorphose(), OMK::PvmReferenceObjectHandle::makeSynchronisationMessage(), ObjectHandle(), OMK::operator<(), OMK::operator<=(), OMK::PvmReferenceObjectHandle::packInitialValues(), OMK::ReferenceObjectHandle::processEvents(), OMK::ReferenceObjectHandle::receiveEvent(), OMK::ReferenceObjectHandle::ReferenceObjectHandle(), OMK::PvmMirrorObjectHandle::registerToReferenceObject(), OMK::PvmMirrorObjectHandle::sendRequestToReferenceObject(), OMK::PvmReferenceObjectHandle::unpack(), OMK::PvmMirrorObjectHandle::unpack(), and ~ObjectHandle().

bool OMK::ObjectHandle::_attributeRead [protected]

a boolean indicating if an attribute of the handled object was read since last call to getAttributeRead ( true )

Definition at line 140 of file OMKObjectHandle.h.

Referenced by attributeRead(), and getAttributeRead().

bool OMK::ObjectHandle::_aControlParameterHasChanged [protected]

memorise changes to a control parameter of the controlled object

Definition at line 143 of file OMKObjectHandle.h.

Referenced by controlParametersChanged(), and notifyChangeInControlParameter().

bool OMK::ObjectHandle::_migrationCase [protected]

CHADI.

Definition at line 146 of file OMKObjectHandle.h.

Referenced by OMK::ReferenceObjectHandle::setMigrationCaseToTrue(), OMK::PvmMirrorObjectHandle::setMorphosisPhaseTrue(), and ~ObjectHandle().


logo OpenMask

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

Generated with doxygen by Dimitri van Heesch ,   1997-2007