vrpn
07.33
Virtual Reality Peripheral Network
|
Go to the documentation of this file.
16 #ifndef VRPN_BASECLASS
17 #define VRPN_BASECLASS
145 vrpn_uint32 level = 0);
149 void set_ostream_to_use(FILE *o);
211 , _severity(other._severity)
217 struct timeval timestamp;
239 int register_autodeleted_handler(vrpn_int32 type,
246 static int encode_text_message_to_buffer(
char *buf,
252 static int decode_text_message_from_buffer(
char *msg,
258 int send_text_message(
const char *msg,
struct timeval timestamp,
260 vrpn_uint32 level = 0);
275 void server_mainloop(
void);
280 void client_mainloop(
void);
289 int d_num_autodeletions;
291 int d_first_mainloop;
292 struct timeval d_time_first_ping;
297 int d_unanswered_ping;
306 void initiate_ping_cycle(
void);
333 virtual int init(
void);
337 virtual int register_senders(
void);
362 #pragma warning(disable : 4251)
367 const CALLBACK_STRUCT info);
374 current = d_change_list;
375 while (current != NULL) {
376 next = current->
next;
384 while (current != NULL) {
386 current = current->
next;
396 if (handler == NULL) {
398 "vrpn_Callback_List::register_handler(): NULL handler\n");
405 "vrpn_Callback_List::register_handler(): Out of memory\n");
413 new_entry->
next = d_change_list;
414 d_change_list = new_entry;
427 snitch = &d_change_list;
429 while ((victim != NULL) && ((victim->
handler != handler) ||
431 snitch = &((*snitch)->next);
432 victim = victim->
next;
436 if (victim == NULL) {
439 "vrpn_Callback_List::unregister_handler: No such handler\n");
444 *snitch = victim->
next;
454 while (handler != NULL) {
456 handler = handler->
next;
462 : d_change_list(NULL){};
467 while (d_change_list != NULL) {
469 delete d_change_list;
470 d_change_list = next;
475 typedef struct vrpn_CBS {
vrpn_int32 d_ping_message_id
Ask the server if they are there.
const unsigned vrpn_MAX_TEXT_LEN
VRPN_API vrpn_TextPrinter vrpn_System_TextPrinter
Definition of the system TextPrinter object that prints messages for all created objects.
vrpn_uint32 d_level_to_print
Minimum level to print.
vrpn_int32 d_text_message_id
ID for text messages.
int register_handler(void *userdata, HANDLER_TYPE handler)
Call this to add a handler to the list.
vrpn_Callback_List()
The list starts out empty.
vrpn_TEXT_SEVERITY d_severity_to_print
Minimum severity to print.
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...
class VRPN_API vrpn_BaseClass
This structure is what is passed to a vrpn_Connection message callback.
INTERNAL class to hold members that there should only be one copy of even when a class inherits from ...
vrpn_int32 d_sender_id
Sender ID registered with the connection.
vrpn_Semaphore d_semaphore
Mutex to ensure thread safety;.
virtual void mainloop()=0
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
vrpn_TextPrinter * me
Pointer to this, because used in a static function.
Generic connection class not specific to the transport mechanism.
vrpn_Connection * connectionPtr()
Returns a pointer to the connection this object is using.
vrpn_BaseClass * obj
Object being watched.
#define vrpn_gettimeofday
void operator=(const vrpn_Callback_List &from)
This class requires deep copies.
const int vrpn_ANY_SENDER
vrpn_ANY_SENDER can be used to register callbacks on a given message type from any sender.
virtual int register_types(void)=0
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
FILE * d_ostream
Output stream to use.
int(VRPN_CALLBACK * vrpn_MESSAGEHANDLER)(void *userdata, vrpn_HANDLERPARAM p)
Type of a message handler for vrpn_Connection messages.
SendTextMessageBoundCall(vrpn_BaseClassUnique *device, vrpn_TEXT_SEVERITY type)
Structure to hold the objects that are being watched.
int operator()(const char *msg) const
vrpn_TEXT_SEVERITY
Since the sending of text messages has been pulled into the base class (so that every object can send...
SendTextMessageBoundCall(SendTextMessageBoundCall const &other)
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.
char * d_servicename
Name of this device, not including the connection part.
Class that handles text/warning/error printing for all objects in the system.
void call_handlers(const CALLBACK_STRUCT &info)
This will pass the referenced parameter as a const to all the callbacks.
~vrpn_Callback_List()
Clear the list upon destruction if it is not empty already.
vrpn_int32 d_pong_message_id
Server telling that it is there.
int unregister_handler(void *userdata, HANDLER_TYPE handler)
Call this to remove a handler from the list (if it exists)
vrpn_TextPrinter_Watch_Entry * next
Pointer to the next one in the list.
vrpn_TextPrinter_Watch_Entry * d_first_watched_object
Head of list of objects being watched.
Class from which all user-level (and other) classes that communicate with vrpn_Connections should der...
CHANGELIST_ENTRY * d_change_list
const int vrpn_MAX_BCADRS
Internal value for number of BaseClass addresses.
vrpn_MESSAGEHANDLER handler