![]() |
Qt 6.x
The Qt SDK
|
\inmodule QtDBus More...
#include <qdbusunixfiledescriptor.h>
Public Member Functions | |
QDBusUnixFileDescriptor () | |
Constructs a QDBusUnixFileDescriptor without a wrapped file descriptor. | |
QDBusUnixFileDescriptor (int fileDescriptor) | |
Constructs a QDBusUnixFileDescriptor object by copying the fileDescriptor parameter. | |
QDBusUnixFileDescriptor (const QDBusUnixFileDescriptor &other) | |
Constructs a QDBusUnixFileDescriptor object by copying other. | |
QDBusUnixFileDescriptor & | operator= (QDBusUnixFileDescriptor &&other) noexcept |
Move-assigns other to this QDBusUnixFileDescriptor. | |
QDBusUnixFileDescriptor & | operator= (const QDBusUnixFileDescriptor &other) |
Copies the Unix file descriptor from the other QDBusUnixFileDescriptor object. | |
~QDBusUnixFileDescriptor () | |
Destroys this QDBusUnixFileDescriptor object and disposes of the Unix file descriptor that it contained. | |
void | swap (QDBusUnixFileDescriptor &other) noexcept |
bool | isValid () const |
Returns true if this Unix file descriptor is valid. | |
int | fileDescriptor () const |
Returns the Unix file descriptor contained by this QDBusUnixFileDescriptor object. | |
void | setFileDescriptor (int fileDescriptor) |
void | giveFileDescriptor (int fileDescriptor) |
int | takeFileDescriptor () |
Static Public Member Functions | |
static bool | isSupported () |
Protected Types | |
typedef QExplicitlySharedDataPointer< QDBusUnixFileDescriptorPrivate > | Data |
Protected Attributes | |
Data | d |
\inmodule QtDBus
The QDBusUnixFileDescriptor class holds one Unix file descriptor.
The QDBusUnixFileDescriptor class is used to hold one Unix file descriptor for use with the Qt D-Bus module. This allows applications to send and receive Unix file descriptors over the D-Bus connection, mapping automatically to the D-Bus type 'h'.
Objects of type QDBusUnixFileDescriptors can be used also as parameters in signals and slots that get exported to D-Bus by registering with QDBusConnection::registerObject.
QDBusUnixFileDescriptor does not take ownership of the file descriptor. Instead, it will use the Unix system call dup(2)
to make a copy of the file descriptor. This file descriptor belongs to the QDBusUnixFileDescriptor object and should not be stored or closed by the user. Instead, you should make your own copy if you need that.
Definition at line 20 of file qdbusunixfiledescriptor.h.
|
protected |
Definition at line 44 of file qdbusunixfiledescriptor.h.
QDBusUnixFileDescriptor::QDBusUnixFileDescriptor | ( | ) |
Constructs a QDBusUnixFileDescriptor without a wrapped file descriptor.
This is equivalent to constructing the object with an invalid file descriptor (like -1).
Definition at line 103 of file qdbusunixfiledescriptor.cpp.
|
explicit |
Constructs a QDBusUnixFileDescriptor object by copying the fileDescriptor parameter.
The original file descriptor is not touched and must be closed by the user.
Note that the value returned by fileDescriptor() will be different from the fileDescriptor parameter passed.
If the fileDescriptor parameter is not valid, isValid() will return false and fileDescriptor() will return -1.
Definition at line 121 of file qdbusunixfiledescriptor.cpp.
References fileDescriptor(), and setFileDescriptor().
QDBusUnixFileDescriptor::QDBusUnixFileDescriptor | ( | const QDBusUnixFileDescriptor & | other | ) |
Constructs a QDBusUnixFileDescriptor object by copying other.
Definition at line 131 of file qdbusunixfiledescriptor.cpp.
QDBusUnixFileDescriptor::~QDBusUnixFileDescriptor | ( | ) |
Destroys this QDBusUnixFileDescriptor object and disposes of the Unix file descriptor that it contained.
Definition at line 157 of file qdbusunixfiledescriptor.cpp.
int QDBusUnixFileDescriptor::fileDescriptor | ( | ) | const |
Returns the Unix file descriptor contained by this QDBusUnixFileDescriptor object.
An invalid file descriptor is represented by the value -1.
Note that the file descriptor returned by this function is owned by the QDBusUnixFileDescriptor object and must not be stored past the lifetime of this object. It is ok to use it while this object is valid, but if one wants to store it for longer use, the file descriptor should be cloned using the Unix dup(2)
, dup2(2)
or dup3(2)
functions.
Definition at line 193 of file qdbusunixfiledescriptor.cpp.
References d, QDBusUnixFileDescriptorPrivate::fd, and QBasicAtomicInteger< T >::loadRelaxed().
Referenced by QDBusUnixFileDescriptor().
void QDBusUnixFileDescriptor::giveFileDescriptor | ( | int | fileDescriptor | ) |
Definition at line 293 of file qdbusunixfiledescriptor.cpp.
|
static |
Definition at line 284 of file qdbusunixfiledescriptor.cpp.
bool QDBusUnixFileDescriptor::isValid | ( | ) | const |
Returns true
if this Unix file descriptor is valid.
A valid Unix file descriptor is not -1.
Definition at line 175 of file qdbusunixfiledescriptor.cpp.
References d, QDBusUnixFileDescriptorPrivate::fd, and QBasicAtomicInteger< T >::loadRelaxed().
QDBusUnixFileDescriptor & QDBusUnixFileDescriptor::operator= | ( | const QDBusUnixFileDescriptor & | other | ) |
Copies the Unix file descriptor from the other QDBusUnixFileDescriptor object.
If the current object contained a file descriptor, it will be properly disposed of before.
Definition at line 141 of file qdbusunixfiledescriptor.cpp.
|
inlinenoexcept |
Move-assigns other to this QDBusUnixFileDescriptor.
Definition at line 26 of file qdbusunixfiledescriptor.h.
References other(), and swap().
void QDBusUnixFileDescriptor::setFileDescriptor | ( | int | fileDescriptor | ) |
Definition at line 289 of file qdbusunixfiledescriptor.cpp.
Referenced by QDBusUnixFileDescriptor().
|
inlinenoexcept |
Swaps this file descriptor instance with other. This function is very fast and never fails.
Definition at line 30 of file qdbusunixfiledescriptor.h.
int QDBusUnixFileDescriptor::takeFileDescriptor | ( | ) |
Definition at line 297 of file qdbusunixfiledescriptor.cpp.
|
protected |
Definition at line 45 of file qdbusunixfiledescriptor.h.
Referenced by fileDescriptor(), isValid(), and operator=().