summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpp/include/qpid/messaging/Address.h2
-rw-r--r--cpp/include/qpid/messaging/Codec.h2
-rw-r--r--cpp/include/qpid/messaging/Connection.h15
-rw-r--r--cpp/include/qpid/messaging/Handle.h71
-rw-r--r--cpp/include/qpid/messaging/ImportExport.h33
-rw-r--r--cpp/include/qpid/messaging/ListContent.h2
-rw-r--r--cpp/include/qpid/messaging/ListView.h2
-rw-r--r--cpp/include/qpid/messaging/MapContent.h2
-rw-r--r--cpp/include/qpid/messaging/MapView.h2
-rw-r--r--cpp/include/qpid/messaging/Message.h6
-rw-r--r--cpp/include/qpid/messaging/Receiver.h27
-rw-r--r--cpp/include/qpid/messaging/Sender.h15
-rw-r--r--cpp/include/qpid/messaging/Session.h34
-rw-r--r--cpp/include/qpid/messaging/Uuid.h2
-rw-r--r--cpp/include/qpid/messaging/Variant.h2
-rw-r--r--cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp4
-rw-r--r--cpp/src/qpid/client/amqp0_10/SessionImpl.cpp4
-rw-r--r--cpp/src/qpid/messaging/Connection.cpp12
-rw-r--r--cpp/src/qpid/messaging/ConnectionImpl.h3
-rw-r--r--cpp/src/qpid/messaging/PrivateImplRef.h94
-rw-r--r--cpp/src/qpid/messaging/Receiver.cpp12
-rw-r--r--cpp/src/qpid/messaging/ReceiverImpl.h3
-rw-r--r--cpp/src/qpid/messaging/Sender.cpp13
-rw-r--r--cpp/src/qpid/messaging/SenderImpl.h3
-rw-r--r--cpp/src/qpid/messaging/Session.cpp12
-rw-r--r--cpp/src/qpid/messaging/SessionImpl.h3
26 files changed, 263 insertions, 117 deletions
diff --git a/cpp/include/qpid/messaging/Address.h b/cpp/include/qpid/messaging/Address.h
index f3ca30bcd4..55befd2d6d 100644
--- a/cpp/include/qpid/messaging/Address.h
+++ b/cpp/include/qpid/messaging/Address.h
@@ -24,7 +24,7 @@
#include <string>
#include "qpid/Exception.h"
#include "qpid/messaging/Variant.h"
-#include "qpid/client/ClientImportExport.h"
+#include "qpid/messaging/ImportExport.h"
#include <ostream>
namespace qpid {
diff --git a/cpp/include/qpid/messaging/Codec.h b/cpp/include/qpid/messaging/Codec.h
index bacec5c786..b9b1cc862a 100644
--- a/cpp/include/qpid/messaging/Codec.h
+++ b/cpp/include/qpid/messaging/Codec.h
@@ -22,7 +22,7 @@
*
*/
#include <string>
-#include "qpid/client/ClientImportExport.h"
+#include "qpid/messaging/ImportExport.h"
namespace qpid {
namespace messaging {
diff --git a/cpp/include/qpid/messaging/Connection.h b/cpp/include/qpid/messaging/Connection.h
index e2d1cc2ed4..7f324cea1e 100644
--- a/cpp/include/qpid/messaging/Connection.h
+++ b/cpp/include/qpid/messaging/Connection.h
@@ -22,19 +22,14 @@
*
*/
#include <string>
-#include "qpid/client/ClientImportExport.h"
-#include "qpid/client/Handle.h"
+#include "qpid/messaging/ImportExport.h"
+#include "qpid/messaging/Handle.h"
#include "qpid/messaging/Variant.h"
namespace qpid {
-namespace client {
-
-template <class> class PrivateImplRef;
-
-}
-
namespace messaging {
+template <class> class PrivateImplRef;
class ConnectionImpl;
class Session;
@@ -43,7 +38,7 @@ struct InvalidOptionString : public qpid::Exception
InvalidOptionString(const std::string& msg);
};
-class Connection : public qpid::client::Handle<ConnectionImpl>
+class Connection : public qpid::messaging::Handle<ConnectionImpl>
{
public:
QPID_CLIENT_EXTERN Connection(ConnectionImpl* impl);
@@ -92,7 +87,7 @@ class Connection : public qpid::client::Handle<ConnectionImpl>
QPID_CLIENT_EXTERN Session getSession(const std::string& name) const;
private:
- friend class qpid::client::PrivateImplRef<Connection>;
+ friend class qpid::messaging::PrivateImplRef<Connection>;
};
diff --git a/cpp/include/qpid/messaging/Handle.h b/cpp/include/qpid/messaging/Handle.h
new file mode 100644
index 0000000000..c528c39e19
--- /dev/null
+++ b/cpp/include/qpid/messaging/Handle.h
@@ -0,0 +1,71 @@
+#ifndef QPID_MESSAGING_HANDLE_H
+#define QPID_MESSAGING_HANDLE_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"
+
+namespace qpid {
+namespace messaging {
+
+template <class> class PrivateImplRef;
+
+/**
+ * A handle is like a pointer: refers to an underlying implementation object.
+ * Copying the handle does not copy the object.
+ *
+ * Handles can be null, like a 0 pointer. Use isValid(), isNull() or the
+ * conversion to bool to test for a null handle.
+ */
+template <class T> class Handle {
+ public:
+
+ /**@return true if handle is valid, i.e. not null. */
+ QPID_CLIENT_EXTERN bool isValid() const { return impl; }
+
+ /**@return true if handle is null. It is an error to call any function on a null handle. */
+ QPID_CLIENT_EXTERN bool isNull() const { return !impl; }
+
+ /** Conversion to bool supports idiom if (handle) { handle->... } */
+ QPID_CLIENT_EXTERN operator bool() const { return impl; }
+
+ /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */
+ QPID_CLIENT_EXTERN bool operator !() const { return !impl; }
+
+ void swap(Handle<T>& h) { T* t = h.impl; h.impl = impl; impl = t; }
+
+ protected:
+ typedef T Impl;
+ QPID_CLIENT_EXTERN Handle() :impl() {}
+
+ // Not implemented,subclasses must implement.
+ QPID_CLIENT_EXTERN Handle(const Handle&);
+ QPID_CLIENT_EXTERN Handle& operator=(const Handle&);
+
+ Impl* impl;
+
+ friend class PrivateImplRef<T>;
+};
+
+}} // namespace qpid::messaging
+
+#endif /*!QPID_MESSAGING_HANDLE_H*/
diff --git a/cpp/include/qpid/messaging/ImportExport.h b/cpp/include/qpid/messaging/ImportExport.h
new file mode 100644
index 0000000000..7113b437be
--- /dev/null
+++ b/cpp/include/qpid/messaging/ImportExport.h
@@ -0,0 +1,33 @@
+#ifndef QPID_MESSAGING_IMPORTEXPORT_H
+#define QPID_MESSAGING_IMPORTEXPORT_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.
+ */
+
+#if defined(WIN32) && !defined(QPID_DECLARE_STATIC)
+#if defined(CLIENT_EXPORT) || defined (qpidclient_EXPORTS)
+#define QPID_CLIENT_EXTERN __declspec(dllexport)
+#else
+#define QPID_CLIENT_EXTERN __declspec(dllimport)
+#endif
+#else
+#define QPID_CLIENT_EXTERN
+#endif
+
+#endif /*!QPID_MESSAGING_IMPORTEXPORT_H*/
diff --git a/cpp/include/qpid/messaging/ListContent.h b/cpp/include/qpid/messaging/ListContent.h
index f57a920a88..3db8a8eac6 100644
--- a/cpp/include/qpid/messaging/ListContent.h
+++ b/cpp/include/qpid/messaging/ListContent.h
@@ -21,7 +21,7 @@
* under the License.
*
*/
-#include "qpid/client/ClientImportExport.h"
+#include "qpid/messaging/ImportExport.h"
#include "Variant.h"
namespace qpid {
diff --git a/cpp/include/qpid/messaging/ListView.h b/cpp/include/qpid/messaging/ListView.h
index 4970a20072..d7c3536a9c 100644
--- a/cpp/include/qpid/messaging/ListView.h
+++ b/cpp/include/qpid/messaging/ListView.h
@@ -22,7 +22,7 @@
*
*/
-#include "qpid/client/ClientImportExport.h"
+#include "qpid/messaging/ImportExport.h"
#include "Variant.h"
namespace qpid {
diff --git a/cpp/include/qpid/messaging/MapContent.h b/cpp/include/qpid/messaging/MapContent.h
index 3a80a38732..78ef51e593 100644
--- a/cpp/include/qpid/messaging/MapContent.h
+++ b/cpp/include/qpid/messaging/MapContent.h
@@ -22,7 +22,7 @@
*
*/
-#include "qpid/client/ClientImportExport.h"
+#include "qpid/messaging/ImportExport.h"
#include "Variant.h"
#include <map>
#include <string>
diff --git a/cpp/include/qpid/messaging/MapView.h b/cpp/include/qpid/messaging/MapView.h
index 910dfca5c2..baa999b4ad 100644
--- a/cpp/include/qpid/messaging/MapView.h
+++ b/cpp/include/qpid/messaging/MapView.h
@@ -21,7 +21,7 @@
* under the License.
*
*/
-#include "qpid/client/ClientImportExport.h"
+#include "qpid/messaging/ImportExport.h"
#include "Variant.h"
#include <map>
#include <string>
diff --git a/cpp/include/qpid/messaging/Message.h b/cpp/include/qpid/messaging/Message.h
index 30e15d79a3..21404d482b 100644
--- a/cpp/include/qpid/messaging/Message.h
+++ b/cpp/include/qpid/messaging/Message.h
@@ -25,12 +25,9 @@
#include <string>
#include "qpid/messaging/Duration.h"
#include "qpid/messaging/Variant.h"
-#include "qpid/client/ClientImportExport.h"
+#include "qpid/messaging/ImportExport.h"
namespace qpid {
-namespace client {
-}
-
namespace messaging {
class Address;
@@ -87,6 +84,7 @@ class Message
QPID_CLIENT_EXTERN const std::string& getContent() const;
QPID_CLIENT_EXTERN std::string& getContent();
+
QPID_CLIENT_EXTERN void setContent(const std::string&);
QPID_CLIENT_EXTERN void setContent(const char* chars, size_t count);
QPID_CLIENT_EXTERN void getContent(std::pair<const char*, size_t>& content) const;
diff --git a/cpp/include/qpid/messaging/Receiver.h b/cpp/include/qpid/messaging/Receiver.h
index bc1f39bfc1..80b58106d7 100644
--- a/cpp/include/qpid/messaging/Receiver.h
+++ b/cpp/include/qpid/messaging/Receiver.h
@@ -22,19 +22,15 @@
*
*/
#include "qpid/Exception.h"
-#include "qpid/client/ClientImportExport.h"
-#include "qpid/client/Handle.h"
+#include "qpid/messaging/ImportExport.h"
+#include "qpid/messaging/Handle.h"
#include "qpid/messaging/Duration.h"
namespace qpid {
-namespace client {
+namespace messaging {
template <class> class PrivateImplRef;
-}
-
-namespace messaging {
-
class Message;
class ReceiverImpl;
class Session;
@@ -42,7 +38,7 @@ class Session;
/**
* Interface through which messages are received.
*/
-class Receiver : public qpid::client::Handle<ReceiverImpl>
+class Receiver : public qpid::messaging::Handle<ReceiverImpl>
{
public:
struct NoMessageAvailable : qpid::Exception {};
@@ -60,14 +56,16 @@ class Receiver : public qpid::client::Handle<ReceiverImpl>
QPID_CLIENT_EXTERN bool get(Message& message, Duration timeout=INFINITE_DURATION);
/**
* Retrieves a message from this receivers local queue, or waits
- * for upto the specified timeout for a message to become
- * available. Throws NoMessageAvailable if there is no
- * message to give after waiting for the specified timeout.
+ * for up to the specified timeout for a message to become
+ * available.
+ *
+ *@exception NoMessageAvailable if there is no message to give
+ * after waiting for the specified timeout.
*/
QPID_CLIENT_EXTERN Message get(Duration timeout=INFINITE_DURATION);
/**
* Retrieves a message for this receivers subscription or waits
- * for upto the specified timeout for one to become
+ * for up to the specified timeout for one to become
* available. Unlike get() this method will check with the server
* that there is no message for the subscription this receiver is
* serving before returning false.
@@ -79,6 +77,9 @@ class Receiver : public qpid::client::Handle<ReceiverImpl>
* available. Unlike get() this method will check with the server
* that there is no message for the subscription this receiver is
* serving before throwing an exception.
+ *
+ *@exception NoMessageAvailable if there is no message to give
+ * after waiting for the specified timeout.
*/
QPID_CLIENT_EXTERN Message fetch(Duration timeout=INFINITE_DURATION);
/**
@@ -123,7 +124,7 @@ class Receiver : public qpid::client::Handle<ReceiverImpl>
QPID_CLIENT_EXTERN Session getSession() const;
private:
- friend class qpid::client::PrivateImplRef<Receiver>;
+ friend class qpid::messaging::PrivateImplRef<Receiver>;
};
}} // namespace qpid::messaging
diff --git a/cpp/include/qpid/messaging/Sender.h b/cpp/include/qpid/messaging/Sender.h
index eb8ccc2f84..b7dd015a55 100644
--- a/cpp/include/qpid/messaging/Sender.h
+++ b/cpp/include/qpid/messaging/Sender.h
@@ -21,27 +21,22 @@
* under the License.
*
*/
-#include "qpid/client/ClientImportExport.h"
-#include "qpid/client/Handle.h"
+#include "qpid/messaging/ImportExport.h"
+#include "qpid/messaging/Handle.h"
#include "qpid/sys/IntegerTypes.h"
#include <string>
namespace qpid {
-namespace client {
-
-template <class> class PrivateImplRef;
-
-}
-
namespace messaging {
+template <class> class PrivateImplRef;
class Message;
class SenderImpl;
class Session;
/**
* Interface through which messages are sent.
*/
-class Sender : public qpid::client::Handle<SenderImpl>
+class Sender : public qpid::messaging::Handle<SenderImpl>
{
public:
QPID_CLIENT_EXTERN Sender(SenderImpl* impl = 0);
@@ -79,7 +74,7 @@ class Sender : public qpid::client::Handle<SenderImpl>
*/
QPID_CLIENT_EXTERN Session getSession() const;
private:
- friend class qpid::client::PrivateImplRef<Sender>;
+ friend class qpid::messaging::PrivateImplRef<Sender>;
};
}} // namespace qpid::messaging
diff --git a/cpp/include/qpid/messaging/Session.h b/cpp/include/qpid/messaging/Session.h
index 87f69f268a..5375b4d346 100644
--- a/cpp/include/qpid/messaging/Session.h
+++ b/cpp/include/qpid/messaging/Session.h
@@ -23,20 +23,15 @@
*/
#include "qpid/Exception.h"
#include "qpid/messaging/Duration.h"
-#include "qpid/client/ClientImportExport.h"
-#include "qpid/client/Handle.h"
+#include "qpid/messaging/ImportExport.h"
+#include "qpid/messaging/Handle.h"
#include "qpid/sys/Time.h"
#include <string>
namespace qpid {
-namespace client {
-
-template <class> class PrivateImplRef;
-
-}
-
namespace messaging {
+template <class> class PrivateImplRef;
class Address;
class Connection;
class Message;
@@ -55,7 +50,7 @@ struct KeyError : qpid::Exception
* A session represents a distinct 'conversation' which can involve
* sending and receiving messages to and from different addresses.
*/
-class Session : public qpid::client::Handle<SessionImpl>
+class Session : public qpid::messaging::Handle<SessionImpl>
{
public:
QPID_CLIENT_EXTERN Session(SessionImpl* impl = 0);
@@ -83,8 +78,8 @@ class Session : public qpid::client::Handle<SessionImpl>
QPID_CLIENT_EXTERN void flush();
/**
- * Returns the number of messages received and waiting to be
- * fetched.
+ * Returns the total number of messages received and waiting to be
+ * fetched by all Receivers belonging to this session.
*/
QPID_CLIENT_EXTERN uint32_t available();
/**
@@ -99,14 +94,15 @@ class Session : public qpid::client::Handle<SessionImpl>
* to the specified timeout waiting for one to arrive. Returns
* true if a message was available at the point of return, in
* which case the passed in receiver reference will be set to the
- * receiver for that message or fals if no message was available.
+ * receiver for that message or false if no message was available.
*/
QPID_CLIENT_EXTERN bool nextReceiver(Receiver&, Duration timeout=INFINITE_DURATION);
/**
* Returns the receiver for the next available message. If there
* are no available messages at present the call will block for up
- * to the specified timeout waiting for one to arrive. Will throw
- * Receiver::NoMessageAvailable if no message became available in
+ * to the specified timeout waiting for one to arrive.
+ *
+ *@exception Receiver::NoMessageAvailable if no message became available in
* time.
*/
QPID_CLIENT_EXTERN Receiver nextReceiver(Duration timeout=INFINITE_DURATION);
@@ -126,13 +122,13 @@ class Session : public qpid::client::Handle<SessionImpl>
QPID_CLIENT_EXTERN Receiver createReceiver(const std::string& address);
/**
- * Returns the sender with the specified name or throws KeyError
- * if there is none for that name.
+ * Returns the sender with the specified name.
+ *@exception KeyError if there is none for that name.
*/
QPID_CLIENT_EXTERN Sender getSender(const std::string& name) const;
/**
- * Returns the receiver with the specified name or throws KeyError
- * if there is none for that name.
+ * Returns the receiver with the specified name.
+ *@exception KeyError if there is none for that name.
*/
QPID_CLIENT_EXTERN Receiver getReceiver(const std::string& name) const;
/**
@@ -142,7 +138,7 @@ class Session : public qpid::client::Handle<SessionImpl>
QPID_CLIENT_EXTERN Connection getConnection() const;
private:
- friend class qpid::client::PrivateImplRef<Session>;
+ friend class qpid::messaging::PrivateImplRef<Session>;
};
}} // namespace qpid::messaging
diff --git a/cpp/include/qpid/messaging/Uuid.h b/cpp/include/qpid/messaging/Uuid.h
index bbc9bd7a97..d83f8495b7 100644
--- a/cpp/include/qpid/messaging/Uuid.h
+++ b/cpp/include/qpid/messaging/Uuid.h
@@ -22,7 +22,7 @@
*
*/
-#include "qpid/client/ClientImportExport.h"
+#include "qpid/messaging/ImportExport.h"
#include <iosfwd>
#include <string>
diff --git a/cpp/include/qpid/messaging/Variant.h b/cpp/include/qpid/messaging/Variant.h
index 0bf62a9909..51c6bd98fe 100644
--- a/cpp/include/qpid/messaging/Variant.h
+++ b/cpp/include/qpid/messaging/Variant.h
@@ -28,7 +28,7 @@
#include "Uuid.h"
#include "qpid/Exception.h"
#include "qpid/sys/IntegerTypes.h"
-#include "qpid/client/ClientImportExport.h"
+#include "qpid/messaging/ImportExport.h"
namespace qpid {
namespace messaging {
diff --git a/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp b/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp
index 9c1c4e0735..ce4e1ecc2a 100644
--- a/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp
+++ b/cpp/src/qpid/client/amqp0_10/ConnectionImpl.cpp
@@ -22,7 +22,7 @@
#include "SessionImpl.h"
#include "SimpleUrlParser.h"
#include "qpid/messaging/Session.h"
-#include "qpid/client/PrivateImplRef.h"
+#include "qpid/messaging/PrivateImplRef.h"
#include "qpid/framing/Uuid.h"
#include "qpid/log/Statement.h"
#include <boost/intrusive_ptr.hpp>
@@ -150,7 +150,7 @@ void ConnectionImpl::close()
boost::intrusive_ptr<SessionImpl> getImplPtr(qpid::messaging::Session& session)
{
return boost::dynamic_pointer_cast<SessionImpl>(
- qpid::client::PrivateImplRef<qpid::messaging::Session>::get(session)
+ qpid::messaging::PrivateImplRef<qpid::messaging::Session>::get(session)
);
}
diff --git a/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp b/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp
index d9fd3a5da1..f12d383206 100644
--- a/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp
+++ b/cpp/src/qpid/client/amqp0_10/SessionImpl.cpp
@@ -24,7 +24,7 @@
#include "qpid/client/amqp0_10/SenderImpl.h"
#include "qpid/client/amqp0_10/MessageSource.h"
#include "qpid/client/amqp0_10/MessageSink.h"
-#include "qpid/client/PrivateImplRef.h"
+#include "qpid/messaging/PrivateImplRef.h"
#include "qpid/Exception.h"
#include "qpid/log/Statement.h"
#include "qpid/messaging/Address.h"
@@ -114,7 +114,7 @@ void SessionImpl::close()
template <class T, class S> boost::intrusive_ptr<S> getImplPtr(T& t)
{
- return boost::dynamic_pointer_cast<S>(qpid::client::PrivateImplRef<T>::get(t));
+ return boost::dynamic_pointer_cast<S>(qpid::messaging::PrivateImplRef<T>::get(t));
}
template <class T> void getFreeKey(std::string& key, T& map)
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;