summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/client
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2009-11-17 10:52:33 +0000
committerGordon Sim <gsim@apache.org>2009-11-17 10:52:33 +0000
commitdfeb9089cd7702cb70e170fcf5f5d01cbbde080c (patch)
treea8965e1124fda146dedca255f912ed6e0a69a643 /cpp/src/qpid/client
parent2b9be90fca9e4e47cc6b47d16dd97d6bfaf0931e (diff)
downloadqpid-python-dfeb9089cd7702cb70e170fcf5f5d01cbbde080c.tar.gz
QPID-664: Added getReceiver()/getSender() methods to session in new api.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@881236 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/client')
-rw-r--r--cpp/src/qpid/client/amqp0_10/SenderImpl.cpp5
-rw-r--r--cpp/src/qpid/client/amqp0_10/SenderImpl.h1
-rw-r--r--cpp/src/qpid/client/amqp0_10/SessionImpl.cpp23
-rw-r--r--cpp/src/qpid/client/amqp0_10/SessionImpl.h5
4 files changed, 33 insertions, 1 deletions
diff --git a/cpp/src/qpid/client/amqp0_10/SenderImpl.cpp b/cpp/src/qpid/client/amqp0_10/SenderImpl.cpp
index 9d168725e6..ef16b26b91 100644
--- a/cpp/src/qpid/client/amqp0_10/SenderImpl.cpp
+++ b/cpp/src/qpid/client/amqp0_10/SenderImpl.cpp
@@ -129,4 +129,9 @@ void SenderImpl::cancelImpl()
parent.senderCancelled(name);
}
+const std::string& SenderImpl::getName() const
+{
+ return name;
+}
+
}}} // namespace qpid::client::amqp0_10
diff --git a/cpp/src/qpid/client/amqp0_10/SenderImpl.h b/cpp/src/qpid/client/amqp0_10/SenderImpl.h
index 60b196b21b..8140b3479a 100644
--- a/cpp/src/qpid/client/amqp0_10/SenderImpl.h
+++ b/cpp/src/qpid/client/amqp0_10/SenderImpl.h
@@ -54,6 +54,7 @@ class SenderImpl : public qpid::messaging::SenderImpl
uint32_t getCapacity();
uint32_t pending();
void init(qpid::client::AsyncSession, AddressResolution&);
+ const std::string& getName() const;
private:
SessionImpl& parent;
diff --git a/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp b/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp
index 4d40bd6c50..3a8992d503 100644
--- a/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp
+++ b/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp
@@ -39,6 +39,7 @@
#include <boost/intrusive_ptr.hpp>
using qpid::messaging::Filter;
+using qpid::messaging::KeyError;
using qpid::messaging::MessageImplAccess;
using qpid::messaging::Sender;
using qpid::messaging::Receiver;
@@ -176,6 +177,28 @@ Sender SessionImpl::createSenderImpl(const qpid::messaging::Address& address)
return sender;
}
+Sender SessionImpl::getSender(const std::string& name) const
+{
+ qpid::sys::Mutex::ScopedLock l(lock);
+ Senders::const_iterator i = senders.find(name);
+ if (i == senders.end()) {
+ throw KeyError(name);
+ } else {
+ return i->second;
+ }
+}
+
+Receiver SessionImpl::getReceiver(const std::string& name) const
+{
+ qpid::sys::Mutex::ScopedLock l(lock);
+ Receivers::const_iterator i = receivers.find(name);
+ if (i == receivers.end()) {
+ throw KeyError(name);
+ } else {
+ return i->second;
+ }
+}
+
SessionImpl& SessionImpl::convert(qpid::messaging::Session& s)
{
boost::intrusive_ptr<SessionImpl> impl = getImplPtr<qpid::messaging::Session, SessionImpl>(s);
diff --git a/cpp/src/qpid/client/amqp0_10/SessionImpl.h b/cpp/src/qpid/client/amqp0_10/SessionImpl.h
index f3018b9685..872f66801d 100644
--- a/cpp/src/qpid/client/amqp0_10/SessionImpl.h
+++ b/cpp/src/qpid/client/amqp0_10/SessionImpl.h
@@ -65,6 +65,9 @@ class SessionImpl : public qpid::messaging::SessionImpl
qpid::messaging::Sender createSender(const qpid::messaging::Address& address);
qpid::messaging::Receiver createReceiver(const qpid::messaging::Address& address);
+ qpid::messaging::Sender getSender(const std::string& name) const;
+ qpid::messaging::Receiver getReceiver(const std::string& name) const;
+
bool nextReceiver(qpid::messaging::Receiver& receiver, qpid::sys::Duration timeout);
qpid::messaging::Receiver nextReceiver(qpid::sys::Duration timeout);
@@ -99,7 +102,7 @@ class SessionImpl : public qpid::messaging::SessionImpl
typedef std::map<std::string, qpid::messaging::Receiver> Receivers;
typedef std::map<std::string, qpid::messaging::Sender> Senders;
- qpid::sys::Mutex lock;
+ mutable qpid::sys::Mutex lock;
ConnectionImpl& connection;
qpid::client::Session session;
AddressResolution resolver;