145 vrpn_uint32 level = 0);
214 , _severity(other._severity)
220 struct timeval timestamp;
222 return _p->send_text_message(msg, timestamp, _severity);
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);
365#pragma warning(disable : 4251)
370 const CALLBACK_STRUCT info);
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");
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;
488 fprintf(stderr,
"vrpn_Callback_List::~vrpn_Callback_List: delete failed\n");
496 typedef struct vrpn_CBS {
SendTextMessageBoundCall(SendTextMessageBoundCall const &other)
SendTextMessageBoundCall(vrpn_BaseClassUnique *device, vrpn_TEXT_SEVERITY type)
int operator()(const char *msg) const
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.
vrpn_Connection * connectionPtr()
Returns a pointer to the connection this object is using.
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.
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.
friend class VRPN_API vrpn_TextPrinter
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.
static 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.
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_senders(void)
Register the sender for this device (by default, the name of the device). Return 0 on success,...
virtual int register_types(void)=0
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
vrpn_BaseClass(const char *name, vrpn_Connection *c=NULL)
Names the device and assigns or opens connection, calls registration methods.
virtual int init(void)
Initialize things that the constructor can't. Returns 0 on success, -1 on failure.
void(VRPN_CALLBACK * HANDLER_TYPE)(void *userdata, const CALLBACK_STRUCT info)
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.
static int VRPN_CALLBACK text_message_handler(void *userdata, vrpn_HANDLERPARAM p)
Handles the text messages that come from the connections for objects we are watching.
vrpn_TEXT_SEVERITY d_severity_to_print
Minimum severity to print.
vrpn_Semaphore d_semaphore
Mutex to ensure thread safety;.
void set_ostream_to_use(FILE *o)
Change the ostream that will be used to print messages. Setting a NULL ostream results in no printing...
void remove_object(vrpn_BaseClass *o)
Remove an object from the list of watched objects (multiple deletions of the object will not cause an...
vrpn_TextPrinter_Watch_Entry * d_first_watched_object
Head of list of objects being watched.
int add_object(vrpn_BaseClass *o)
Adds an object to the list of watched objects (multiple registration of the same object will result i...
void set_min_level_to_print(vrpn_TEXT_SEVERITY severity, vrpn_uint32 level=0)
Change the level of printing for the object (sets the minimum level to print). Default is Warnings an...
vrpn_uint32 d_level_to_print
Minimum level to print.
This structure is what is passed to a vrpn_Connection message callback.
vrpn_TextPrinter & vrpn_System_TextPrinter
class VRPN_API vrpn_BaseClass
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.
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