Panda3D

Loading...
Searching...
No Matches
clientDialDevice.h
Go to the documentation of this file.
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
14#ifndef CLIENTDIALDEVICE_H
15#define CLIENTDIALDEVICE_H
16
17#include "pandabase.h"
18
19#include "clientDevice.h"
20
21/**
22 * A device, attached to the ClientBase by a DialNode, that records the data
23 * from a single named dial device. The named device can contain any number
24 * of dials, numbered in sequence beginning at zero.
25 *
26 * A dial is a rotating device that does not have stops--it can keep rotating
27 * any number of times. Therefore it does not have a specific position at any
28 * given time, unlike an AnalogDevice.
29 */
30 class EXPCL_PANDA_DEVICE ClientDialDevice : public ClientDevice {
31 protected:
32 INLINE ClientDialDevice(ClientBase *client, const std::string &device_name);
33
34 public:
35 INLINE int get_num_dials() const;
36
37 INLINE void push_dial(int index, double offset);
38 INLINE double read_dial(int index);
39 INLINE bool is_dial_known(int index) const;
40
41 private:
42 void ensure_dial_index(int index);
43
44 protected:
45 class DialState {
46 public:
47 INLINE DialState();
48
49 double _offset;
50 bool _known;
51 };
52
53 typedef pvector<DialState> Dials;
54 Dials _dials;
55
56
57 public:
58 static TypeHandle get_class_type() {
59 return _type_handle;
60 }
61 static void init_type() {
62 ClientDevice::init_type();
63 register_type(_type_handle, "ClientDialDevice",
64 ClientDevice::get_class_type());
65 }
66 virtual TypeHandle get_type() const {
67 return get_class_type();
68 }
69 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
70
71 private:
72 static TypeHandle _type_handle;
73};
74
75#include "clientDialDevice.I"
76
77#endif
ClientDialDevice::read_dial
double read_dial(int index)
Returns the number of complete revolutions of the dial since the last time read_dial() was called.
Definition clientDialDevice.I:64
ClientDialDevice::is_dial_known
bool is_dial_known(int index) const
Returns true if the state of the indicated dial dial is known, or false if we have never heard anythi...
Definition clientDialDevice.I:79
ClientDialDevice::get_num_dials
int get_num_dials() const
Returns the number of dial dials known to the ClientDialDevice.
Definition clientDialDevice.I:38
ClientDialDevice::push_dial
void push_dial(int index, double offset)
Marks that the dial has been offset by the indicated amount.
Definition clientDialDevice.I:48
TypeHandle
TypeHandle is the identifier used to differentiate C++ class types.
Definition typeHandle.h:81
clientDevice.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
clientDialDevice.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
register_type
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition register_type.I:22