Panda3D

inputDeviceSet.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 inputDeviceSet.h
10 * @author rdb
11 * @date 2015-12-16
12 */
13
14 #ifndef INPUTDEVICESET_H
15 #define INPUTDEVICESET_H
16
17 #include "pandabase.h"
18 #include "ordered_vector.h"
19 #include "inputDevice.h"
20
21 /**
22 * Manages a list of InputDevice objects, as returned by various
23 * InputDeviceManager methods. This is implemented like a set, meaning the
24 * same device cannot occur more than once.
25 */
26 class EXPCL_PANDA_DEVICE InputDeviceSet {
27 PUBLISHED:
28 InputDeviceSet();
29 InputDeviceSet(const InputDeviceSet &copy);
30 void operator = (const InputDeviceSet &copy);
31 INLINE ~InputDeviceSet();
32
33 public:
34 void add_device(InputDevice *device);
35 bool remove_device(InputDevice *device);
36 void add_devices_from(const InputDeviceSet &other);
37 void remove_devices_from(const InputDeviceSet &other);
38 bool has_device(InputDevice *device) const;
39
40 PUBLISHED:
41 void clear();
42 void reserve(size_t num);
43
44 INLINE InputDevice *operator [] (size_t index) const;
45 INLINE size_t size() const;
46
47 void output(std::ostream &out) const;
48 void write(std::ostream &out, int indent_level = 0) const;
49
50 private:
51 // This is currently implemented as ov_set instead of a regular set so that
52 // we can still support random access.
53 typedef ov_set<PT(InputDevice)> InputDevices;
54 InputDevices _devices;
55 };
56
57 INLINE std::ostream &operator << (std::ostream &out, const InputDeviceSet &col) {
58 col.output(out);
59 return out;
60 }
61
62 #include "inputDeviceSet.I"
63
64 #endif
InputDeviceSet
Manages a list of InputDevice objects, as returned by various InputDeviceManager methods.
Definition: inputDeviceSet.h:26
InputDeviceSet::output
void output(std::ostream &out) const
Writes a brief one-line description of the InputDeviceSet to the indicated output stream.
Definition: inputDeviceSet.cxx:118
InputDevice
This is a structure representing a single input device.
Definition: inputDevice.h:53
ov_set
A specialization of ordered_vector that emulates a standard STL set: one copy of each element is allo...
Definition: ordered_vector.h:269
inputDeviceSet.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
inputDevice.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
ordered_vector.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.