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