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