Panda3D

vrpnDial.h

00001 // Filename: vrpnDial.h
00002 // Created by:  drose (26Jan01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef VRPNDIAL_H
00016 #define VRPNDIAL_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "vrpn_interface.h"
00021 
00022 #include "pvector.h"
00023 
00024 class VrpnDialDevice;
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //       Class : VrpnDial
00028 // Description : This is the actual interface to a particular VRPN
00029 //               dial device, and all of its numbered dials.  A
00030 //               pointer to this object is stored in the VrpnClient
00031 //               class for each differently-named VRPN dial device
00032 //               we connect to.
00033 //
00034 //               The VRPN callbacks go here, which in turn get
00035 //               vectored out to any VrpnDialDevice objects that
00036 //               register with this.  When the last VrpnDialDevice
00037 //               object unregisters, the VrpnDial will be deleted
00038 //               by the VrpnClient.
00039 //
00040 //               This class does not need to be exported from the DLL.
00041 ////////////////////////////////////////////////////////////////////
00042 class VrpnDial {
00043 public:
00044   VrpnDial(const string &dial_name, vrpn_Connection *connection);
00045   ~VrpnDial();
00046 
00047   INLINE const string &get_dial_name() const;
00048   INLINE bool is_empty() const;
00049 
00050   void mark(VrpnDialDevice *device);
00051   void unmark(VrpnDialDevice *device);
00052 
00053   INLINE void poll();
00054 
00055   void output(ostream &out) const;
00056   void write(ostream &out, int indent_level = 0) const;
00057 
00058 private:
00059   static void VRPN_CALLBACK
00060   vrpn_dial_callback(void *userdata, const vrpn_DIALCB info);
00061 
00062 private:
00063   string _dial_name;
00064   vrpn_Dial_Remote *_dial;
00065 
00066   typedef pvector<VrpnDialDevice *> Devices;
00067   Devices _devices;
00068 };
00069 
00070 INLINE ostream &operator << (ostream &out, const VrpnDial &dial) {
00071   dial.output(out);
00072   return out;
00073 }
00074 
00075 #include "vrpnDial.I"
00076 
00077 #endif
 All Classes Functions Variables Enumerations