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