Panda3D
Loading...
Searching...
No Matches
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 */
26class EXPCL_PANDA_DEVICE InputDeviceSet {
27PUBLISHED:
28 InputDeviceSet();
29 InputDeviceSet(const InputDeviceSet &copy);
30 void operator = (const InputDeviceSet &copy);
31 INLINE ~InputDeviceSet();
32
33public:
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
40PUBLISHED:
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
50private:
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
57INLINE 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
Manages a list of InputDevice objects, as returned by various InputDeviceManager methods.
void output(std::ostream &out) const
Writes a brief one-line description of the InputDeviceSet to the indicated output stream.
void write(std::ostream &out, int indent_level=0) const
Writes a complete multi-line description of the InputDeviceSet to the indicated output stream.
void reserve(size_t num)
This is a hint to Panda to allocate enough memory to hold the given number of InputDevices,...
void remove_devices_from(const InputDeviceSet &other)
Removes from this collection all of the devices listed in the other set.
void add_devices_from(const InputDeviceSet &other)
Adds all the InputDevices indicated in the other collection to this set.
void clear()
Removes all InputDevices from the collection.
size_t size() const
Returns the number of devices in the collection.
void add_device(InputDevice *device)
Adds a new InputDevice to the collection.
bool remove_device(InputDevice *device)
Removes the indicated InputDevice from the collection.
bool has_device(InputDevice *device) const
Returns true if the indicated InputDevice appears in this collection, false otherwise.
This is a structure representing a single input device.
Definition inputDevice.h:53
A specialization of ordered_vector that emulates a standard STL set: one copy of each element is allo...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.