vrpn  07.33
Virtual Reality Peripheral Network
vrpn_Text.C
Go to the documentation of this file.
1 #include "vrpn_Text.h"
2 
4  vrpn_uint32 level, const struct timeval time)
5 {
6  struct timeval now;
7 
8  // Replace the time value with the current time if the user passed in the
9  // constant time referring to "now".
10  if ((time.tv_sec == vrpn_TEXT_NOW.tv_sec) &&
11  (time.tv_usec == vrpn_TEXT_NOW.tv_usec)) {
12  vrpn_gettimeofday(&now, NULL);
13  }
14  else {
15  now = time;
16  }
17  // send message, time, type and level
18  return send_text_message(msg, now, type, level);
19 }
20 
22  : vrpn_BaseClass(name, c)
23 {
24  init();
25  if (d_connection) {
27  d_sender_id);
28  }
29 };
30 
32 
34 {
35 
37  vrpn_TEXTCB cp;
38 
39  cp.msg_time = p.msg_time;
41  p.buffer);
42 
43  // Go down the list of callbacks that have been registered.
44  // Fill in the parameter and call each.
46  return 0;
47 }
vrpn_BaseClassUnique::decode_text_message_from_buffer
static 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.
Definition: vrpn_BaseClass.C:549
vrpn_BaseClassUnique::register_autodeleted_handler
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.
Definition: vrpn_BaseClass.C:503
vrpn_Text_Receiver::vrpn_Text_Receiver
vrpn_Text_Receiver(const char *name, vrpn_Connection *c=NULL)
Definition: vrpn_Text.C:21
vrpn_TEXTCB::level
vrpn_uint32 level
Definition: vrpn_Text.h:25
vrpn_Text_Receiver::handle_message
static int VRPN_CALLBACK handle_message(void *userdata, vrpn_HANDLERPARAM p)
Definition: vrpn_Text.C:33
vrpn_BaseClassUnique::userdata
void * userdata
Definition: vrpn_BaseClass.h:287
vrpn_Text_Receiver
Allows a user to handle text messages directly, in addition too having the.
Definition: vrpn_Text.h:68
vrpn_Text_Sender::send_message
int send_message(const char *msg, vrpn_TEXT_SEVERITY type=vrpn_TEXT_NORMAL, vrpn_uint32 level=0, const struct timeval time=vrpn_TEXT_NOW)
Send a text message.
Definition: vrpn_Text.C:3
vrpn_BaseClassUnique::d_text_message_id
vrpn_int32 d_text_message_id
ID for text messages.
Definition: vrpn_BaseClass.h:229
vrpn_Text_Receiver::~vrpn_Text_Receiver
virtual ~vrpn_Text_Receiver(void)
Definition: vrpn_Text.C:31
vrpn_BaseClassUnique::d_connection
vrpn_Connection * d_connection
Connection that this object talks to.
Definition: vrpn_BaseClass.h:224
vrpn_HANDLERPARAM::buffer
const char * buffer
Definition: vrpn_Connection.h:49
vrpn_HANDLERPARAM
This structure is what is passed to a vrpn_Connection message callback.
Definition: vrpn_Connection.h:44
vrpn_BaseClassUnique::d_sender_id
vrpn_int32 d_sender_id
Sender ID registered with the connection.
Definition: vrpn_BaseClass.h:228
vrpn_HANDLERPARAM::msg_time
struct timeval msg_time
Definition: vrpn_Connection.h:47
vrpn_Connection
Generic connection class not specific to the transport mechanism.
Definition: vrpn_Connection.h:510
vrpn_TEXTCB
Structure passed back to user-level code from a vrpn_Text_Receiver.
Definition: vrpn_Text.h:21
vrpn_gettimeofday
#define vrpn_gettimeofday
Definition: vrpn_Shared.h:89
vrpn_Text.h
vrpn_BaseClass::init
virtual int init(void)
Initialize things that the constructor can't. Returns 0 on success, -1 on failure.
Definition: vrpn_BaseClass.C:363
vrpn_TEXT_SEVERITY
vrpn_TEXT_SEVERITY
Since the sending of text messages has been pulled into the base class (so that every object can send...
Definition: vrpn_BaseClass.h:100
vrpn_TEXTCB::type
vrpn_TEXT_SEVERITY type
Definition: vrpn_Text.h:24
vrpn_BaseClassUnique::send_text_message
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.
Definition: vrpn_BaseClass.C:568
vrpn_Callback_List::call_handlers
void call_handlers(const CALLBACK_STRUCT &info)
This will pass the referenced parameter as a const to all the callbacks.
Definition: vrpn_BaseClass.h:451
vrpn_BaseClassUnique::type
vrpn_int32 type
Definition: vrpn_BaseClass.h:286
vrpn_TEXTCB::msg_time
struct timeval msg_time
Definition: vrpn_Text.h:22
vrpn_BaseClass
Class from which all user-level (and other) classes that communicate with vrpn_Connections should der...
Definition: vrpn_BaseClass.h:313
vrpn_TEXT_NOW
const struct timeval vrpn_TEXT_NOW
Definition: vrpn_Text.h:18
vrpn_TEXTCB::message
char message[vrpn_MAX_TEXT_LEN]
Definition: vrpn_Text.h:23
vrpn_Text_Receiver::d_callback_list
vrpn_Callback_List< vrpn_TEXTCB > d_callback_list
Definition: vrpn_Text.h:95