vrpn
07.33
Virtual Reality Peripheral Network
|
Class from which all user-level (and other) classes that communicate with vrpn_Connections should derive. More...
#include <vrpn_BaseClass.h>
Public Member Functions | |
vrpn_BaseClass (const char *name, vrpn_Connection *c=NULL) | |
Names the device and assigns or opens connection, calls registration methods. More... | |
virtual | ~vrpn_BaseClass () |
virtual void | mainloop ()=0 |
Called once through each main loop iteration to handle updates. Remote object mainloop() should call client_mainloop() and then call d_connection->mainloop(). Server object mainloop() should service the device and then call server_mainloop(), but should not normally call d_connection->mainloop(). More... | |
![]() | |
vrpn_BaseClassUnique () | |
virtual | ~vrpn_BaseClassUnique () |
Unregister all of the message handlers that were to be autodeleted. More... | |
vrpn_Connection * | connectionPtr () |
Returns a pointer to the connection this object is using. More... | |
Protected Member Functions | |
virtual int | init (void) |
Initialize things that the constructor can't. Returns 0 on success, -1 on failure. More... | |
virtual int | register_senders (void) |
Register the sender for this device (by default, the name of the device). Return 0 on success, -1 on fail. More... | |
virtual int | register_types (void)=0 |
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail. More... | |
![]() | |
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. More... | |
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. More... | |
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(vrpn_TEXT_WARNING) << "Value of i is: " << i; This use requires including vrpn_SendTextMessageStreamProxy.h. More... | |
void | server_mainloop (void) |
Handles functions that all servers should provide in their mainloop() (ping/pong, for example) Should be called by all servers in their mainloop() More... | |
void | client_mainloop (void) |
Handles functions that all clients should provide in their mainloop() (warning of no server, for example) Should be called by all clients in their mainloop() More... | |
Additional Inherited Members | |
![]() | |
bool | shutup |
vrpn_MESSAGEHANDLER | handler |
vrpn_int32 | sender |
vrpn_int32 | type |
void * | userdata |
![]() | |
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. More... | |
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. More... | |
![]() | |
vrpn_Connection * | d_connection |
Connection that this object talks to. More... | |
char * | d_servicename |
Name of this device, not including the connection part. More... | |
vrpn_int32 | d_sender_id |
Sender ID registered with the connection. More... | |
vrpn_int32 | d_text_message_id |
ID for text messages. More... | |
vrpn_int32 | d_ping_message_id |
Ask the server if they are there. More... | |
vrpn_int32 | d_pong_message_id |
Server telling that it is there. More... | |
Class from which all user-level (and other) classes that communicate with vrpn_Connections should derive.
Definition at line 313 of file vrpn_BaseClass.h.
vrpn_BaseClass::vrpn_BaseClass | ( | const char * | name, |
vrpn_Connection * | c = NULL |
||
) |
Names the device and assigns or opens connection, calls registration methods.
Assigns the connection passed in to the object, or else tries to create a new connection based on the object name.
If this succeeds, it calls the sender and type registration routines for the object. Sets the servicename field to be the part of the name coming before the "@" sign in the name.
vrpn_BaseClassUnique is a virtual base class so it will only be called once, while vrpn_BaseClass may be called multiple times. Setting d_connection and d_servicename, only needs to be done once for each object (even if it inherits from multiple device classes). So these things should technically go into the vrpn_BaseClassUnique constructor, except that it is unable to accept parameters. If the vrpn_BaseClassUnique constructor did* take the service-name, connnection, and use-ref-count parameters then every derived class (not just those at the top level) would have to make an explicit call to the vrpn_BaseClassUnique constructor. As it stands, these derived classes will instead use the 0-parameter version of the vrpn_BaseClassUnique constructor implicitly. As a result, this constructor must make sure that it only executes the code therein once.
Definition at line 312 of file vrpn_BaseClass.C.
References vrpn_Connection::addReference(), vrpn_BaseClassUnique::d_connection, vrpn_BaseClassUnique::d_servicename, vrpn_copy_service_name(), and vrpn_get_connection_by_name().
|
virtual |
Definition at line 350 of file vrpn_BaseClass.C.
References vrpn_TextPrinter::remove_object(), and vrpn_System_TextPrinter.
|
protectedvirtual |
Initialize things that the constructor can't. Returns 0 on success, -1 on failure.
This would normally be found in the constructor, but the constructor cannot call virtual functions in the derived class (since it does not yet exist).
This function needs to be called at the beginning of the constructor of each class that derives directly from vrpn_BaseClass ....(i.e. the top-level device classes such as Button, Analog, Tracker, etc)
Definition at line 363 of file vrpn_BaseClass.C.
References vrpn_TextPrinter::add_object(), vrpn_BaseClassUnique::d_connection, vrpn_BaseClassUnique::d_ping_message_id, vrpn_BaseClassUnique::d_pong_message_id, vrpn_BaseClassUnique::d_text_message_id, vrpn_Connection::register_message_type(), register_senders(), register_types(), and vrpn_System_TextPrinter.
Referenced by vrpn_Analog::vrpn_Analog(), vrpn_Analog_Output::vrpn_Analog_Output(), vrpn_Auxiliary_Logger::vrpn_Auxiliary_Logger(), vrpn_Button::vrpn_Button(), vrpn_Dial::vrpn_Dial(), vrpn_ForceDevice::vrpn_ForceDevice(), vrpn_FunctionGenerator::vrpn_FunctionGenerator(), vrpn_Imager::vrpn_Imager(), vrpn_ImagerPose::vrpn_ImagerPose(), vrpn_Poser::vrpn_Poser(), vrpn_RedundantController::vrpn_RedundantController(), vrpn_RedundantRemote::vrpn_RedundantRemote(), vrpn_Sound::vrpn_Sound(), vrpn_Text_Receiver::vrpn_Text_Receiver(), vrpn_Text_Sender::vrpn_Text_Sender(), vrpn_Tracker::vrpn_Tracker(), vrpn_YEI_3Space_Sensor::vrpn_YEI_3Space_Sensor(), and vrpn_YEI_3Space_Sensor_Wireless::vrpn_YEI_3Space_Sensor_Wireless().
|
pure virtual |
Called once through each main loop iteration to handle updates. Remote object mainloop() should call client_mainloop() and then call d_connection->mainloop(). Server object mainloop() should service the device and then call server_mainloop(), but should not normally call d_connection->mainloop().
Implemented in vrpn_Microsoft_Controller_Raw, vrpn_CHProducts_Controller_Raw, vrpn_Contour, vrpn_Futaba, vrpn_Griffin, vrpn_Logitech_Controller_Raw, vrpn_Saitek_Controller_Raw, vrpn_Retrolink, vrpn_ImagerPose_Remote, vrpn_Imager_Remote, vrpn_Imager_Stream_Buffer, vrpn_ImagerPose_Server, vrpn_Imager_Server, vrpn_Auxiliary_Logger_Remote, vrpn_Auxiliary_Logger_Server_Generic, vrpn_RedundantRemote, vrpn_Microsoft_Controller_Raw_Xbox_360, vrpn_Button_SerialMouse, vrpn_RedundantController, vrpn_Microsoft_Controller_Raw_Xbox_S, vrpn_Text_Receiver, vrpn_Microsoft_SideWinder, vrpn_Auxiliary_Logger_Server, vrpn_Retrolink_GameCube, vrpn_Freespace, vrpn_Microsoft_SideWinder_Precision_2, vrpn_CHProducts_Fighterstick_USB, vrpn_Contour_ShuttleXpress, vrpn_Futaba_InterLink_Elite, vrpn_Griffin_PowerMate, vrpn_Logitech_Extreme_3D_Pro, vrpn_Saitek_ST290_Pro, vrpn_Text_Sender, vrpn_Event_Mouse, vrpn_Tracker_JoyFly, vrpn_ImmersionBox, vrpn_Tng3, vrpn_Joylin, vrpn_Joystick, vrpn_Wanda, vrpn_Xkeys, vrpn_DreamCheeky, vrpn_ForceDevice_Remote, vrpn_Tracker_Remote, vrpn_FunctionGenerator_Remote, vrpn_Sound_Client, vrpn_Button_Remote, vrpn_Tracker_Server, vrpn_Tracker_NULL, vrpn_FunctionGenerator_Server, vrpn_Tracker_USB, vrpn_Button_PinchGlove, vrpn_Analog_Remote, vrpn_Tracker_Serial, vrpn_Button_Python, vrpn_Analog_Output_Remote, vrpn_Poser_Remote, vrpn_WiiMote, vrpn_Xkeys_XK3, vrpn_Tracker_ButtonFly, vrpn_Button_Example_Server, vrpn_inertiamouse, vrpn_Analog_Server, vrpn_Tracker_AnalogFly, vrpn_Xkeys_Jog_And_Shuttle, vrpn_Analog_Output_Server_NI, vrpn_Tracker_DTrack, vrpn_Button_Server, vrpn_Poser_Server, vrpn_Tracker_WiimoteHead, vrpn_Xkeys_Joystick, vrpn_Dial_Remote, vrpn_Tracker_NDI_Polaris, vrpn_Tracker_RazerHydra, vrpn_Poser_Analog, vrpn_Atmel, vrpn_Tracker_Flock_Parallel_Slave, vrpn_Xkeys_Pro, vrpn_Tracker_OSVRHackerDevKit, vrpn_Analog_USDigital_A2, vrpn_Button_5DT_Server, vrpn_Button_NI_DIO24, vrpn_Mouse, vrpn_Xkeys_Desktop, vrpn_Analog_Output_Server, vrpn_Tracker_Flock_Parallel, vrpn_Analog_5dtUSB, vrpn_IDEA, vrpn_Dial_Example_Server, vrpn_DreamCheeky_Drum_Kit, vrpn_Tracker_InterSense, vrpn_Tracker_TrivisioColibri, vrpn_National_Instruments_Server, vrpn_Tracker_FilterOneEuro, vrpn_YEI_3Space, vrpn_LUDL_USBMAC6000, vrpn_BiosciencesTools, vrpn_Tracker_MotionNode, vrpn_Tracker_PhaseSpace, vrpn_3DConnexion, vrpn_5dt, vrpn_Tracker_Crossbow, vrpn_ADBox, vrpn_Poser_Tek4662, vrpn_GlobalHapticsOrb, vrpn_Tracker_SpacePoint, vrpn_raw_SGIBox, vrpn_3DMicroscribe, vrpn_5dt16, vrpn_CerealBox, vrpn_Keyboard, vrpn_Tracker_GameTrak, vrpn_Tracker_Wintracker, vrpn_Tracker_3DMouse, vrpn_VPJoystick, vrpn_Magellan, vrpn_Spaceball, vrpn_Radamec_SPI, vrpn_Zaber, and vrpn_Nikon_Controls.
|
protectedvirtual |
Register the sender for this device (by default, the name of the device). Return 0 on success, -1 on fail.
Registers the senders (usually only one, that part of the name of the device coming before the "@" sign).
For example, the sender for Track is Tracker0. Both the remote device and the server device will register the same sender. If for some reason, there is a different sender or more than one sender, this function should be overridden by both the remote and server objects. er0@ mumbl e.cs .unc. edu
This routine returns 0 on success and -1 on failure.
Definition at line 427 of file vrpn_BaseClass.C.
References vrpn_BaseClassUnique::d_connection, vrpn_BaseClassUnique::d_sender_id, vrpn_BaseClassUnique::d_servicename, and vrpn_Connection::register_sender().
Referenced by init().
|
protectedpure virtual |
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
Implemented in vrpn_ImagerPose, vrpn_ForceDevice, vrpn_Sound, vrpn_Imager, vrpn_RedundantRemote, vrpn_Tracker, vrpn_RedundantController, vrpn_Text_Receiver, vrpn_LUDL_USBMAC6000, vrpn_Text_Sender, vrpn_Microsoft_Controller_Raw, vrpn_Xkeys, vrpn_Button, vrpn_Poser, vrpn_Analog_Output, vrpn_Analog, vrpn_Contour, vrpn_Futaba, vrpn_Griffin, vrpn_CHProducts_Controller_Raw, vrpn_Logitech_Controller_Raw, vrpn_Saitek_Controller_Raw, vrpn_DreamCheeky, vrpn_Retrolink, vrpn_Auxiliary_Logger, vrpn_Dial, and vrpn_FunctionGenerator.
Referenced by init().