vrpn  07.33
Virtual Reality Peripheral Network
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. More...
 
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. More...
 
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). More...
 
void 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. More...
 

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() More...
 
int yankDeferredUpdateCallbacks (void)
 returns -1 on error (i.e. nonzero return by a callback) More...
 
void serverPostBindCleanup (void)
 
void remotePostBindCleanup (void)
 
virtual void sendUpdate (void)=0
 Should invoke default sendUpdate() for this derived type. More...
 
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. More...
 
static int VRPN_CALLBACK handle_update (void *, vrpn_HANDLERPARAM)
 Passes arguments to handleUpdate() for this type; < registered in postBindCleanup();. More...
 

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. More...
 
vrpn_int32 d_grantSerializer_type
 Sent by the serializer to grant a request. More...
 
vrpn_int32 d_assumeSerializer_type
 Sent by a new serializer once it has been notified that < its request has been granted. More...
 
vrpn_int32 d_lamportUpdate_type
 
vrpn_bool d_isSerializer
 default to vrpn_TRUE for servers, FALSE for remotes More...
 
vrpn_bool d_isNegotiatingSerializer
 As long as we have inorder delivery, this should be < sufficient to keep us from getting many at once. More...
 
vrpn_bool d_queueSets
 If this is true, no set()s are processed; instead, they < are queued for later execution. < NOT IMPLEMENTED. More...
 
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 ( const char *  name,
const char *  tname,
vrpn_int32  mode 
)

Definition at line 31 of file vrpn_SharedObject.C.

References d_lastUpdate, d_name, d_typename, and vrpn_gettimeofday.

Member Function Documentation

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 147 of file vrpn_SharedObject.C.

References d_connection, d_isNegotiatingSerializer, d_lastUpdate, d_myId, d_requestSerializer_type, vrpn_Connection::pack_message(), vrpn_CONNECTION_RELIABLE, and vrpn_gettimeofday.

Here is the call graph for this function:

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

Definition at line 285 of file vrpn_SharedObject.C.

References d_isNegotiatingSerializer, and d_isSerializer.

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

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 326 of file vrpn_SharedObject.C.

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

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

Here is the call graph for this function:

int vrpn_SharedObject::handle_grantSerializer ( void *  userdata,
vrpn_HANDLERPARAM   
)
staticprotected
int vrpn_SharedObject::handle_requestSerializer ( void *  userdata,
vrpn_HANDLERPARAM   
)
staticprotected
int vrpn_SharedObject::handle_update ( void *  userdata,
vrpn_HANDLERPARAM  p 
)
staticprotected
virtual int vrpn_SharedObject::handleUpdate ( vrpn_HANDLERPARAM  )
protectedpure virtual
vrpn_bool vrpn_SharedObject::isSerializer ( void  ) const

Definition at line 95 of file vrpn_SharedObject.C.

Referenced by handle_requestSerializer().

const char * vrpn_SharedObject::name ( void  ) const

Definition at line 93 of file vrpn_SharedObject.C.

References d_name.

void 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 170 of file vrpn_SharedObject.C.

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

void vrpn_SharedObject::remotePostBindCleanup ( void  )
protected
virtual void vrpn_SharedObject::sendUpdate ( void  )
protectedpure virtual

Should invoke default sendUpdate() for this derived type.

Implemented in vrpn_Shared_String, vrpn_Shared_float64, and vrpn_Shared_int32.

Referenced by handle_gotConnection().

void vrpn_SharedObject::serverPostBindCleanup ( void  )
protected
vrpn_bool vrpn_SharedObject::shouldSendUpdate ( vrpn_bool  isLocalSet,
vrpn_bool  acceptedUpdate 
)
protectedvirtual
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 140 of file vrpn_SharedObject.C.

int vrpn_SharedObject::yankCallbacks ( vrpn_bool  isLocal)
protected

must set d_lastUpdate BEFORE calling yankCallbacks()

Member Data Documentation

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(), handle_update(), and ~vrpn_SharedObject().

deferredUpdateCallbackEntry* vrpn_SharedObject::d_deferredUpdateCallbacks
protected
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(), handle_update(), and ~vrpn_SharedObject().

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(), and handle_requestSerializer().

vrpn_int32 vrpn_SharedObject::d_lamportUpdate_type
protected

Definition at line 191 of file vrpn_SharedObject.h.

vrpn_LamportTimestamp* vrpn_SharedObject::d_lastLamportUpdate
protected

Definition at line 216 of file vrpn_SharedObject.h.

Referenced by vrpn_Shared_int32::handle_lamportUpdate().

vrpn_LamportClock* vrpn_SharedObject::d_lClock
protected
vrpn_int32 vrpn_SharedObject::d_peerId
protected
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().

vrpn_int32 vrpn_SharedObject::d_remoteId
protected
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(), handle_update(), and ~vrpn_SharedObject().

vrpn_int32 vrpn_SharedObject::d_serverId
protected
char* vrpn_SharedObject::d_typename
protected

Definition at line 169 of file vrpn_SharedObject.h.

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

vrpn_int32 vrpn_SharedObject::d_update_type
protected

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