RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_Forwarder.h
1#ifndef VRPN_FORWARDER_H
2#define VRPN_FORWARDER_H
3
4#include "vrpn_Configure.h" // for VRPN_API, VRPN_CALLBACK
5#include "vrpn_Connection.h" // for vrpn_Connection (ptr only), etc
6#include "vrpn_Types.h" // for vrpn_int32, vrpn_uint32
7
8// vrpn_Forwarder
9// Tom Hudson, August 1998
10//
11// Class to take messages from one VRPN connection and send them out
12// on another.
13
14// Design decisions:
15// Scale of forwarding:
16// Could write a forwarder per stream (serviceName per instantiation)
17// or per connection (serviceName per forward() call). Latter is
18// more flexible, but takes up more memory if few distinct streams need
19// to be forwarded, has a clunkier syntax, ...
20// Flexibility of naming:
21// We allow users to take in a message of one name and send it out
22// with another name; this is useful and dangerous.
23
24// Faults:
25// There is currently no way to specify vrpn_SENDER_ANY as a source.
26// If we do, it isn't clear what sender to specify to the destination.
27
29
30public:
31 // Set up to forward messages from <source> to <destination>
33 vrpn_Connection *destination);
34
36
37 // Begins forwarding of a message type.
38 // Forwards messages of type <sourceName> and sender <sourceServiceName>,
39 // sending them out as type <destinationName> from sender
40 // <destinationServiceName>.
41 // Return nonzero on failure.
42 int forward(const char *sourceName, const char *sourceServiceName,
43 const char *destinationName, const char *destinationServiceName,
44 vrpn_uint32 classOfService = vrpn_CONNECTION_RELIABLE);
45
46 // Stops forwarding of a message type.
47 // Return nonzero on failure.
48 int unforward(const char *sourceName, const char *sourceServiceName,
49 const char *destinationName,
50 const char *destinationServiceName,
51 vrpn_uint32 classOfService = vrpn_CONNECTION_RELIABLE);
52
53private:
54 static int VRPN_CALLBACK handle_message(void *, vrpn_HANDLERPARAM);
55
56 // Translates (id, serviceId) from source to destination
57 // and looks up intended class of service.
58 // Returns nonzero if lookup fails.
59 vrpn_int32 map(vrpn_int32 *id, vrpn_int32 *serviceId,
60 vrpn_uint32 *serviceClass);
61
62 vrpn_Connection *d_source;
63 vrpn_Connection *d_destination;
64
65 struct vrpn_CONNECTIONFORWARDERRECORD {
66
67 vrpn_CONNECTIONFORWARDERRECORD(vrpn_Connection *, vrpn_Connection *,
68 const char *, const char *, const char *,
69 const char *, vrpn_uint32);
70
71 vrpn_int32 sourceId; // source's type id
72 vrpn_int32 sourceServiceId; // source's sender id
73 vrpn_int32 destinationId; // destination's type id
74 vrpn_int32 destinationServiceId; // destination's sender id
75 vrpn_uint32 classOfService; // class of service to send
76
77 vrpn_CONNECTIONFORWARDERRECORD *next;
78 };
79
80 vrpn_CONNECTIONFORWARDERRECORD *d_list;
81};
82
83class VRPN_API vrpn_StreamForwarder {
84
85public:
86 // Set up to forward messages from sender <sourceServiceName> on <source>
87 // to <destination>, as if from sender <destinationServiceName>
88 vrpn_StreamForwarder(vrpn_Connection *source, const char *sourceServiceName,
89 vrpn_Connection *destination,
90 const char *destinationServiceName);
91
93
94 // Begins forwarding of a message type.
95 // Return nonzero on failure.
96 int forward(const char *sourceName, const char *destinationName,
97 vrpn_uint32 classOfService = vrpn_CONNECTION_RELIABLE);
98
99 // Stops forwarding of a message type.
100 // Return nonzero on failure.
101 int unforward(const char *sourceName, const char *destinationName,
102 vrpn_uint32 classOfService = vrpn_CONNECTION_RELIABLE);
103
104private:
105 static int VRPN_CALLBACK handle_message(void *, vrpn_HANDLERPARAM);
106
107 // Translates (id, serviceId) from source to destination
108 // and looks up intended class of service.
109 // Returns nonzero if lookup fails.
110 vrpn_int32 map(vrpn_int32 *id, vrpn_uint32 *serviceClass);
111
112 vrpn_Connection *d_source;
113 vrpn_int32 d_sourceService;
114 vrpn_Connection *d_destination;
115 vrpn_int32 d_destinationService;
116
117 struct vrpn_STREAMFORWARDERRECORD {
118
119 vrpn_STREAMFORWARDERRECORD(vrpn_Connection *, vrpn_Connection *,
120 const char *, const char *, vrpn_uint32);
121
122 vrpn_int32 sourceId; // source's type id
123 vrpn_int32 destinationId; // destination's type id
124 vrpn_uint32 classOfService; // class of service to send
125
126 vrpn_STREAMFORWARDERRECORD *next;
127 };
128
129 vrpn_STREAMFORWARDERRECORD *d_list;
130};
131
132#endif // VRPN_FORWARDER_H
定义 vrpn_Forwarder.h:28
Generic connection class not specific to the transport mechanism.
定义 vrpn_Connection.h:562
定义 vrpn_Forwarder.h:83
This structure is what is passed to a vrpn_Connection message callback.
定义 vrpn_Connection.h:41