Qt 4.8
Public Functions | Static Public Functions | Public Variables | Properties | List of all members
QDBusConnectionManager Class Reference

#include <qdbusconnectionmanager_p.h>

Public Functions

QDBusConnectionPrivateconnection (const QString &name) const
 
 QDBusConnectionManager ()
 
void removeConnection (const QString &name)
 
QDBusConnectionPrivatesender () const
 
void setConnection (const QString &name, QDBusConnectionPrivate *c)
 
void setSender (const QDBusConnectionPrivate *s)
 
 ~QDBusConnectionManager ()
 

Static Public Functions

static QDBusConnectionManagerinstance ()
 

Public Variables

QMutex mutex
 

Properties

QHash< QString, QDBusConnectionPrivate * > connectionHash
 
QMutex senderMutex
 
QString senderName
 

Detailed Description

Definition at line 63 of file qdbusconnectionmanager_p.h.

Constructors and Destructors

◆ QDBusConnectionManager()

QDBusConnectionManager::QDBusConnectionManager ( )
inline

Definition at line 66 of file qdbusconnectionmanager_p.h.

66 {}

◆ ~QDBusConnectionManager()

QDBusConnectionManager::~QDBusConnectionManager ( )

Definition at line 97 of file qdbusconnection.cpp.

Referenced by QDBusConnectionManager().

98 {
100  it != connectionHash.constEnd(); ++it) {
101  QDBusConnectionPrivate *d = it.value();
102  if (!d->ref.deref())
103  d->deleteYourself();
104  else
105  d->closeConnection();
106  }
108 }
QHash< QString, QDBusConnectionPrivate * > connectionHash
double d
Definition: qnumeric_p.h:62
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
void clear()
Removes all items from the hash.
Definition: qhash.h:574
#define it(className, varName)
bool deref()
Atomically decrements the value of this QAtomicInt.
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469

Functions

◆ connection()

QDBusConnectionPrivate * QDBusConnectionManager::connection ( const QString name) const

Definition at line 78 of file qdbusconnection.cpp.

Referenced by QDBusConnectionManager().

79 {
80  return connectionHash.value(name, 0);
81 }
QHash< QString, QDBusConnectionPrivate * > connectionHash
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606

◆ instance()

QDBusConnectionManager * QDBusConnectionManager::instance ( )
static

Definition at line 110 of file qdbusconnection.cpp.

Referenced by QDBusConnectionManager(), QDBusDefaultConnection::QDBusDefaultConnection(), qDBusNewConnection(), and QDBusServer::~QDBusServer().

111 {
112  return _q_manager();
113 }

◆ removeConnection()

void QDBusConnectionManager::removeConnection ( const QString name)

Definition at line 83 of file qdbusconnection.cpp.

Referenced by QDBusConnectionManager(), and QDBusServer::~QDBusServer().

84 {
86  d = connectionHash.take(name);
87  if (d && !d->ref.deref())
88  d->deleteYourself();
89 
90  // Static objects may be keeping the connection open.
91  // However, it is harmless to have outstanding references to a connection that is
92  // closing as long as those references will be soon dropped without being used.
93 
94  // ### Output a warning if connections are being used after they have been removed.
95 }
QHash< QString, QDBusConnectionPrivate * > connectionHash
double d
Definition: qnumeric_p.h:62
T take(const Key &key)
Removes the item with the key from the hash and returns the value associated with it...
Definition: qhash.h:807
bool deref()
Atomically decrements the value of this QAtomicInt.

◆ sender()

QDBusConnectionPrivate * QDBusConnectionManager::sender ( ) const

Definition at line 66 of file qdbusconnection.cpp.

Referenced by QDBusConnectionManager(), and QDBusConnection::sender().

67 {
68  QMutexLocker locker(&senderMutex);
69  return connection(senderName);
70 }
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
QDBusConnectionPrivate * connection(const QString &name) const

◆ setConnection()

void QDBusConnectionManager::setConnection ( const QString name,
QDBusConnectionPrivate c 
)

Definition at line 120 of file qdbusconnection.cpp.

Referenced by QDBusConnectionManager(), and qDBusNewConnection().

121 {
122  connectionHash[name] = c;
123  c->name = name;
124 }
QHash< QString, QDBusConnectionPrivate * > connectionHash
unsigned char c[8]
Definition: qnumeric_p.h:62
const char * name

◆ setSender()

void QDBusConnectionManager::setSender ( const QDBusConnectionPrivate s)

Definition at line 72 of file qdbusconnection.cpp.

Referenced by QDBusConnectionManager().

73 {
74  QMutexLocker locker(&senderMutex);
75  senderName = (s ? s->name : QString());
76 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101

Properties

◆ connectionHash

QHash<QString, QDBusConnectionPrivate *> QDBusConnectionManager::connectionHash
private

◆ mutex

QMutex QDBusConnectionManager::mutex
mutable

◆ senderMutex

QMutex QDBusConnectionManager::senderMutex
mutableprivate

Definition at line 81 of file qdbusconnectionmanager_p.h.

Referenced by setSender().

◆ senderName

QString QDBusConnectionManager::senderName
private

Definition at line 82 of file qdbusconnectionmanager_p.h.

Referenced by setSender().


The documentation for this class was generated from the following files: