vrpn 07.35
Virtual Reality Peripheral Network
 
Loading...
Searching...
No Matches
vrpn_SharedObject Class Referenceabstract

#include <vrpn_SharedObject.h>

Inheritance diagram for vrpn_SharedObject:
Collaboration diagram for vrpn_SharedObject:

Classes

struct  deferredUpdateCallbackEntry
 

Public Member Functions

 vrpn_SharedObject (const char *name, const char *tname, vrpn_int32 mode)
 
virtual ~vrpn_SharedObject (void)
 
const char * name (void) const
 
vrpn_bool isSerializer (void) const
 
virtual void bindConnection (vrpn_Connection *)
 Every derived class should call this, do what it needs to, and ALSO call {server,remote}PostBindCleanup() to get myId and peerId set up and to get standard handlers registered.
 
void useLamportClock (vrpn_LamportClock *)
 Lamport Clocks are NOT currently integrated. They should provide serialization (virtual timestamps) that work even when the clocks of the computers communicating are not roughly synchronized.
 
void becomeSerializer (void)
 Requests that this instance of the shared object becomes the serializer (i.e. lock-arbitrator), and we can then use setSerializerPolicy to imitate a complete lock. Does nothing if we already are the serializer (isSerializer() returns true); otherwise initiates a 3-phase request protocol with the current serializer. There currently isn't any provision for notification of success (or failure).
 
vrpn_bool registerDeferredUpdateCallback (vrpnDeferredUpdateCallback, void *userdata)
 The specified function will be passed userdata when this particular shared object defers an update (receives a local update but is not the serializer and so sends the update off to the serializer). Intended to allow insertion of timing code for those times when you really want to know how long every little thing is taking.
 

Protected Member Functions

virtual vrpn_bool shouldSendUpdate (vrpn_bool isLocalSet, vrpn_bool acceptedUpdate)
 
int yankCallbacks (vrpn_bool isLocal)
 must set d_lastUpdate BEFORE calling yankCallbacks()
 
int yankDeferredUpdateCallbacks (void)
 returns -1 on error (i.e. nonzero return by a callback)
 
void serverPostBindCleanup (void)
 
void remotePostBindCleanup (void)
 
virtual void sendUpdate (void)=0
 Should invoke default sendUpdate() for this derived type.
 
virtual int handleUpdate (vrpn_HANDLERPARAM)=0
 

Static Protected Member Functions

static int VRPN_CALLBACK handle_requestSerializer (void *, vrpn_HANDLERPARAM)
 
static int VRPN_CALLBACK handle_grantSerializer (void *, vrpn_HANDLERPARAM)
 
static int VRPN_CALLBACK handle_assumeSerializer (void *, vrpn_HANDLERPARAM)
 
static int VRPN_CALLBACK handle_gotConnection (void *, vrpn_HANDLERPARAM)
 Register this handler in postBindCleanup(); it calls sendUpdate() to make sure the remote has the correct value on first connection.
 
static int VRPN_CALLBACK handle_update (void *, vrpn_HANDLERPARAM)
 Passes arguments to handleUpdate() for this type; registered in postBindCleanup();.
 

Protected Attributes

char * d_name
 
vrpn_int32 d_mode
 
timeval d_lastUpdate
 
char * d_typename
 
vrpn_Connectiond_connection
 
vrpn_int32 d_serverId
 
vrpn_int32 d_remoteId
 
vrpn_int32 d_myId
 
vrpn_int32 d_peerId
 
vrpn_int32 d_update_type
 
vrpn_int32 d_requestSerializer_type
 Sent to the serializer to assume its duties.
 
vrpn_int32 d_grantSerializer_type
 Sent by the serializer to grant a request.
 
vrpn_int32 d_assumeSerializer_type
 Sent by a new serializer once it has been notified that its request has been granted.
 
vrpn_int32 d_lamportUpdate_type
 
vrpn_bool d_isSerializer
 default to vrpn_TRUE for servers, FALSE for remotes
 
vrpn_bool d_isNegotiatingSerializer
 As long as we have inorder delivery, this should be sufficient to keep us from getting many at once.
 
vrpn_bool d_queueSets
 If this is true, no set()s are processed; instead, they are queued for later execution. NOT IMPLEMENTED.
 
vrpn_LamportClockd_lClock
 
vrpn_LamportTimestampd_lastLamportUpdate
 
deferredUpdateCallbackEntryd_deferredUpdateCallbacks
 

Detailed Description

Definition at line 123 of file vrpn_SharedObject.h.

Constructor & Destructor Documentation

◆ vrpn_SharedObject()

◆ ~vrpn_SharedObject()

Member Function Documentation

◆ becomeSerializer()

void vrpn_SharedObject::becomeSerializer ( void )

Requests that this instance of the shared object becomes the serializer (i.e. lock-arbitrator), and we can then use setSerializerPolicy to imitate a complete lock. Does nothing if we already are the serializer (isSerializer() returns true); otherwise initiates a 3-phase request protocol with the current serializer. There currently isn't any provision for notification of success (or failure).

Definition at line 158 of file vrpn_SharedObject.C.

References d_connection, d_isNegotiatingSerializer, d_lastUpdate, d_myId, d_requestSerializer_type, vrpn_CONNECTION_RELIABLE, and vrpn_gettimeofday.

◆ bindConnection()

◆ handle_assumeSerializer()

int vrpn_SharedObject::handle_assumeSerializer ( void * userdata,
vrpn_HANDLERPARAM  )
staticprotected

Definition at line 297 of file vrpn_SharedObject.C.

References d_isNegotiatingSerializer, d_isSerializer, and vrpn_SharedObject().

Referenced by yankCallbacks(), and ~vrpn_SharedObject().

Here is the call graph for this function:

◆ handle_gotConnection()

int vrpn_SharedObject::handle_gotConnection ( void * userdata,
vrpn_HANDLERPARAM  )
staticprotected

Register this handler in postBindCleanup(); it calls sendUpdate() to make sure the remote has the correct value on first connection.

Definition at line 338 of file vrpn_SharedObject.C.

References d_isSerializer, d_mode, d_myId, d_serverId, sendUpdate(), vrpn_SharedObject(), and VRPN_SO_DEFER_UPDATES.

Referenced by handleUpdate(), and ~vrpn_SharedObject().

Here is the call graph for this function:

◆ handle_grantSerializer()

int vrpn_SharedObject::handle_grantSerializer ( void * userdata,
vrpn_HANDLERPARAM  )
staticprotected

◆ handle_requestSerializer()

int vrpn_SharedObject::handle_requestSerializer ( void * userdata,
vrpn_HANDLERPARAM  )
staticprotected

◆ handle_update()

int vrpn_SharedObject::handle_update ( void * userdata,
vrpn_HANDLERPARAM p )
staticprotected

Passes arguments to handleUpdate() for this type; registered in postBindCleanup();.

Definition at line 361 of file vrpn_SharedObject.C.

References handleUpdate(), and vrpn_SharedObject().

Referenced by handleUpdate(), and ~vrpn_SharedObject().

Here is the call graph for this function:

◆ handleUpdate()

virtual int vrpn_SharedObject::handleUpdate ( vrpn_HANDLERPARAM )
protectedpure virtual

Implemented in vrpn_Shared_float64, vrpn_Shared_int32, and vrpn_Shared_String.

References handle_gotConnection(), handle_update(), and VRPN_CALLBACK.

Referenced by handle_update().

Here is the call graph for this function:

◆ isSerializer()

vrpn_bool vrpn_SharedObject::isSerializer ( void ) const

Definition at line 106 of file vrpn_SharedObject.C.

Referenced by handle_requestSerializer().

◆ name()

◆ registerDeferredUpdateCallback()

vrpn_bool vrpn_SharedObject::registerDeferredUpdateCallback ( vrpnDeferredUpdateCallback cb,
void * userdata )

The specified function will be passed userdata when this particular shared object defers an update (receives a local update but is not the serializer and so sends the update off to the serializer). Intended to allow insertion of timing code for those times when you really want to know how long every little thing is taking.

Definition at line 181 of file vrpn_SharedObject.C.

References d_deferredUpdateCallbacks, vrpn_SharedObject::deferredUpdateCallbackEntry::handler, vrpn_SharedObject::deferredUpdateCallbackEntry::next, and vrpn_SharedObject::deferredUpdateCallbackEntry::userdata.

◆ remotePostBindCleanup()

void vrpn_SharedObject::remotePostBindCleanup ( void )
protected

◆ sendUpdate()

virtual void vrpn_SharedObject::sendUpdate ( void )
protectedpure virtual

