clientDialDevice.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /**
  2. * PANDA 3D SOFTWARE
  3. * Copyright (c) Carnegie Mellon University. All rights reserved.
  4. *
  5. * All use of this software is subject to the terms of the revised BSD
  6. * license. You should have received a copy of this license along
  7. * with this source code in a file named "LICENSE."
  8. *
  9. * @file clientDialDevice.h
  10. * @author drose
  11. * @date 2001-01-26
  12. */
  13. #ifndef CLIENTDIALDEVICE_H
  14. #define CLIENTDIALDEVICE_H
  15. #include "pandabase.h"
  16. #include "clientDevice.h"
  17. /**
  18. * A device, attached to the ClientBase by a DialNode, that records the data
  19. * from a single named dial device. The named device can contain any number
  20. * of dials, numbered in sequence beginning at zero.
  21. *
  22. * A dial is a rotating device that does not have stops--it can keep rotating
  23. * any number of times. Therefore it does not have a specific position at any
  24. * given time, unlike an AnalogDevice.
  25. */
  26. class EXPCL_PANDA_DEVICE ClientDialDevice : public ClientDevice {
  27. protected:
  28. INLINE ClientDialDevice(ClientBase *client, const std::string &device_name);
  29. public:
  30. INLINE int get_num_dials() const;
  31. INLINE void push_dial(int index, double offset);
  32. INLINE double read_dial(int index);
  33. INLINE bool is_dial_known(int index) const;
  34. private:
  35. void ensure_dial_index(int index);
  36. protected:
  37. class DialState {
  38. public:
  39. INLINE DialState();
  40. double _offset;
  41. bool _known;
  42. };
  43. typedef pvector<DialState> Dials;
  44. Dials _dials;
  45. public:
  46. static TypeHandle get_class_type() {
  47. return _type_handle;
  48. }
  49. static void init_type() {
  50. ClientDevice::init_type();
  51. register_type(_type_handle, "ClientDialDevice",
  52. ClientDevice::get_class_type());
  53. }
  54. virtual TypeHandle get_type() const {
  55. return get_class_type();
  56. }
  57. virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
  58. private:
  59. static TypeHandle _type_handle;
  60. };
  61. #include "clientDialDevice.I"
  62. #endif