Panda3D
|
00001 // Filename: clientDialDevice.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 CLIENTDIALDEVICE_H 00016 #define CLIENTDIALDEVICE_H 00017 00018 #include "pandabase.h" 00019 00020 #include "clientDevice.h" 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Class : ClientDialDevice 00024 // Description : A device, attached to the ClientBase by a 00025 // DialNode, that records the data from a single 00026 // named dial device. The named device can contain 00027 // any number of dials, numbered in sequence beginning 00028 // at zero. 00029 // 00030 // A dial is a rotating device that does not have 00031 // stops--it can keep rotating any number of times. 00032 // Therefore it does not have a specific position at any 00033 // given time, unlike an AnalogDevice. 00034 //////////////////////////////////////////////////////////////////// 00035 class EXPCL_PANDA_DEVICE ClientDialDevice : public ClientDevice { 00036 protected: 00037 INLINE ClientDialDevice(ClientBase *client, const string &device_name); 00038 00039 public: 00040 INLINE int get_num_dials() const; 00041 00042 INLINE void push_dial(int index, double offset); 00043 INLINE double read_dial(int index); 00044 INLINE bool is_dial_known(int index) const; 00045 00046 private: 00047 void ensure_dial_index(int index); 00048 00049 protected: 00050 class DialState { 00051 public: 00052 INLINE DialState(); 00053 00054 double _offset; 00055 bool _known; 00056 }; 00057 00058 typedef pvector<DialState> Dials; 00059 Dials _dials; 00060 00061 00062 public: 00063 static TypeHandle get_class_type() { 00064 return _type_handle; 00065 } 00066 static void init_type() { 00067 ClientDevice::init_type(); 00068 register_type(_type_handle, "ClientDialDevice", 00069 ClientDevice::get_class_type()); 00070 } 00071 virtual TypeHandle get_type() const { 00072 return get_class_type(); 00073 } 00074 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00075 00076 private: 00077 static TypeHandle _type_handle; 00078 }; 00079 00080 #include "clientDialDevice.I" 00081 00082 #endif