Main Page   Class Hierarchy   Compound List   File List   Header Files   Compound Members   File Members  

vrpn_BaseClassUnique Class Reference

INTERNAL class to hold members that there should only be one copy of even when a class inherits from multiple vrpn_BaseClasses because it inherits from multiple user-level classes. Note that not everything in vrpnBaseClass should be here, because (for example) the registration of types should be done for each parent class. More...

#include <vrpn_BaseClass.h>

Class diagram for vrpn_BaseClassUnique:

vrpn_BaseClass vrpn_Tracker vrpn_Text_Sender vrpn_Text_Receiver vrpn_TempImager vrpn_Sound vrpn_Router vrpn_RedundantRemote vrpn_RedundantController vrpn_Poser vrpn_ForceDevice vrpn_Dial vrpn_Clock vrpn_Button vrpn_Analog_Output vrpn_Analog

List of all members.


Public Members

 vrpn_BaseClassUnique ()
virtual ~vrpn_BaseClassUnique ()
Unregister all of the message handlers that were to be autodeleted. More...

vrpn_MESSAGEHANDLER handler
vrpn_int32 sender
vrpn_int32 type
void* userdata

Protected Members

int register_autodeleted_handler (vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender = vrpn_ANY_SENDER)
Registers a handler with the connection, and remembers to delete at destruction. More...

int send_text_message (const char *msg, struct timeval timestamp, vrpn_TEXT_SEVERITY type = vrpn_TEXT_NORMAL, vrpn_uint32 level = 0)
Sends a NULL-terminated text message from the device d_sender_id.

void server_mainloop (void)
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should be called by all servers in their mainloop(). More...

void client_mainloop (void)
Handles functions that all clients should provide in their mainloop() (warning of no server, for example) Should be called by all clients in their mainloop(). More...

vrpn_Connectiond_connection
Connection that this object talks to.

char* d_servicename
Name of this device, not including the connection part.

vrpn_int32 d_sender_id
Sender ID registered with the connection.

vrpn_int32 d_text_message_id
ID for text messages.

vrpn_int32 d_ping_message_id
Ask the server if they are there.

vrpn_int32 d_pong_message_id
Server telling that it is there.


Static Protected Members

int encode_text_message_to_buffer ( char *buf, vrpn_TEXT_SEVERITY severity, vrpn_uint32 level, const char *msg)
Encodes the body of the text message into a buffer, preparing for sending.

int decode_text_message_from_buffer ( char *msg, vrpn_TEXT_SEVERITY *severity, vrpn_uint32 *level, const char *buf)
Decodes the body of the text message from a buffer from the connection.


Friends

class  vrpn_TextPrinter

Detailed Description

INTERNAL class to hold members that there should only be one copy of even when a class inherits from multiple vrpn_BaseClasses because it inherits from multiple user-level classes. Note that not everything in vrpnBaseClass should be here, because (for example) the registration of types should be done for each parent class.


Member Function Documentation

vrpn_BaseClassUnique::vrpn_BaseClassUnique ()

vrpn_BaseClassUnique::~vrpn_BaseClassUnique () [virtual]

Unregister all of the message handlers that were to be autodeleted.

Delete space allocated in the constructor.

int vrpn_BaseClassUnique::register_autodeleted_handler (vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void * userdata, vrpn_int32 sender = vrpn_ANY_SENDER) [protected]

Registers a handler with the connection, and remembers to delete at destruction.

It also keeps track of all of the handlers registered by an object and unregisters them automatically when the object is destroyed. This routine should be used, rather than the Connection one, to ensure that they are all unregistered. If they are not, and a message comes in after the object is destroyed, it will likely cause a Segmentation Violation.

The function returns 0 on success and -1 on failure.

int vrpn_BaseClassUnique::send_text_message (const char * msg, struct timeval timestamp, vrpn_TEXT_SEVERITY type = vrpn_TEXT_NORMAL, vrpn_uint32 level = 0) [protected]

Sends a NULL-terminated text message from the device d_sender_id.

void vrpn_BaseClassUnique::server_mainloop (void) [protected]

Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should be called by all servers in their mainloop().

It should be called each time through by each server's mainloop() function. Performed functions include: Sending pong ("server is alive") messages so that clients can know if they have connected to the server.

void vrpn_BaseClassUnique::client_mainloop (void) [protected]

Handles functions that all clients should provide in their mainloop() (warning of no server, for example) Should be called by all clients in their mainloop().

It should be called each time through a client's mainloop() function. Performed functions include: Handling the Ping/Pong messages that tell the client if the server is alive: Client initiates ping/pong cycle when client is created and when its connection is dropped This initiation is done the first time through client_mainloop() It is done again in a handler for the "dropped_connection" system message During ping/pong cycle, client sends ping requests once/second and waits for response At the start of the cycle, d_unanswered_ping is set to 1 and d_first_ping_time is set Handler for pong message sets d_unanswered_ping to 0 when we get one Prints warning messages every second after 3+ seconds with no pong Prints error messages every second after 10+ seconds with no pong (flatlined) Server responds to ping message with pong message Handler for ping set up the first time through server_mainloop()

int vrpn_BaseClassUnique::encode_text_message_to_buffer (char * buf, vrpn_TEXT_SEVERITY severity, vrpn_uint32 level, const char * msg) [static, protected]

Encodes the body of the text message into a buffer, preparing for sending.

int vrpn_BaseClassUnique::decode_text_message_from_buffer (char * msg, vrpn_TEXT_SEVERITY * severity, vrpn_uint32 * level, const char * buf) [static, protected]

Decodes the body of the text message from a buffer from the connection.


Friends And Related Function Documentation

friend class vrpn_TextPrinter [friend]


Member Data Documentation

vrpn_MESSAGEHANDLER vrpn_BaseClassUnique::handler

vrpn_int32 vrpn_BaseClassUnique::sender

vrpn_int32 vrpn_BaseClassUnique::type

void* vrpn_BaseClassUnique::userdata

vrpn_Connection* vrpn_BaseClassUnique::d_connection [protected]

Connection that this object talks to.

char* vrpn_BaseClassUnique::d_servicename [protected]

Name of this device, not including the connection part.

vrpn_int32 vrpn_BaseClassUnique::d_sender_id [protected]

Sender ID registered with the connection.

vrpn_int32 vrpn_BaseClassUnique::d_text_message_id [protected]

ID for text messages.

vrpn_int32 vrpn_BaseClassUnique::d_ping_message_id [protected]

Ask the server if they are there.

vrpn_int32 vrpn_BaseClassUnique::d_pong_message_id [protected]

Server telling that it is there.


The documentation for this class was generated from the following files:
Generated at Fri Sep 13 15:03:59 2002 for vrpn by doxygen 1.0.0 written by Dimitri van Heesch, © 1997-1999