Panda3D
Loading...
Searching...
No Matches
vrpnClient.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file vrpnClient.h
10 * @author jason
11 * @date 2000-08-04
12 */
13
14#ifndef VRPNCLIENT_H
15#define VRPNCLIENT_H
16
17#include "pandabase.h"
18#include "clientBase.h"
19
20#include "vrpn_interface.h"
21
22class VrpnTracker;
24class VrpnButton;
26class VrpnAnalog;
28class VrpnDial;
29class VrpnDialDevice;
30
31/**
32 * A specific ClientBase that connects to a VRPN server and records
33 * information on the connected VRPN devices.
34 */
35class EXPCL_VRPN VrpnClient : public ClientBase {
36PUBLISHED:
37 explicit VrpnClient(const std::string &server_name);
39
40 INLINE const std::string &get_server_name() const;
41 bool is_valid() const;
42 bool is_connected() const;
43
44 void write(std::ostream &out, int indent_level = 0) const;
45
46public:
47 INLINE static double convert_to_secs(struct timeval msg_time);
48
49protected:
50 virtual PT(ClientDevice) make_device(TypeHandle device_type,
51 const std::string &device_name);
52
53 virtual bool disconnect_device(TypeHandle device_type,
54 const std::string &device_name,
55 ClientDevice *device);
56
57 virtual void do_poll();
58
59private:
60 PT(ClientDevice) make_tracker_device(const std::string &device_name);
61 PT(ClientDevice) make_button_device(const std::string &device_name);
62 PT(ClientDevice) make_analog_device(const std::string &device_name);
63 PT(ClientDevice) make_dial_device(const std::string &device_name);
64 void disconnect_tracker_device(VrpnTrackerDevice *device);
65 void disconnect_button_device(VrpnButtonDevice *device);
66 void disconnect_analog_device(VrpnAnalogDevice *device);
67 void disconnect_dial_device(VrpnDialDevice *device);
68
69 VrpnTracker *get_tracker(const std::string &tracker_name);
70 void free_tracker(VrpnTracker *vrpn_tracker);
71
72 VrpnButton *get_button(const std::string &button_name);
73 void free_button(VrpnButton *vrpn_button);
74
75 VrpnAnalog *get_analog(const std::string &analog_name);
76 void free_analog(VrpnAnalog *vrpn_analog);
77
78 VrpnDial *get_dial(const std::string &dial_name);
79 void free_dial(VrpnDial *vrpn_dial);
80
81private:
82 std::string _server_name;
83 vrpn_Connection *_connection;
84
89
90 Trackers _trackers;
91 Buttons _buttons;
92 Analogs _analogs;
93 Dials _dials;
94
95
96public:
97 static TypeHandle get_class_type() {
98 return _type_handle;
99 }
100 static void init_type() {
101 ClientBase::init_type();
102 register_type(_type_handle, "VrpnClient",
103 ClientBase::get_class_type());
104 }
105 virtual TypeHandle get_type() const {
106 return get_class_type();
107 }
108 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
109
110private:
111 static TypeHandle _type_handle;
112};
113
114#include "vrpnClient.I"
115
116#endif
An abstract base class for a family of client device interfaces–including trackers,...
Definition clientBase.h:43
Any of a number of different devices that might be attached to a ClientBase, including trackers,...
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
The Panda interface to a VRPN analog device.
This is the actual interface to a particular VRPN analog device, and all of its numbered controls.
Definition vrpnAnalog.h:38
The Panda interface to a VRPN button.
This is the actual interface to a particular VRPN button device, and all of its numbered buttons.
Definition vrpnButton.h:37
A specific ClientBase that connects to a VRPN server and records information on the connected VRPN de...
Definition vrpnClient.h:35
The Panda interface to a VRPN dial device.
This is the actual interface to a particular VRPN dial device, and all of its numbered dials.
Definition vrpnDial.h:37
The Panda interface to a VRPN tracker.
This is the actual interface to a particular VRPN tracker object, and all of its sensors.
Definition vrpnTracker.h:37
This is our own Panda specialization on the default STL map.
Definition pmap.h:49
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool is_connected(MObject &node, const string &attribute_name)
Returns true if the named connection exists on the node and is connected to anything,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.