00001 #ifndef QPID_CLIENT_PRIVATEIMPL_H
00002 #define QPID_CLIENT_PRIVATEIMPL_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "qpid/client/ClientImportExport.h"
00026 #include <boost/intrusive_ptr.hpp>
00027 #include "qpid/RefCounted.h"
00028
00029 namespace qpid {
00030 namespace client {
00031
00032
00071 template <class T> class PrivateImplRef {
00072 public:
00073 typedef typename T::Impl Impl;
00074 typedef boost::intrusive_ptr<Impl> intrusive_ptr;
00075
00076 static intrusive_ptr get(const T& t) { return intrusive_ptr(t.impl); }
00077
00078 static void set(T& t, const intrusive_ptr& p) {
00079 if (t.impl == p) return;
00080 if (t.impl) boost::intrusive_ptr_release(t.impl);
00081 t.impl = p.get();
00082 if (t.impl) boost::intrusive_ptr_add_ref(t.impl);
00083 }
00084
00085
00086 static void ctor(T& t, Impl* p) { t.impl = p; if (p) boost::intrusive_ptr_add_ref(p); }
00087 static void copy(T& t, const T& x) { if (&t == &x) return; t.impl = 0; assign(t, x); }
00088 static void dtor(T& t) { if(t.impl) boost::intrusive_ptr_release(t.impl); }
00089 static T& assign(T& t, const T& x) { set(t, get(x)); return t;}
00090 };
00091
00092 }}
00093
00094 #endif