2
Definition of user-level access to the text sending and retrieving
3
functions within VRPN. These are wrappers around the vrpn_BaseClass
4
routines, since basic text functions have been pulled into these
14
#include "vrpn_Connection.h"
15
#include "vrpn_BaseClass.h"
17
// text-message time value meaning "go find out what time it is right now"
18
const struct timeval vrpn_TEXT_NOW = { 0 , 0 };
20
/// Structure passed back to user-level code from a vrpn_Text_Receiver.
21
typedef struct _vrpn_TEXTCB {
22
struct timeval msg_time; // Time of the message
23
char message[vrpn_MAX_TEXT_LEN]; // The message
24
vrpn_TEXT_SEVERITY type;
28
/// Description of the callback function type.
29
typedef void (VRPN_CALLBACK *vrpn_TEXTHANDLER)(void *userdata, const vrpn_TEXTCB info);
31
//----------------------------------------------------------
32
//************** Users deal with the following *************
34
/// Allows a user to send text messages from a device (usually,
35
// the send_text_message() function is protected). It provides
36
// the needed function definitions for vrpn_BaseClass.
38
class VRPN_API vrpn_Text_Sender: public vrpn_BaseClass {
40
vrpn_Text_Sender(const char *name, vrpn_Connection *c = NULL) :
41
vrpn_BaseClass(name, c) { init(); };
43
/// Mainloop the connection to send the message.
44
void mainloop(void) { server_mainloop(); if (d_connection) d_connection->mainloop(); };
46
/// Send a text message.
47
int send_message(const char *msg,
48
vrpn_TEXT_SEVERITY type = vrpn_TEXT_NORMAL,
49
vrpn_uint32 level = 0,
50
const struct timeval time = vrpn_TEXT_NOW);
52
/// No types to register beyond the text, which is done in BaseClass.
53
virtual int register_types(void) { return 0; };
56
/// Allows a user to handle text messages directly, in addition too having the
57
// standard VRPN printing functions handle them.
59
class VRPN_API vrpn_Text_Receiver: public vrpn_BaseClass {
61
vrpn_Text_Receiver (const char * name, vrpn_Connection * c = NULL);
62
virtual ~vrpn_Text_Receiver (void);
63
virtual int register_message_handler(void *userdata,
64
vrpn_TEXTHANDLER handler) {
65
return d_callback_list.register_handler(userdata, handler);
68
virtual int unregister_message_handler(void *userdata,
69
vrpn_TEXTHANDLER handler) {
70
return d_callback_list.unregister_handler(userdata, handler);
73
virtual void mainloop(void) { if (d_connection) { d_connection->mainloop(); }; client_mainloop(); };
76
static int VRPN_CALLBACK handle_message (void * userdata, vrpn_HANDLERPARAM p);
77
vrpn_Callback_List<vrpn_TEXTCB> d_callback_list;
79
/// No types to register beyond the text, which is done in BaseClass.
80
virtual int register_types(void) { return 0; };