DBus-1-TQt
1.0
Main Page
Related Pages
Classes
Files
Examples
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
tqdbusunixfd.cpp
Go to the documentation of this file.
1
/* tqdbusunixfd.cpp DBUS unix file handle data type
2
*
3
* Copyright (C) 2013 Slávek Banko <slavek.banko@axis.cz>
4
*
5
* Licensed under the Academic Free License version 2.1
6
*
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
20
* USA.
21
*
22
*/
23
24
#include <unistd.h>
25
#include "
tqdbusunixfd.h
"
26
27
TQT_DBusUnixFd::TQT_DBusUnixFd
() : d(new
TQT_DBusUnixFdPrivate
())
28
{
29
d
->ref();
30
d
->
fd
= -1;
31
};
32
33
TQT_DBusUnixFd::TQT_DBusUnixFd
(
const
TQT_DBusUnixFd
& other) : d(other.d)
34
{
35
d
->ref();
36
}
37
38
TQT_DBusUnixFd::TQT_DBusUnixFd
(
int
other) : d(0)
39
{
40
setFileDescriptor
(other);
41
}
42
43
TQT_DBusUnixFd::~TQT_DBusUnixFd
()
44
{
45
if
(
d
&&
d
->deref() ) {
46
if
(
isValid
() ) {
47
close(
d
->
fd
);
48
}
49
delete
d
;
50
}
51
}
52
53
bool
TQT_DBusUnixFd::isValid
()
const
54
{
55
return
d
?
d
->
fd
!= -1 :
false
;
56
}
57
58
int
TQT_DBusUnixFd::fileDescriptor
()
const
59
{
60
return
d
?
d
->
fd
: -1;
61
}
62
63
void
TQT_DBusUnixFd::setFileDescriptor
(
int
fileDescriptor)
64
{
65
giveFileDescriptor
(fileDescriptor != -1 ? dup(fileDescriptor) : -1);
66
}
67
68
void
TQT_DBusUnixFd::giveFileDescriptor
(
int
fileDescriptor)
69
{
70
if
(
d
&&
d
->deref() ) {
71
if
(
isValid
() ) {
72
close(
d
->
fd
);
73
}
74
}
75
else
{
76
d
=
new
TQT_DBusUnixFdPrivate
;
77
}
78
d
->ref();
79
d
->
fd
=
fileDescriptor
;
80
}
81
82
TQT_DBusUnixFd
&
TQT_DBusUnixFd::operator=
(
const
TQT_DBusUnixFd
&other )
83
{
84
if
(other.
d
) {
85
other.
d
->ref();
86
}
87
if
(
d
&&
d
->deref() ) {
88
if
(
isValid
() ) {
89
close(
d
->
fd
);
90
}
91
delete
d
;
92
}
93
d
= other.
d
;
94
return
*
this
;
95
}
build
buildd
dbus-1-tqt-14.1.0~r197
src
tqdbusunixfd.cpp
Generated on Mon Feb 3 2020 00:28:27 for DBus-1-TQt by
1.8.1.2