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

panda/src/device/clientAnalogDevice.h

Go to the documentation of this file.
00001 // Filename: clientAnalogDevice.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 CLIENTANALOGDEVICE_H
00020 #define CLIENTANALOGDEVICE_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include "clientDevice.h"
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //       Class : ClientAnalogDevice
00028 // Description : A device, attached to the ClientBase by a
00029 //               AnalogNode, that records the data from a single
00030 //               named analog device.  The named device can contain
00031 //               any number of analog controls, numbered in
00032 //               sequence beginning at zero.
00033 //
00034 //               Each analog control returns a value ranging from -1
00035 //               to 1, reflecting the current position of the control
00036 //               within its total range of motion.
00037 ////////////////////////////////////////////////////////////////////
00038 class EXPCL_PANDA ClientAnalogDevice : public ClientDevice {
00039 protected:
00040   INLINE ClientAnalogDevice(ClientBase *client, const string &device_name);
00041 
00042 public:
00043   INLINE int get_num_controls() const;
00044 
00045   INLINE void set_control_state(int index, double state);
00046   INLINE double get_control_state(int index) const;
00047   INLINE bool is_control_known(int index) const;
00048 
00049   virtual void write(ostream &out, int indent_level = 0) const;
00050   void write_controls(ostream &out, int indent_level) const;
00051 
00052 private:
00053   void ensure_control_index(int index);
00054 
00055 protected:
00056   class AnalogState {
00057   public:
00058     INLINE AnalogState();
00059 
00060     double _state;
00061     bool _known;
00062   };
00063 
00064   typedef pvector<AnalogState> Controls;
00065   Controls _controls;
00066 
00067 
00068 public:
00069   static TypeHandle get_class_type() {
00070     return _type_handle;
00071   }
00072   static void init_type() {
00073     ClientDevice::init_type();
00074     register_type(_type_handle, "ClientAnalogDevice",
00075                   ClientDevice::get_class_type());
00076   }
00077   virtual TypeHandle get_type() const {
00078     return get_class_type();
00079   }
00080   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00081 
00082 private:
00083   static TypeHandle _type_handle;
00084 };
00085 
00086 #include "clientAnalogDevice.I"
00087 
00088 #endif

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