RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_Text.h
1/* vrpn_Text.h
2 Definition of user-level access to the text sending and retrieving
3 functions within VRPN. These are wrappers around the vrpn_BaseClass
4 routines, since basic text functions have been pulled into these
5 classes.
6*/
7
8#ifndef VRPN_TEXT_H
9#define VRPN_TEXT_H
10#include <stddef.h> // for NULL
11
12#include "vrpn_BaseClass.h" // for vrpn_BaseClass, etc
13#include "vrpn_Configure.h" // for VRPN_API, VRPN_CALLBACK
14#include "vrpn_Connection.h" // for vrpn_Connection, etc
15#include "vrpn_Shared.h" // for timeval
16#include "vrpn_Types.h" // for vrpn_uint32
17
18// text-message time value meaning "go find out what time it is right now"
19const struct timeval vrpn_TEXT_NOW = {0, 0};
20
22typedef struct _vrpn_TEXTCB {
23 struct timeval msg_time; // Time of the message
24 char message[vrpn_MAX_TEXT_LEN]; // The message
26 vrpn_uint32 level;
28
30typedef void(VRPN_CALLBACK *vrpn_TEXTHANDLER)(void *userdata,
31 const vrpn_TEXTCB info);
32
33//----------------------------------------------------------
34//************** Users deal with the following *************
35
37// the send_text_message() function is protected). It provides
38// the needed function definitions for vrpn_BaseClass.
39
40class VRPN_API vrpn_Text_Sender : public vrpn_BaseClass {
41public:
42 vrpn_Text_Sender(const char *name, vrpn_Connection *c = NULL)
43 : vrpn_BaseClass(name, c)
44 {
45 init();
46 };
47
49 void mainloop(void)
50 {
52 if (d_connection) d_connection->mainloop();
53 };
54
56 int send_message(const char *msg,
57 vrpn_TEXT_SEVERITY type = vrpn_TEXT_NORMAL,
58 vrpn_uint32 level = 0,
59 const struct timeval time = vrpn_TEXT_NOW);
60
61protected:
63 virtual int register_types(void) { return 0; };
64};
65
67// standard VRPN printing functions handle them.
68
69class VRPN_API vrpn_Text_Receiver : public vrpn_BaseClass {
70public:
71 vrpn_Text_Receiver(const char *name, vrpn_Connection *c = NULL);
72 virtual ~vrpn_Text_Receiver(void);
73 virtual int register_message_handler(void *userdata,
74 vrpn_TEXTHANDLER handler)
75 {
76 return d_callback_list.register_handler(userdata, handler);
77 };
78
79 virtual int unregister_message_handler(void *userdata,
80 vrpn_TEXTHANDLER handler)
81 {
82 return d_callback_list.unregister_handler(userdata, handler);
83 }
84
85 virtual void mainloop(void)
86 {
87 if (d_connection) {
88 d_connection->mainloop();
89 };
91 };
92
93protected:
94 static int VRPN_CALLBACK
95 handle_message(void *userdata, vrpn_HANDLERPARAM p);
96 vrpn_Callback_List<vrpn_TEXTCB> d_callback_list;
97
99 virtual int register_types(void) { return 0; };
100};
101
102#endif
void server_mainloop(void)
void client_mainloop(void)
定义 vrpn_BaseClass.h:310
virtual int init(void)
定义 vrpn_BaseClass.h:361
Generic connection class not specific to the transport mechanism.
定义 vrpn_Connection.h:562
Allows a user to handle text messages directly, in addition to having the
定义 vrpn_Text.h:69
virtual void mainloop(void)
定义 vrpn_Text.h:85
virtual int register_types(void)
No types to register beyond the text, which is done in BaseClass.
定义 vrpn_Text.h:99
Allows a user to send text messages from a device (usually,
定义 vrpn_Text.h:40
void mainloop(void)
Mainloop the connection to send the message.
定义 vrpn_Text.h:49
int send_message(const char *msg, vrpn_TEXT_SEVERITY type=vrpn_TEXT_NORMAL, vrpn_uint32 level=0, const struct timeval time=vrpn_TEXT_NOW)
Send a text message.
virtual int register_types(void)
No types to register beyond the text, which is done in BaseClass.
定义 vrpn_Text.h:63
Structure passed back to user-level code from a vrpn_Text_Receiver.
定义 vrpn_Text.h:22
This structure is what is passed to a vrpn_Connection message callback.
定义 vrpn_Connection.h:41
vrpn_TEXT_SEVERITY
定义 vrpn_BaseClass.h:100