QAmqpChannelHash: Add contains function

This commit is contained in:
Stuart Longland 2015-05-02 21:01:07 +10:00
parent 3e5cf05256
commit c171b5c337
3 changed files with 22 additions and 6 deletions

View File

@ -35,6 +35,17 @@ QAmqpChannel* QAmqpChannelHash::get(const QString& name) const
return channels.value(name);
}
/*!
* Return true if the named channel exists.
*/
bool QAmqpChannelHash::contains(const QString& name) const
{
if (name.isNull())
return channels.contains(QString(""));
return channels.contains(name);
}
/*!
* Store an exchange in the hash. The nameless exchange is stored under
* the name "".

View File

@ -47,6 +47,11 @@ public:
*/
QAmqpChannel* get(const QString& name) const;
/*!
* Return true if the named channel exists.
*/
bool contains(const QString& name) const;
/*!
* Store an exchange in the hash. The nameless exchange is stored under
* the name "".

View File

@ -660,9 +660,9 @@ QAmqpExchange *QAmqpClient::createExchange(int channelNumber)
QAmqpExchange *QAmqpClient::createExchange(const QString &name, int channelNumber)
{
Q_D(QAmqpClient);
QAmqpExchange *exchange = static_cast<QAmqpExchange*>(d->exchanges.get(name));
if (exchange != NULL)
return exchange;
QAmqpExchange *exchange;
if (d->exchanges.contains(name))
return static_cast<QAmqpExchange*>(d->exchanges.get(name));
exchange = new QAmqpExchange(channelNumber, this);
d->methodHandlersByChannel[exchange->channelNumber()].append(exchange->d_func());
@ -684,9 +684,9 @@ QAmqpQueue *QAmqpClient::createQueue(int channelNumber)
QAmqpQueue *QAmqpClient::createQueue(const QString &name, int channelNumber)
{
Q_D(QAmqpClient);
QAmqpQueue *queue = static_cast<QAmqpQueue*>(d->queues.get(name));
if (queue != NULL)
return queue;
QAmqpQueue *queue;
if (d->queues.contains(name))
return static_cast<QAmqpQueue*>(d->queues.get(name));
queue = new QAmqpQueue(channelNumber, this);
d->methodHandlersByChannel[queue->channelNumber()].append(queue->d_func());