Should invoke default sendUpdate() for this derived type.

Implemented in vrpn_Shared_float64, vrpn_Shared_int32, and vrpn_Shared_String.

Referenced by handle_gotConnection().

◆ serverPostBindCleanup()

void vrpn_SharedObject::serverPostBindCleanup ( void )
protected

◆ shouldSendUpdate()

vrpn_bool vrpn_SharedObject::shouldSendUpdate ( vrpn_bool isLocalSet,
vrpn_bool acceptedUpdate )
protectedvirtual

◆ useLamportClock()

void vrpn_SharedObject::useLamportClock ( vrpn_LamportClock * )

Lamport Clocks are NOT currently integrated. They should provide serialization (virtual timestamps) that work even when the clocks of the computers communicating are not roughly synchronized.

Definition at line 151 of file vrpn_SharedObject.C.

References vrpn_LamportClock.

◆ yankCallbacks()

int vrpn_SharedObject::yankCallbacks ( vrpn_bool isLocal)
protected

must set d_lastUpdate BEFORE calling yankCallbacks()

References handle_assumeSerializer(), handle_grantSerializer(), handle_requestSerializer(), and VRPN_CALLBACK.

Here is the call graph for this function:

◆ yankDeferredUpdateCallbacks()

Member Data Documentation

◆ d_assumeSerializer_type

vrpn_int32 vrpn_SharedObject::d_assumeSerializer_type
protected

Sent by a new serializer once it has been notified that its request has been granted.

Definition at line 185 of file vrpn_SharedObject.h.

Referenced by bindConnection(), handle_grantSerializer(), vrpn_SharedObject(), and ~vrpn_SharedObject().

◆ d_connection

◆ d_deferredUpdateCallbacks

deferredUpdateCallbackEntry* vrpn_SharedObject::d_deferredUpdateCallbacks
protected

◆ d_grantSerializer_type

vrpn_int32 vrpn_SharedObject::d_grantSerializer_type
protected

Sent by the serializer to grant a request.

Definition at line 183 of file vrpn_SharedObject.h.

Referenced by bindConnection(), handle_requestSerializer(), vrpn_SharedObject(), and ~vrpn_SharedObject().

◆ d_isNegotiatingSerializer

vrpn_bool vrpn_SharedObject::d_isNegotiatingSerializer
protected

As long as we have inorder delivery, this should be sufficient to keep us from getting many at once.

Definition at line 195 of file vrpn_SharedObject.h.

Referenced by becomeSerializer(), handle_assumeSerializer(), handle_grantSerializer(), handle_requestSerializer(), and vrpn_SharedObject().

◆ d_isSerializer

◆ d_lamportUpdate_type

vrpn_int32 vrpn_SharedObject::d_lamportUpdate_type
protected

Definition at line 191 of file vrpn_SharedObject.h.

Referenced by vrpn_SharedObject().

◆ d_lastLamportUpdate

vrpn_LamportTimestamp* vrpn_SharedObject::d_lastLamportUpdate
protected

◆ d_lastUpdate

◆ d_lClock

vrpn_LamportClock* vrpn_SharedObject::d_lClock
protected

◆ d_mode

◆ d_myId

◆ d_name

◆ d_peerId

vrpn_int32 vrpn_SharedObject::d_peerId
protected

◆ d_queueSets

vrpn_bool vrpn_SharedObject::d_queueSets
protected

If this is true, no set()s are processed; instead, they are queued for later execution. NOT IMPLEMENTED.

Definition at line 210 of file vrpn_SharedObject.h.

Referenced by handle_requestSerializer(), and vrpn_SharedObject().

◆ d_remoteId

vrpn_int32 vrpn_SharedObject::d_remoteId
protected

◆ d_requestSerializer_type

vrpn_int32 vrpn_SharedObject::d_requestSerializer_type
protected

Sent to the serializer to assume its duties.

Definition at line 181 of file vrpn_SharedObject.h.

Referenced by becomeSerializer(), bindConnection(), vrpn_SharedObject(), and ~vrpn_SharedObject().

◆ d_serverId

vrpn_int32 vrpn_SharedObject::d_serverId
protected

◆ d_typename

char* vrpn_SharedObject::d_typename
protected

Definition at line 169 of file vrpn_SharedObject.h.

Referenced by bindConnection(), vrpn_SharedObject(), and ~vrpn_SharedObject().

◆ d_update_type


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