vrpn 07.35
Virtual Reality Peripheral Network
|
#include <vrpn_SharedObject.h>
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_Connection * | d_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_LamportClock * | d_lClock |
vrpn_LamportTimestamp * | d_lastLamportUpdate |
deferredUpdateCallbackEntry * | d_deferredUpdateCallbacks |
Definition at line 123 of file vrpn_SharedObject.h.
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.
|
virtual |
Definition at line 65 of file vrpn_SharedObject.C.
References d_assumeSerializer_type, d_connection, d_grantSerializer_type, d_myId, d_name, d_peerId, d_requestSerializer_type, d_typename, d_update_type, handle_assumeSerializer(), handle_gotConnection(), handle_grantSerializer(), handle_requestSerializer(), handle_update(), vrpn_Connection::register_message_type(), vrpn_Connection::removeReference(), vrpn_Connection::unregister_handler(), and vrpn_got_connection.
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::pack_message(), vrpn_CONNECTION_RELIABLE, and vrpn_gettimeofday.
|
virtual |
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.
Reimplemented in vrpn_Shared_int32_Server, vrpn_Shared_int32_Remote, vrpn_Shared_float64_Server, vrpn_Shared_float64_Remote, vrpn_Shared_String_Server, and vrpn_Shared_String_Remote.
Definition at line 109 of file vrpn_SharedObject.C.
References vrpn_Connection::addReference(), d_assumeSerializer_type, d_connection, d_grantSerializer_type, d_name, d_remoteId, d_requestSerializer_type, d_serverId, d_typename, d_update_type, vrpn_Connection::register_message_type(), vrpn_Connection::register_sender(), and vrpn_Connection::removeReference().
Referenced by vrpn_Shared_int32_Server::bindConnection(), vrpn_Shared_int32_Remote::bindConnection(), vrpn_Shared_float64_Server::bindConnection(), vrpn_Shared_float64_Remote::bindConnection(), vrpn_Shared_String_Server::bindConnection(), and vrpn_Shared_String_Remote::bindConnection().
|
staticprotected |
Definition at line 297 of file vrpn_SharedObject.C.
References d_isNegotiatingSerializer, and d_isSerializer.
Referenced by ~vrpn_SharedObject().
|
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(), and VRPN_SO_DEFER_UPDATES.
Referenced by ~vrpn_SharedObject().
|
staticprotected |
Definition at line 275 of file vrpn_SharedObject.C.
References d_assumeSerializer_type, d_connection, d_isNegotiatingSerializer, d_isSerializer, d_lastUpdate, d_myId, vrpn_Connection::pack_message(), vrpn_CONNECTION_RELIABLE, and vrpn_gettimeofday.
Referenced by ~vrpn_SharedObject().
|
staticprotected |
Definition at line 236 of file vrpn_SharedObject.C.
References d_connection, d_grantSerializer_type, d_isNegotiatingSerializer, d_lastUpdate, d_myId, d_queueSets, isSerializer(), vrpn_Connection::pack_message(), vrpn_CONNECTION_RELIABLE, and vrpn_gettimeofday.
Referenced by ~vrpn_SharedObject().
|
staticprotected |
Passes arguments to handleUpdate() for this type; registered in postBindCleanup();.
Definition at line 361 of file vrpn_SharedObject.C.
References handleUpdate().
Referenced by ~vrpn_SharedObject().
|
protectedpure virtual |
Implemented in vrpn_Shared_int32, vrpn_Shared_float64, and vrpn_Shared_String.
Referenced by handle_update().
vrpn_bool vrpn_SharedObject::isSerializer | ( | void | ) | const |
Definition at line 106 of file vrpn_SharedObject.C.
Referenced by handle_requestSerializer().
const char * vrpn_SharedObject::name | ( | void | ) | const |
Definition at line 104 of file vrpn_SharedObject.C.
References d_name.
Referenced by vrpn_Shared_float64::vrpn_Shared_float64(), vrpn_Shared_String::vrpn_Shared_String(), and vrpn_SharedObject().
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.
|
protected |
Definition at line 330 of file vrpn_SharedObject.C.
References d_myId, d_peerId, d_remoteId, and d_serverId.
Referenced by vrpn_Shared_int32_Remote::bindConnection(), vrpn_Shared_float64_Remote::bindConnection(), and vrpn_Shared_String_Remote::bindConnection().
|
protectedpure virtual |
Should invoke default sendUpdate() for this derived type.
Implemented in vrpn_Shared_int32, vrpn_Shared_float64, and vrpn_Shared_String.
Referenced by handle_gotConnection().
|
protected |
Definition at line 323 of file vrpn_SharedObject.C.
References d_myId, d_peerId, d_remoteId, and d_serverId.
Referenced by vrpn_Shared_int32_Server::bindConnection(), vrpn_Shared_float64_Server::bindConnection(), and vrpn_Shared_String_Server::bindConnection().
|
protectedvirtual |
Definition at line 201 of file vrpn_SharedObject.C.
References d_isSerializer, d_mode, and VRPN_SO_DEFER_UPDATES.
Referenced by vrpn_Shared_String::set(), vrpn_Shared_float64::set(), and vrpn_Shared_int32::set().
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.
|
protected |
must set d_lastUpdate BEFORE calling yankCallbacks()
|
protected |
returns -1 on error (i.e. nonzero return by a callback)
Definition at line 310 of file vrpn_SharedObject.C.
References d_deferredUpdateCallbacks, vrpn_SharedObject::deferredUpdateCallbackEntry::handler, vrpn_SharedObject::deferredUpdateCallbackEntry::next, and vrpn_SharedObject::deferredUpdateCallbackEntry::userdata.
Referenced by vrpn_Shared_String::shouldAcceptUpdate(), vrpn_Shared_float64::shouldAcceptUpdate(), and vrpn_Shared_int32::shouldAcceptUpdate().
|
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().
|
protected |
Definition at line 171 of file vrpn_SharedObject.h.
Referenced by becomeSerializer(), bindConnection(), handle_grantSerializer(), handle_requestSerializer(), vrpn_Shared_String::sendUpdate(), vrpn_Shared_float64::sendUpdate(), vrpn_Shared_int32::sendUpdate(), and ~vrpn_SharedObject().
|
protected |
Definition at line 223 of file vrpn_SharedObject.h.
Referenced by registerDeferredUpdateCallback(), and yankDeferredUpdateCallbacks().
|
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().
|
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().
|
protected |
default to vrpn_TRUE for servers, FALSE for remotes
Definition at line 193 of file vrpn_SharedObject.h.
Referenced by handle_assumeSerializer(), handle_gotConnection(), handle_grantSerializer(), vrpn_Shared_String::shouldAcceptUpdate(), vrpn_Shared_float64::shouldAcceptUpdate(), vrpn_Shared_int32::shouldAcceptUpdate(), shouldSendUpdate(), vrpn_Shared_float64_Server::vrpn_Shared_float64_Server(), vrpn_Shared_int32_Server::vrpn_Shared_int32_Server(), and vrpn_Shared_String_Server::vrpn_Shared_String_Server().
|
protected |
Definition at line 191 of file vrpn_SharedObject.h.
|
protected |
Definition at line 216 of file vrpn_SharedObject.h.
Referenced by vrpn_Shared_int32::handle_lamportUpdate().
|
protected |
Definition at line 168 of file vrpn_SharedObject.h.
Referenced by becomeSerializer(), handle_grantSerializer(), handle_requestSerializer(), vrpn_Shared_String::sendUpdate(), vrpn_Shared_int32::sendUpdate(), vrpn_Shared_float64::sendUpdate(), vrpn_Shared_String::sendUpdate(), vrpn_Shared_float64::sendUpdate(), vrpn_Shared_int32::sendUpdate(), vrpn_Shared_String::set(), vrpn_Shared_float64::set(), vrpn_Shared_int32::set(), vrpn_Shared_String::shouldAcceptUpdate(), vrpn_Shared_float64::shouldAcceptUpdate(), vrpn_Shared_int32::shouldAcceptUpdate(), vrpn_Shared_float64::vrpn_Shared_float64(), vrpn_Shared_String::vrpn_Shared_String(), vrpn_SharedObject(), vrpn_Shared_int32::yankCallbacks(), vrpn_Shared_float64::yankCallbacks(), and vrpn_Shared_String::yankCallbacks().
|
protected |
Definition at line 215 of file vrpn_SharedObject.h.
Referenced by vrpn_Shared_int32::handle_lamportUpdate(), and vrpn_Shared_int32::sendUpdate().
|
protected |
Definition at line 167 of file vrpn_SharedObject.h.
Referenced by handle_gotConnection(), vrpn_Shared_String::shouldAcceptUpdate(), vrpn_Shared_float64::shouldAcceptUpdate(), vrpn_Shared_int32::shouldAcceptUpdate(), and shouldSendUpdate().
|
protected |
Definition at line 177 of file vrpn_SharedObject.h.
Referenced by becomeSerializer(), handle_gotConnection(), handle_grantSerializer(), handle_requestSerializer(), remotePostBindCleanup(), vrpn_Shared_String::sendUpdate(), vrpn_Shared_float64::sendUpdate(), vrpn_Shared_int32::sendUpdate(), serverPostBindCleanup(), and ~vrpn_SharedObject().
|
protected |
Definition at line 166 of file vrpn_SharedObject.h.
Referenced by bindConnection(), name(), vrpn_Shared_float64::vrpn_Shared_float64(), vrpn_Shared_String::vrpn_Shared_String(), vrpn_SharedObject(), and ~vrpn_SharedObject().
|
protected |
Definition at line 178 of file vrpn_SharedObject.h.
Referenced by remotePostBindCleanup(), serverPostBindCleanup(), and ~vrpn_SharedObject().
|
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().
|
protected |
Definition at line 176 of file vrpn_SharedObject.h.
Referenced by bindConnection(), remotePostBindCleanup(), and serverPostBindCleanup().
|
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().
|
protected |
Definition at line 175 of file vrpn_SharedObject.h.
Referenced by bindConnection(), handle_gotConnection(), remotePostBindCleanup(), and serverPostBindCleanup().
|
protected |
Definition at line 169 of file vrpn_SharedObject.h.
Referenced by bindConnection(), vrpn_SharedObject(), and ~vrpn_SharedObject().
|
protected |
Definition at line 179 of file vrpn_SharedObject.h.
Referenced by bindConnection(), vrpn_Shared_String::sendUpdate(), vrpn_Shared_float64::sendUpdate(), vrpn_Shared_int32::sendUpdate(), and ~vrpn_SharedObject().