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
#
ifndef
__cpp_aggregate_paren_init
31
Q_IMPLICIT
Device
(
QString
s
,
std
::
unique_ptr
<
Handler
>
p
)
32
:
deviceNode
(
std
::
move
(
s
)),
handler
(
std
::
move
(
p
)) {}
33
#
endif
34
QString
deviceNode
;
35
std
::
unique_ptr
<
Handler
>
handler
;
36
};
37
38
void
add
(QString deviceNode, std::unique_ptr<Handler> handler)
39
{
40
v.emplace_back(std::move(deviceNode), std::move(handler));
41
}
42
43
bool
remove
(
const
QString &deviceNode)
44
{
45
const
auto
deviceNodeMatches = [&] (
const
Device
&d) {
return
d.deviceNode == deviceNode; };
46
const
auto
it = std::find_if(v.cbegin(), v.cend(), deviceNodeMatches);
47
if
(it == v.cend())
48
return
false
;
49
v.erase(it);
50
return
true
;
51
}
52
53
int
count
()
const
noexcept
{
return
static_cast
<
int
>(v.size()); }
54
55
typename
std
::
vector
<
Device
>::
const_iterator
begin
()
const
noexcept
{
return
v.begin(); }
56
typename
std
::
vector
<
Device
>::
const_iterator
end
()
const
noexcept
{
return
v.end(); }
57
58
private
:
59
std::vector<Device> v;
60
};
61
62
}
// QtInputSupport
63
64
#
endif
// QTINPUTSUPPORT_DEVICEHANDLERLIST_P_H
QtInputSupport::DeviceHandlerList
Definition
devicehandlerlist_p.h:27
QtInputSupport::DeviceHandlerList::add
void add(QString deviceNode, std::unique_ptr< Handler > handler)
Definition
devicehandlerlist_p.h:38
QtInputSupport::DeviceHandlerList::count
int count() const noexcept
Definition
devicehandlerlist_p.h:53
QtInputSupport::DeviceHandlerList::end
std::vector< Device >::const_iterator end() const noexcept
Definition
devicehandlerlist_p.h:56
QtInputSupport::DeviceHandlerList::begin
std::vector< Device >::const_iterator begin() const noexcept
Definition
devicehandlerlist_p.h:55
QtInputSupport::DeviceHandlerList::remove
bool remove(const QString &deviceNode)
Definition
devicehandlerlist_p.h:43
QtInputSupport
Definition
devicehandlerlist_p.h:24
QtInputSupport::DeviceHandlerList::Device
Definition
devicehandlerlist_p.h:29
QtInputSupport::DeviceHandlerList::Device::deviceNode
QString deviceNode
Definition
devicehandlerlist_p.h:34
QtInputSupport::DeviceHandlerList::Device::handler
std::unique_ptr< Handler > handler
Definition
devicehandlerlist_p.h:35
qtbase
src
platformsupport
input
shared
devicehandlerlist_p.h
Generated on
for Qt by
1.16.1