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 */
26 class EXPCL_PANDA_DEVICE InputDeviceSet {
27PUBLISHED:
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
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
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
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
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
InputDeviceSet::write
void write(std::ostream &out, int indent_level=0) const
Writes a complete multi-line description of the InputDeviceSet to the indicated output stream.
Definition inputDeviceSet.cxx:131
InputDeviceSet::reserve
void reserve(size_t num)
This is a hint to Panda to allocate enough memory to hold the given number of InputDevices,...
Definition inputDeviceSet.cxx:109
InputDeviceSet::remove_devices_from
void remove_devices_from(const InputDeviceSet &other)
Removes from this collection all of the devices listed in the other set.
Definition inputDeviceSet.cxx:74
InputDeviceSet::add_devices_from
void add_devices_from(const InputDeviceSet &other)
Adds all the InputDevices indicated in the other collection to this set.
Definition inputDeviceSet.cxx:62
InputDeviceSet::clear
void clear()
Removes all InputDevices from the collection.
Definition inputDeviceSet.cxx:100
InputDeviceSet::size
size_t size() const
Returns the number of devices in the collection.
Definition inputDeviceSet.I:34
InputDeviceSet::add_device
void add_device(InputDevice *device)
Adds a new InputDevice to the collection.
Definition inputDeviceSet.cxx:45
InputDeviceSet::remove_device
bool remove_device(InputDevice *device)
Removes the indicated InputDevice from the collection.
Definition inputDeviceSet.cxx:54
InputDeviceSet::has_device
bool has_device(InputDevice *device) const
Returns true if the indicated InputDevice appears in this collection, false otherwise.
Definition inputDeviceSet.cxx:91
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.