Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
devicehandlerlist_p.h
Go to the documentation of this file.
1
// Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
ifndef
QTINPUTSUPPORT_DEVICEHANDLERLIST_P_H
5
#
define
QTINPUTSUPPORT_DEVICEHANDLERLIST_P_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#
include
<
QString
>
19
#
include
<
private
/
qglobal_p
.
h
>
20
21
#
include
<
vector
>
22
#
include
<
memory
>
23
24
namespace
QtInputSupport
{
25
26
template
<
typename
Handler>
27
class
DeviceHandlerList
{
28
public
:
29
struct
Device
{
30
QString
deviceNode
;
31
std
::
unique_ptr
<
Handler
>
handler
;
32
};
33
34
void
add
(
const
QString &deviceNode, std::unique_ptr<Handler> handler)
35
{
36
v.push_back({deviceNode, std::move(handler)});
37
}
38
39
bool
remove
(
const
QString &deviceNode)
40
{
41
const
auto
deviceNodeMatches = [&] (
const
Device
&d) {
return
d.deviceNode == deviceNode; };
42
const
auto
it = std::find_if(v.cbegin(), v.cend(), deviceNodeMatches);
43
if
(it == v.cend())
44
return
false
;
45
v.erase(it);
46
return
true
;
47
}
48
49
int
count
()
const
noexcept
{
return
static_cast
<
int
>(v.size()); }
50
51
typename
std
::
vector
<
Device
>::
const_iterator
begin
()
const
noexcept
{
return
v.begin(); }
52
typename
std
::
vector
<
Device
>::
const_iterator
end
()
const
noexcept
{
return
v.end(); }
53
54
private
:
55
std::vector<Device> v;
56
};
57
58
}
// QtInputSupport
59
60
#
endif
// QTINPUTSUPPORT_DEVICEHANDLERLIST_P_H
QtInputSupport::DeviceHandlerList
Definition
devicehandlerlist_p.h:27
QtInputSupport::DeviceHandlerList::count
int count() const noexcept
Definition
devicehandlerlist_p.h:49
QtInputSupport::DeviceHandlerList::add
void add(const QString &deviceNode, std::unique_ptr< Handler > handler)
Definition
devicehandlerlist_p.h:34
QtInputSupport::DeviceHandlerList::end
std::vector< Device >::const_iterator end() const noexcept
Definition
devicehandlerlist_p.h:52
QtInputSupport::DeviceHandlerList::begin
std::vector< Device >::const_iterator begin() const noexcept
Definition
devicehandlerlist_p.h:51
QtInputSupport::DeviceHandlerList::remove
bool remove(const QString &deviceNode)
Definition
devicehandlerlist_p.h:39
QtInputSupport
Definition
devicehandlerlist_p.h:24
QtInputSupport::DeviceHandlerList::Device
Definition
devicehandlerlist_p.h:29
QtInputSupport::DeviceHandlerList::Device::deviceNode
QString deviceNode
Definition
devicehandlerlist_p.h:30
QtInputSupport::DeviceHandlerList::Device::handler
std::unique_ptr< Handler > handler
Definition
devicehandlerlist_p.h:31
qtbase
src
platformsupport
input
shared
devicehandlerlist_p.h
Generated on
for Qt by
1.14.0