Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qsocketnotifier.h
Go to the documentation of this file.
1
// Copyright (C) 2016 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
ifndef
QSOCKETNOTIFIER_H
6
#
define
QSOCKETNOTIFIER_H
7
8
#
include
<
QtCore
/
qobject
.
h
>
9
10
QT_BEGIN_NAMESPACE
11
12
class
QSocketDescriptor
;
13
class
QSocketNotifierPrivate
;
14
class
Q_CORE_EXPORT
QSocketNotifier
:
public
QObject
15
{
16
Q_OBJECT
17
Q_DECLARE_PRIVATE(QSocketNotifier)
18
19
public
:
20
enum
Type { Read, Write, Exception };
21
22
explicit
QSocketNotifier(Type, QObject *parent =
nullptr
);
23
QSocketNotifier(qintptr socket, Type, QObject *parent =
nullptr
);
24
~QSocketNotifier();
25
26
void
setSocket(qintptr socket);
27
qintptr socket()
const
;
28
Type type()
const
;
29
30
bool
isValid()
const
;
31
bool
isEnabled()
const
;
32
33
public
Q_SLOTS:
34
void
setEnabled(
bool
);
35
36
Q_SIGNALS:
37
#
if
defined
(
Q_MOC_RUN
)
38
// Add default arguments during Q_MOC_RUN which makes moc generate "signals" which takes less
39
// parameters, but we won't actually allow emitting without all 3. This lets users use the
40
// string-based connect without specifying QSocketNotifier::Type as one of the parameters.
41
void
activated(QSocketDescriptor socket, QSocketNotifier::Type activationEvent = Read,
42
QPrivateSignal = {});
43
#
else
44
void
activated(QSocketDescriptor socket, QSocketNotifier::Type activationEvent, QPrivateSignal);
45
#
endif
46
47
// ### Qt7: consider removing it.
48
// The old signal is compiled internally, but hidden outside of this class.
49
// This means the PMF-based connect(..) will automatically, on recompile, pick up the new
50
// version while the old-style connect(..) can query the metaobject system for this version.
51
#
if
defined
(
Q_MOC_RUN
)
||
defined
(
BUILDING_QSOCKETNOTIFIER
)
||
defined
(
Q_QDOC
)
52
QT_MOC_COMPAT
void
activated(
int
socket, QPrivateSignal);
53
#
endif
54
55
protected
:
56
bool
event(QEvent *) override;
57
58
private
:
59
Q_DISABLE_COPY(QSocketNotifier)
60
};
61
62
class
QSocketDescriptor
63
{
64
public
:
65
#
if
defined
(
Q_OS_WIN
)
||
defined
(
Q_QDOC
)
66
using
DescriptorType
=
Qt
::
HANDLE
;
67
#
define
Q_DECL_CONSTEXPR_NOT_WIN
68
#
else
69
using
DescriptorType
=
int
;
70
#
define
Q_DECL_CONSTEXPR_NOT_WIN
Q_DECL_CONSTEXPR
71
#
endif
72
73
Q_DECL_CONSTEXPR_NOT_WIN
Q_IMPLICIT
74
QSocketDescriptor
(
DescriptorType
descriptor
=
DescriptorType
(-1))
noexcept
:
sockfd
(
descriptor
)
75
{
76
}
77
78
#
if
defined
(
Q_OS_WIN
)
||
defined
(
Q_QDOC
)
79
Q_IMPLICIT
QSocketDescriptor
(
qintptr
desc
)
noexcept
:
sockfd
(
DescriptorType
(
desc
)) {}
80
Q_IMPLICIT
operator
qintptr
()
const
noexcept
{
return
qintptr
(
sockfd
); }
81
Q_DECL_CONSTEXPR
Qt
::
HANDLE
winHandle
()
const
noexcept
{
return
sockfd
; }
82
#
endif
83
Q_DECL_CONSTEXPR
operator
DescriptorType
()
const
noexcept
{
return
sockfd
; }
84
85
Q_DECL_CONSTEXPR_NOT_WIN
bool
isValid
()
const
noexcept
{
return
*
this
!=
QSocketDescriptor
(); }
86
87
private
:
88
friend
Q_DECL_CONSTEXPR_NOT_WIN
bool
comparesEqual
(
const
QSocketDescriptor
&
lhs
,
89
const
QSocketDescriptor
&
rhs
)
noexcept
90
{
91
return
lhs
.
sockfd
==
rhs
.
sockfd
;
92
}
93
#
if
defined
(
Q_OS_WIN
)
||
defined
(
Q_QDOC
)
94
Q_DECLARE_EQUALITY_COMPARABLE
(
QSocketDescriptor
)
95
#
else
96
Q_DECLARE_EQUALITY_COMPARABLE_LITERAL_TYPE
(
QSocketDescriptor
)
97
#
endif
98
99
#
undef
Q_DECL_CONSTEXPR_NOT_WIN
100
101
DescriptorType
sockfd
;
102
};
103
104
QT_END_NAMESPACE
105
106
QT_DECL_METATYPE_EXTERN_TAGGED(QSocketNotifier::Type, QSocketNotifier_Type, Q_CORE_EXPORT)
107
QT_DECL_METATYPE_EXTERN(QSocketDescriptor, Q_CORE_EXPORT)
108
109
#
endif
// QSOCKETNOTIFIER_H
QSocketDescriptor
\inmodule QtCore
Definition
qsocketnotifier.h:63
QSocketDescriptor::DescriptorType
int DescriptorType
Definition
qsocketnotifier.h:69
QSocketNotifierPrivate
Definition
qsocketnotifier.cpp:28
QSocketNotifier
\inmodule QtCore
Definition
qsocketnotifier.h:15
QVarLengthArray
Definition
qvarlengtharray.h:291
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QT_REQUIRE_CONFIG
QT_REQUIRE_CONFIG(animation)
QT_REQUIRE_CONFIG
QT_REQUIRE_CONFIG(filesystemwatcher)
find_last_in_equal_range
Hash::const_iterator find_last_in_equal_range(const Hash &c, const Key &key)
Definition
qfilesystemwatcher_inotify.cpp:395
Q_DECL_CONSTEXPR_NOT_WIN
#define Q_DECL_CONSTEXPR_NOT_WIN
Definition
qsocketnotifier.h:70
qtbase
src
corelib
kernel
qsocketnotifier.h
Generated on
for Qt by
1.18.0