Panda3D
vrpnTracker.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 vrpnTracker.h
10  * @author drose
11  * @date 2001-01-25
12  */
13 
14 #ifndef VRPNTRACKER_H
15 #define VRPNTRACKER_H
16 
17 #include "pandabase.h"
18 
19 #include "vrpn_interface.h"
20 
21 #include "pvector.h"
22 
23 class VrpnTrackerDevice;
24 
25 /**
26  * This is the actual interface to a particular VRPN tracker object, and all
27  * of its sensors. A pointer to this object is stored in the VrpnClient class
28  * for each differently-named VRPN tracker we connect to.
29  *
30  * The VRPN callbacks go here, which in turn get vectored out to any
31  * VrpnTrackerDevice objects that register with this. When the last
32  * VrpnTrackerDevice object unregisters, the VrpnTracker will be deleted by
33  * the VrpnClient.
34  *
35  * This class does not need to be exported from the DLL.
36  */
37 class VrpnTracker {
38 public:
39  VrpnTracker(const std::string &tracker_name, vrpn_Connection *connection);
40  ~VrpnTracker();
41 
42  INLINE const std::string &get_tracker_name() const;
43  INLINE bool is_empty() const;
44 
45  void mark(VrpnTrackerDevice *device);
46  void unmark(VrpnTrackerDevice *device);
47 
48  void poll();
49 
50  void output(std::ostream &out) const;
51  void write(std::ostream &out, int indent_level = 0) const;
52 
53 private:
54  static void VRPN_CALLBACK
55  vrpn_position_callback(void *userdata, const vrpn_TRACKERCB info);
56  static void VRPN_CALLBACK
57  vrpn_velocity_callback(void *userdata, const vrpn_TRACKERVELCB info);
58  static void VRPN_CALLBACK
59  vrpn_acceleration_callback(void *userdata, const vrpn_TRACKERACCCB info);
60 
61 private:
62  std::string _tracker_name;
63  vrpn_Tracker_Remote *_tracker;
64 
66  Devices _devices;
67 };
68 
69 INLINE std::ostream &operator << (std::ostream &out, const VrpnTracker &tracker) {
70  tracker.output(out);
71  return out;
72 }
73 
74 #include "vrpnTracker.I"
75 
76 #endif
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
bool is_empty() const
Returns true if no VrpnTrackerDevices reference this VrpnTracker, or false otherwise.
Definition: vrpnTracker.I:28
void mark(VrpnTrackerDevice *device)
Adds the indicated VrpnTrackerDevice to the list of devices that are sharing this VrpnTracker.
Definition: vrpnTracker.cxx:50
const std::string & get_tracker_name() const
Returns the name of the tracker device that was used to create this VrpnTracker.
Definition: vrpnTracker.I:19
void unmark(VrpnTrackerDevice *device)
Removes the indicated VrpnTrackerDevice from the list of devices that are sharing this VrpnTracker.
Definition: vrpnTracker.cxx:62
void poll()
Polls the connected device.
Definition: vrpnTracker.cxx:80
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.