Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/vrpn/vrpnButton.h

Go to the documentation of this file.
00001 // Filename: vrpnButton.h
00002 // Created by:  drose (26Jan01)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef VRPNBUTTON_H
00020 #define VRPNBUTTON_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include "vrpn_interface.h"
00025 
00026 #include "pvector.h"
00027 
00028 class VrpnButtonDevice;
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //       Class : VrpnButton
00032 // Description : This is the actual interface to a particular VRPN
00033 //               button device, and all of its numbered buttons.  A
00034 //               pointer to this object is stored in the VrpnClient
00035 //               class for each differently-named VRPN button device
00036 //               we connect to.
00037 //
00038 //               The VRPN callbacks go here, which in turn get
00039 //               vectored out to any VrpnButtonDevice objects that
00040 //               register with this.  When the last VrpnButtonDevice
00041 //               object unregisters, the VrpnButton will be deleted
00042 //               by the VrpnClient.
00043 //
00044 //               This class does not need to be exported from the DLL.
00045 ////////////////////////////////////////////////////////////////////
00046 class VrpnButton {
00047 public:
00048   VrpnButton(const string &button_name, vrpn_Connection *connection);
00049   ~VrpnButton();
00050 
00051   INLINE const string &get_button_name() const;
00052   INLINE bool is_empty() const;
00053 
00054   void mark(VrpnButtonDevice *device);
00055   void unmark(VrpnButtonDevice *device);
00056 
00057   INLINE void poll();
00058 
00059   void output(ostream &out) const;
00060   void write(ostream &out, int indent_level = 0) const;
00061 
00062 private:
00063   static void
00064   vrpn_button_callback(void *userdata, const vrpn_BUTTONCB info);
00065 
00066 private:
00067   string _button_name;
00068   vrpn_Button_Remote *_button;
00069 
00070   typedef pvector<VrpnButtonDevice *> Devices;
00071   Devices _devices;
00072 };
00073 
00074 INLINE ostream &operator << (ostream &out, const VrpnButton &button) {
00075   button.output(out);
00076   return out;
00077 }
00078 
00079 #include "vrpnButton.I"
00080 
00081 #endif

Generated on Fri May 2 00:44:34 2003 for Panda by doxygen1.3