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