145 vrpn_uint32 level = 0);
149 void set_ostream_to_use(FILE *o);
214 , _severity(other._severity)
220 struct timeval timestamp;
242 int register_autodeleted_handler(vrpn_int32 type,
249 static int encode_text_message_to_buffer(
char *buf,
255 static int decode_text_message_from_buffer(
char *msg,
261 int send_text_message(
const char *msg,
struct timeval timestamp,
263 vrpn_uint32 level = 0);
278 void server_mainloop(
void);
283 void client_mainloop(
void);
292 int d_num_autodeletions;
294 int d_first_mainloop;
296 struct timeval d_time_first_ping;
300 int d_unanswered_ping;
309 void initiate_ping_cycle(
void);
336 virtual int init(
void);
340 virtual int register_senders(
void);
365#pragma warning(disable : 4251)
370 const CALLBACK_STRUCT info);
377 current = d_change_list;
378 while (current != NULL) {
379 next = current->
next;
384 "vrpn_Callback_List::operator =: Deletion failure\n");
393 while (current != NULL) {
395 current = current->
next;
405 if (handler == NULL) {
407 "vrpn_Callback_List::register_handler(): NULL handler\n");
416 "vrpn_Callback_List::register_handler(): Out of memory\n");
424 new_entry->
next = d_change_list;
425 d_change_list = new_entry;
438 snitch = &d_change_list;
440 while ((victim != NULL) && ((victim->
handler != handler) ||
442 snitch = &((*snitch)->next);
443 victim = victim->
next;
447 if (victim == NULL) {
450 "vrpn_Callback_List::unregister_handler: No such handler\n");
455 *snitch = victim->
next;
459 fprintf(stderr,
"vrpn_Callback_List::unregister_handler: delete failed\n");
470 while (handler != NULL) {
472 handler = handler->
next;
478 : d_change_list(NULL){};
483 while (d_change_list != NULL) {
486 delete d_change_list;
488 fprintf(stderr,
"vrpn_Callback_List::~vrpn_Callback_List: delete failed\n");
491 d_change_list = next;
496 typedef struct vrpn_CBS {
SendTextMessageBoundCall(SendTextMessageBoundCall const &other)
SendTextMessageBoundCall(vrpn_BaseClassUnique *device, vrpn_TEXT_SEVERITY type)
int operator()(const char *msg) const
INTERNAL class to hold members that there should only be one copy of even when a class inherits from ...
vrpn_Connection * connectionPtr()
Returns a pointer to the connection this object is using.
vrpn_Connection * d_connection
Connection that this object talks to.
SendTextMessageBoundCall send_text_message(vrpn_TEXT_SEVERITY type=vrpn_TEXT_NORMAL)
Returns an object you can stream into to send a text message from the device like send_text_message(v...
vrpn_MESSAGEHANDLER handler
vrpn_int32 d_pong_message_id
Server telling that it is there.
vrpn_int32 d_sender_id
Sender ID registered with the connection.
vrpn_int32 d_text_message_id
ID for text messages.
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.
vrpn_int32 d_ping_message_id
Ask the server if they are there.
char * d_servicename
Name of this device, not including the connection part.
Class from which all user-level (and other) classes that communicate with vrpn_Connections should der...
virtual void mainloop()=0
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
virtual int register_types(void)=0
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
int register_handler(void *userdata, HANDLER_TYPE handler)
Call this to add a handler to the list.
~vrpn_Callback_List()
Clear the list upon destruction if it is not empty already.
int unregister_handler(void *userdata, HANDLER_TYPE handler)
Call this to remove a handler from the list (if it exists)
vrpn_Callback_List()
The list starts out empty.
void call_handlers(const CALLBACK_STRUCT &info)
This will pass the referenced parameter as a const to all the callbacks.
void operator=(const vrpn_Callback_List &from)
This class requires deep copies.
CHANGELIST_ENTRY * d_change_list
Generic connection class not specific to the transport mechanism.
Structure to hold the objects that are being watched.
vrpn_TextPrinter_Watch_Entry * next
Pointer to the next one in the list.
vrpn_BaseClass * obj
Object being watched.
vrpn_TextPrinter * me
Pointer to this, because used in a static function.
Class that handles text/warning/error printing for all objects in the system.
FILE * d_ostream
Output stream to use.
vrpn_TEXT_SEVERITY d_severity_to_print
Minimum severity to print.
vrpn_Semaphore d_semaphore
Mutex to ensure thread safety;.
vrpn_TextPrinter_Watch_Entry * d_first_watched_object
Head of list of objects being watched.
vrpn_uint32 d_level_to_print
Minimum level to print.
This structure is what is passed to a vrpn_Connection message callback.
vrpn_TEXT_SEVERITY
Since the sending of text messages has been pulled into the base class (so that every object can send...
const unsigned vrpn_MAX_TEXT_LEN
const int vrpn_MAX_BCADRS
Internal value for number of BaseClass addresses.
VRPN_API vrpn_TextPrinter & vrpn_System_TextPrinter
const int vrpn_ANY_SENDER
vrpn_ANY_SENDER can be used to register callbacks on a given message type from any sender.
int(VRPN_CALLBACK * vrpn_MESSAGEHANDLER)(void *userdata, vrpn_HANDLERPARAM p)
Type of a message handler for vrpn_Connection messages.
#define vrpn_gettimeofday