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

panda/src/vrpn/vrpnClient.h

Go to the documentation of this file.
00001 // Filename: vrpnClient.h
00002 // Created by:  jason (04Aug00)
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 VRPNCLIENT_H
00020 #define VRPNCLIENT_H
00021 
00022 #include <pandabase.h>
00023 #include <clientBase.h>
00024 
00025 #include "vrpn_interface.h"
00026 
00027 class VrpnTracker;
00028 class VrpnTrackerDevice;
00029 class VrpnButton;
00030 class VrpnButtonDevice;
00031 class VrpnAnalog;
00032 class VrpnAnalogDevice;
00033 class VrpnDial;
00034 class VrpnDialDevice;
00035 
00036 ////////////////////////////////////////////////////////////////////
00037 //       Class : VrpnClient
00038 // Description : A specific ClientBase that connects to a VRPN server
00039 //               and records information on the connected VRPN
00040 //               devices.
00041 ////////////////////////////////////////////////////////////////////
00042 class EXPCL_PANDA VrpnClient : public ClientBase {
00043 PUBLISHED:
00044   VrpnClient(const string &server_name);
00045   ~VrpnClient();
00046 
00047   INLINE const string &get_server_name() const;
00048   INLINE bool is_valid() const;
00049   INLINE bool is_connected() const;
00050 
00051   void write(ostream &out, int indent_level = 0) const;
00052 
00053 public:
00054   INLINE static double convert_to_secs(struct timeval msg_time);
00055 
00056 protected:
00057   virtual PT(ClientDevice) make_device(TypeHandle device_type,
00058                                        const string &device_name);
00059 
00060   virtual bool disconnect_device(TypeHandle device_type,
00061                                  const string &device_name,
00062                                  ClientDevice *device);
00063 
00064   virtual void do_poll();
00065 
00066 private:
00067   PT(ClientDevice) make_tracker_device(const string &device_name);
00068   PT(ClientDevice) make_button_device(const string &device_name);
00069   PT(ClientDevice) make_analog_device(const string &device_name);
00070   PT(ClientDevice) make_dial_device(const string &device_name);
00071   void disconnect_tracker_device(VrpnTrackerDevice *device);
00072   void disconnect_button_device(VrpnButtonDevice *device);
00073   void disconnect_analog_device(VrpnAnalogDevice *device);
00074   void disconnect_dial_device(VrpnDialDevice *device);
00075 
00076   VrpnTracker *get_tracker(const string &tracker_name);
00077   void free_tracker(VrpnTracker *vrpn_tracker);
00078 
00079   VrpnButton *get_button(const string &button_name);
00080   void free_button(VrpnButton *vrpn_button);
00081 
00082   VrpnAnalog *get_analog(const string &analog_name);
00083   void free_analog(VrpnAnalog *vrpn_analog);
00084 
00085   VrpnDial *get_dial(const string &dial_name);
00086   void free_dial(VrpnDial *vrpn_dial);
00087 
00088 private:
00089   string _server_name;
00090   vrpn_Connection *_connection;
00091 
00092   typedef pmap<string, VrpnTracker *> Trackers;
00093   typedef pmap<string, VrpnButton *> Buttons;
00094   typedef pmap<string, VrpnAnalog *> Analogs;
00095   typedef pmap<string, VrpnDial *> Dials;
00096 
00097   Trackers _trackers;
00098   Buttons _buttons;
00099   Analogs _analogs;
00100   Dials _dials;
00101 
00102 
00103 public:
00104   static TypeHandle get_class_type() {
00105     return _type_handle;
00106   }
00107   static void init_type() {
00108     ClientBase::init_type();
00109     register_type(_type_handle, "VrpnClient",
00110                   ClientBase::get_class_type());
00111   }
00112   virtual TypeHandle get_type() const {
00113     return get_class_type();
00114   }
00115   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00116 
00117 private:
00118   static TypeHandle _type_handle;
00119 };
00120 
00121 #include "vrpnClient.I"
00122 
00123 #endif
00124 
00125 

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