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