diff options
author | Alan Conway <aconway@apache.org> | 2010-03-16 18:01:38 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2010-03-16 18:01:38 +0000 |
commit | db9e84cd3de1e56ae81e0ca6110c164435e7ca5a (patch) | |
tree | 8f75a1ffb2fd6bdf3af3a0d7bf337e54d131520a /cpp/src/qpid/messaging | |
parent | 24952dc43e52362d5e16a5dbd795fae7d07a12d0 (diff) | |
download | qpid-python-db9e84cd3de1e56ae81e0ca6110c164435e7ca5a.tar.gz |
Removed dependencies in qpid/messaging on qpid/client.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@923908 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/messaging')
-rw-r--r-- | cpp/src/qpid/messaging/Connection.cpp | 12 | ||||
-rw-r--r-- | cpp/src/qpid/messaging/ConnectionImpl.h | 3 | ||||
-rw-r--r-- | cpp/src/qpid/messaging/PrivateImplRef.h | 94 | ||||
-rw-r--r-- | cpp/src/qpid/messaging/Receiver.cpp | 12 | ||||
-rw-r--r-- | cpp/src/qpid/messaging/ReceiverImpl.h | 3 | ||||
-rw-r--r-- | cpp/src/qpid/messaging/Sender.cpp | 13 | ||||
-rw-r--r-- | cpp/src/qpid/messaging/SenderImpl.h | 3 | ||||
-rw-r--r-- | cpp/src/qpid/messaging/Session.cpp | 12 | ||||
-rw-r--r-- | cpp/src/qpid/messaging/SessionImpl.h | 3 |
9 files changed, 106 insertions, 49 deletions
diff --git a/cpp/src/qpid/messaging/Connection.cpp b/cpp/src/qpid/messaging/Connection.cpp index 4873899787..cb06af7693 100644 --- a/cpp/src/qpid/messaging/Connection.cpp +++ b/cpp/src/qpid/messaging/Connection.cpp @@ -23,23 +23,17 @@ #include "qpid/messaging/ConnectionImpl.h" #include "qpid/messaging/Session.h" #include "qpid/messaging/SessionImpl.h" -#include "qpid/client/PrivateImplRef.h" +#include "qpid/messaging/PrivateImplRef.h" #include "qpid/client/amqp0_10/ConnectionImpl.h" #include "qpid/log/Statement.h" namespace qpid { -namespace client { - -typedef PrivateImplRef<qpid::messaging::Connection> PI; - -} - namespace messaging { -using qpid::client::PI; +typedef PrivateImplRef<qpid::messaging::Connection> PI; Connection::Connection(ConnectionImpl* impl) { PI::ctor(*this, impl); } -Connection::Connection(const Connection& c) : qpid::client::Handle<ConnectionImpl>() { PI::copy(*this, c); } +Connection::Connection(const Connection& c) : Handle<ConnectionImpl>() { PI::copy(*this, c); } Connection& Connection::operator=(const Connection& c) { return PI::assign(*this, c); } Connection::~Connection() { PI::dtor(*this); } diff --git a/cpp/src/qpid/messaging/ConnectionImpl.h b/cpp/src/qpid/messaging/ConnectionImpl.h index 33ebcda950..2f03c9610b 100644 --- a/cpp/src/qpid/messaging/ConnectionImpl.h +++ b/cpp/src/qpid/messaging/ConnectionImpl.h @@ -25,9 +25,6 @@ #include "qpid/RefCounted.h" namespace qpid { -namespace client { -} - namespace messaging { class Session; diff --git a/cpp/src/qpid/messaging/PrivateImplRef.h b/cpp/src/qpid/messaging/PrivateImplRef.h new file mode 100644 index 0000000000..cc2798c647 --- /dev/null +++ b/cpp/src/qpid/messaging/PrivateImplRef.h @@ -0,0 +1,94 @@ +#ifndef QPID_MESSAGING_PRIVATEIMPL_H +#define QPID_MESSAGING_PRIVATEIMPL_H + +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ + +#include "qpid/messaging/ImportExport.h" +#include <boost/intrusive_ptr.hpp> +#include "qpid/RefCounted.h" + +namespace qpid { +namespace messaging { + +// FIXME aconway 2009-04-24: details! +/** @file + * + * Helper class to implement a class with a private, reference counted + * implementation and reference semantics. + * + * Such classes are used in the public API to hide implementation, they + * should. Example of use: + * + * === Foo.h + * + * template <class T> PrivateImplRef; + * class FooImpl; + * + * Foo : public Handle<FooImpl> { + * public: + * Foo(FooImpl* = 0); + * Foo(const Foo&); + * ~Foo(); + * Foo& operator=(const Foo&); + * + * int fooDo(); // and other Foo functions... + * + * private: + * typedef FooImpl Impl; + * Impl* impl; + * friend class PrivateImplRef<Foo>; + * + * === Foo.cpp + * + * typedef PrivateImplRef<Foo> PI; + * Foo::Foo(FooImpl* p) { PI::ctor(*this, p); } + * Foo::Foo(const Foo& c) : Handle<FooImpl>() { PI::copy(*this, c); } + * Foo::~Foo() { PI::dtor(*this); } + * Foo& Foo::operator=(const Foo& c) { return PI::assign(*this, c); } + * + * int foo::fooDo() { return impl->fooDo(); } + * + */ +template <class T> class PrivateImplRef { + public: + typedef typename T::Impl Impl; + typedef boost::intrusive_ptr<Impl> intrusive_ptr; + + static intrusive_ptr get(const T& t) { return intrusive_ptr(t.impl); } + + static void set(T& t, const intrusive_ptr& p) { + if (t.impl == p) return; + if (t.impl) boost::intrusive_ptr_release(t.impl); + t.impl = p.get(); + if (t.impl) boost::intrusive_ptr_add_ref(t.impl); + } + + // Helper functions to implement the ctor, dtor, copy, assign + static void ctor(T& t, Impl* p) { t.impl = p; if (p) boost::intrusive_ptr_add_ref(p); } + static void copy(T& t, const T& x) { if (&t == &x) return; t.impl = 0; assign(t, x); } + static void dtor(T& t) { if(t.impl) boost::intrusive_ptr_release(t.impl); } + static T& assign(T& t, const T& x) { set(t, get(x)); return t;} +}; + +}} // namespace qpid::messaging + +#endif /*!QPID_MESSAGING_PRIVATEIMPL_H*/ diff --git a/cpp/src/qpid/messaging/Receiver.cpp b/cpp/src/qpid/messaging/Receiver.cpp index 841bee274c..df13052671 100644 --- a/cpp/src/qpid/messaging/Receiver.cpp +++ b/cpp/src/qpid/messaging/Receiver.cpp @@ -22,21 +22,15 @@ #include "qpid/messaging/Message.h" #include "qpid/messaging/ReceiverImpl.h" #include "qpid/messaging/Session.h" -#include "qpid/client/PrivateImplRef.h" +#include "qpid/messaging/PrivateImplRef.h" namespace qpid { -namespace client { - -typedef PrivateImplRef<qpid::messaging::Receiver> PI; - -} - namespace messaging { -using qpid::client::PI; +typedef PrivateImplRef<qpid::messaging::Receiver> PI; Receiver::Receiver(ReceiverImpl* impl) { PI::ctor(*this, impl); } -Receiver::Receiver(const Receiver& s) : qpid::client::Handle<ReceiverImpl>() { PI::copy(*this, s); } +Receiver::Receiver(const Receiver& s) : Handle<ReceiverImpl>() { PI::copy(*this, s); } Receiver::~Receiver() { PI::dtor(*this); } Receiver& Receiver::operator=(const Receiver& s) { return PI::assign(*this, s); } bool Receiver::get(Message& message, Duration timeout) { return impl->get(message, timeout); } diff --git a/cpp/src/qpid/messaging/ReceiverImpl.h b/cpp/src/qpid/messaging/ReceiverImpl.h index a720fe8210..c156265f6c 100644 --- a/cpp/src/qpid/messaging/ReceiverImpl.h +++ b/cpp/src/qpid/messaging/ReceiverImpl.h @@ -24,9 +24,6 @@ #include "qpid/RefCounted.h" namespace qpid { -namespace client { -} - namespace messaging { class Message; diff --git a/cpp/src/qpid/messaging/Sender.cpp b/cpp/src/qpid/messaging/Sender.cpp index 5e18db1d7c..711a857d7a 100644 --- a/cpp/src/qpid/messaging/Sender.cpp +++ b/cpp/src/qpid/messaging/Sender.cpp @@ -22,21 +22,14 @@ #include "qpid/messaging/Message.h" #include "qpid/messaging/SenderImpl.h" #include "qpid/messaging/Session.h" -#include "qpid/client/PrivateImplRef.h" +#include "qpid/messaging/PrivateImplRef.h" namespace qpid { -namespace client { - -typedef PrivateImplRef<qpid::messaging::Sender> PI; - -} - namespace messaging { - -using qpid::client::PI; +typedef PrivateImplRef<qpid::messaging::Sender> PI; Sender::Sender(SenderImpl* impl) { PI::ctor(*this, impl); } -Sender::Sender(const Sender& s) : qpid::client::Handle<SenderImpl>() { PI::copy(*this, s); } +Sender::Sender(const Sender& s) : qpid::messaging::Handle<SenderImpl>() { PI::copy(*this, s); } Sender::~Sender() { PI::dtor(*this); } Sender& Sender::operator=(const Sender& s) { return PI::assign(*this, s); } void Sender::send(const Message& message) { impl->send(message); } diff --git a/cpp/src/qpid/messaging/SenderImpl.h b/cpp/src/qpid/messaging/SenderImpl.h index 0294688771..7653049c26 100644 --- a/cpp/src/qpid/messaging/SenderImpl.h +++ b/cpp/src/qpid/messaging/SenderImpl.h @@ -24,9 +24,6 @@ #include "qpid/RefCounted.h" namespace qpid { -namespace client { -} - namespace messaging { class Message; diff --git a/cpp/src/qpid/messaging/Session.cpp b/cpp/src/qpid/messaging/Session.cpp index 5d1a6fb815..2ac19727e3 100644 --- a/cpp/src/qpid/messaging/Session.cpp +++ b/cpp/src/qpid/messaging/Session.cpp @@ -25,21 +25,15 @@ #include "qpid/messaging/Sender.h" #include "qpid/messaging/Receiver.h" #include "qpid/messaging/SessionImpl.h" -#include "qpid/client/PrivateImplRef.h" +#include "qpid/messaging/PrivateImplRef.h" namespace qpid { -namespace client { - -typedef PrivateImplRef<qpid::messaging::Session> PI; - -} - namespace messaging { -using qpid::client::PI; +typedef PrivateImplRef<qpid::messaging::Session> PI; Session::Session(SessionImpl* impl) { PI::ctor(*this, impl); } -Session::Session(const Session& s) : qpid::client::Handle<SessionImpl>() { PI::copy(*this, s); } +Session::Session(const Session& s) : Handle<SessionImpl>() { PI::copy(*this, s); } Session::~Session() { PI::dtor(*this); } Session& Session::operator=(const Session& s) { return PI::assign(*this, s); } void Session::commit() { impl->commit(); } diff --git a/cpp/src/qpid/messaging/SessionImpl.h b/cpp/src/qpid/messaging/SessionImpl.h index 653df8fdda..79f0d007b5 100644 --- a/cpp/src/qpid/messaging/SessionImpl.h +++ b/cpp/src/qpid/messaging/SessionImpl.h @@ -26,9 +26,6 @@ #include "qpid/messaging/Duration.h" namespace qpid { -namespace client { -} - namespace messaging { class Address; |