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::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, name(), and vrpn_gettimeofday.

Here is the call graph for this function:

◆ ~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 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:

◆ bindConnection()

◆ handle_assumeSerializer()

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

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

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

Referenced by ~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 349 of file vrpn_SharedObject.C.

References handleUpdate().

Referenced by ~vrpn_SharedObject().

Here is the call graph for this function:

◆ handleUpdate()

virtual int vrpn_SharedObject::handleUpdate ( vrpn_HANDLERPARAM  )
protectedpure virtual

◆ isSerializer()

vrpn_bool vrpn_SharedObject::isSerializer ( void  ) const

Definition at line 95 of file vrpn_SharedObject.C.

Referenced by handle_requestSerializer().

◆ name()

const char * vrpn_SharedObject::name ( void  ) const

◆ registerDeferredUpdateCallback()

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.

◆ 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_String, vrpn_Shared_float64, and vrpn_Shared_int32.

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

◆ yankCallbacks()

int vrpn_SharedObject::yankCallbacks ( vrpn_bool  isLocal)
protected

must set d_lastUpdate BEFORE calling yankCallbacks()

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

◆ d_isSerializer

◆ d_lamportUpdate_type

vrpn_int32 vrpn_SharedObject::d_lamportUpdate_type
protected

Definition at line 191 of file vrpn_SharedObject.h.

◆ d_lastLamportUpdate

vrpn_LamportTimestamp* vrpn_SharedObject::d_lastLamportUpdate
protected

Definition at line 216 of file vrpn_SharedObject.h.

Referenced by vrpn_Shared_int32::handle_lamportUpdate().

◆ 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().

◆ 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(), 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

vrpn_int32 vrpn_SharedObject::d_update_type
protected

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