vrpn
07.33
Virtual Reality Peripheral Network
|
Class that handles text/warning/error printing for all objects in the system. More...
#include <vrpn_BaseClass.h>
Classes | |
class | vrpn_TextPrinter_Watch_Entry |
Structure to hold the objects that are being watched. More... | |
Public Member Functions | |
vrpn_TextPrinter () | |
~vrpn_TextPrinter () | |
Deletes any callbacks that are still registered. More... | |
int | add_object (vrpn_BaseClass *o) |
Adds an object to the list of watched objects (multiple registration of the same object will result in only one printing for each message from the object). Returns 0 on success and -1 on failure. YOU MUST REMOVE any objects from a vrpn_TextPrinter that you create before destroying the printer if any connection objects survive, otherwise they may call a callback function on the destroyed object. More... | |
void | remove_object (vrpn_BaseClass *o) |
Remove an object from the list of watched objects (multiple deletions of the object will not cause any error condition; deletions of unregistered objects will not cause errors). More... | |
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 and Errors of all levels. More... | |
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. More... | |
Static Protected Member Functions | |
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. More... | |
Protected Attributes | |
vrpn_Semaphore | d_semaphore |
Mutex to ensure thread safety;. More... | |
vrpn_TextPrinter_Watch_Entry * | d_first_watched_object |
Head of list of objects being watched. More... | |
FILE * | d_ostream |
Output stream to use. More... | |
vrpn_TEXT_SEVERITY | d_severity_to_print |
Minimum severity to print. More... | |
vrpn_uint32 | d_level_to_print |
Minimum level to print. More... | |
Class that handles text/warning/error printing for all objects in the system.
Definition at line 124 of file vrpn_BaseClass.h.
vrpn_TextPrinter::vrpn_TextPrinter | ( | ) |
Definition at line 17 of file vrpn_BaseClass.C.
vrpn_TextPrinter::~vrpn_TextPrinter | ( | ) |
Deletes any callbacks that are still registered.
Definition at line 26 of file vrpn_BaseClass.C.
References vrpn_BaseClassUnique::connectionPtr(), d_first_watched_object, d_semaphore, vrpn_BaseClassUnique::d_sender_id, vrpn_BaseClassUnique::d_text_message_id, vrpn_TextPrinter::vrpn_TextPrinter_Watch_Entry::next, vrpn_TextPrinter::vrpn_TextPrinter_Watch_Entry::obj, vrpn_Semaphore::p(), text_message_handler(), vrpn_Connection::unregister_handler(), and vrpn_Semaphore::v().
int vrpn_TextPrinter::add_object | ( | vrpn_BaseClass * | o | ) |
Adds an object to the list of watched objects (multiple registration of the same object will result in only one printing for each message from the object). Returns 0 on success and -1 on failure. YOU MUST REMOVE any objects from a vrpn_TextPrinter that you create before destroying the printer if any connection objects survive, otherwise they may call a callback function on the destroyed object.
Adds an object to the list of watched objects.
Returns 0 on success and -1 on failure. Registering a watched object is idempotent: doing so again for an already-registered object has no effect, nor is it an error. Objects are considered to be the same if they share the same connection and they have the same service name. What we're going for here is to get only one print-out of any message.
Definition at line 67 of file vrpn_BaseClass.C.
References vrpn_BaseClassUnique::d_connection, d_first_watched_object, d_semaphore, vrpn_BaseClassUnique::d_sender_id, vrpn_BaseClassUnique::d_servicename, vrpn_BaseClassUnique::d_text_message_id, vrpn_TextPrinter::vrpn_TextPrinter_Watch_Entry::me, vrpn_TextPrinter::vrpn_TextPrinter_Watch_Entry::next, vrpn_TextPrinter::vrpn_TextPrinter_Watch_Entry::obj, vrpn_Semaphore::p(), vrpn_Connection::register_handler(), text_message_handler(), and vrpn_Semaphore::v().
Referenced by vrpn_BaseClass::init().
void vrpn_TextPrinter::remove_object | ( | vrpn_BaseClass * | o | ) |
Remove an object from the list of watched objects (multiple deletions of the object will not cause any error condition; deletions of unregistered objects will not cause errors).
Removes an object from the list of watched objects.
Returns 0 on success and -1 on failure. Unregistering a non-watched object has no effect, nor is it an error. Objects are considered to be the same if they share the same connection and they have the same service name.
Definition at line 132 of file vrpn_BaseClass.C.
References vrpn_BaseClassUnique::d_connection, d_first_watched_object, d_semaphore, vrpn_BaseClassUnique::d_sender_id, vrpn_BaseClassUnique::d_servicename, vrpn_BaseClassUnique::d_text_message_id, vrpn_TextPrinter::vrpn_TextPrinter_Watch_Entry::next, vrpn_TextPrinter::vrpn_TextPrinter_Watch_Entry::obj, vrpn_Semaphore::p(), text_message_handler(), vrpn_Connection::unregister_handler(), and vrpn_Semaphore::v().
Referenced by vrpn_BaseClass::~vrpn_BaseClass().
void vrpn_TextPrinter::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 and Errors of all levels.
Definition at line 267 of file vrpn_BaseClass.C.
References d_level_to_print, d_semaphore, d_severity_to_print, vrpn_Semaphore::p(), and vrpn_Semaphore::v().
void vrpn_TextPrinter::set_ostream_to_use | ( | FILE * | o | ) |
Change the ostream that will be used to print messages. Setting a NULL ostream results in no printing.
Definition at line 278 of file vrpn_BaseClass.C.
References d_ostream, d_semaphore, vrpn_Semaphore::p(), and vrpn_Semaphore::v().
|
staticprotected |
Handles the text messages that come from the connections for objects we are watching.
Prints out a text message that comes in, identifying the severity, level and sender of the message.
The message is not printed if the severity or level do not pass the threshold for severity or level.
Definition at line 199 of file vrpn_BaseClass.C.
References vrpn_HANDLERPARAM::buffer, vrpn_BaseClassUnique::d_connection, d_level_to_print, d_ostream, d_semaphore, d_severity_to_print, vrpn_BaseClassUnique::decode_text_message_from_buffer(), vrpn_TextPrinter::vrpn_TextPrinter_Watch_Entry::me, vrpn_TextPrinter::vrpn_TextPrinter_Watch_Entry::obj, vrpn_Semaphore::p(), vrpn_HANDLERPARAM::sender, vrpn_Connection::sender_name(), vrpn_Semaphore::v(), vrpn_MAX_TEXT_LEN, vrpn_TEXT_ERROR, vrpn_TEXT_NORMAL, and vrpn_TEXT_WARNING.
Referenced by add_object(), remove_object(), and ~vrpn_TextPrinter().
|
protected |
Head of list of objects being watched.
Definition at line 164 of file vrpn_BaseClass.h.
Referenced by add_object(), remove_object(), and ~vrpn_TextPrinter().
|
protected |
Minimum level to print.
Definition at line 169 of file vrpn_BaseClass.h.
Referenced by set_min_level_to_print(), and text_message_handler().
|
protected |
Output stream to use.
Definition at line 167 of file vrpn_BaseClass.h.
Referenced by set_ostream_to_use(), and text_message_handler().
|
protected |
Mutex to ensure thread safety;.
Definition at line 153 of file vrpn_BaseClass.h.
Referenced by add_object(), remove_object(), set_min_level_to_print(), set_ostream_to_use(), text_message_handler(), and ~vrpn_TextPrinter().
|
protected |
Minimum severity to print.
Definition at line 168 of file vrpn_BaseClass.h.
Referenced by set_min_level_to_print(), and text_message_handler().