#ifndef QPID_CLIENT_PRIVATEIMPLPRIVATE_H #define QPID_CLIENT_PRIVATEIMPLPRIVATE_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 namespace qpid { namespace client { /** @file * Implementation of PrivateImpl functions, to include in .cpp file of handle subclasses. * T can be any class with value semantics. */ template PrivateImpl::PrivateImpl(T* p) : impl(p) { assert(impl); } template PrivateImpl::~PrivateImpl() { delete impl; } template PrivateImpl::PrivateImpl(const PrivateImpl& h) : impl(new T(*h.impl)) {} template PrivateImpl& PrivateImpl::operator=(const PrivateImpl& h) { PrivateImpl(h).swap(*this); return *this; } template void PrivateImpl::swap(PrivateImpl& h) { std::swap(impl, h.impl); } /** Access to private impl of a PrivateImpl */ template class PrivateImplPrivate { public: static T* get(const PrivateImpl& h) { return h.impl; } static void set(PrivateImpl& h, const T& p) { PrivateImpl(p).swap(h); } }; template T* privateImplGetPtr(PrivateImpl& h) { return PrivateImplPrivate::get(h); } template T* privateImplGetPtr(const PrivateImpl& h) { return PrivateImplPrivate::get(h); } template void privateImplSetPtr(PrivateImpl& h, const T*& p) { PrivateImplPrivate::set(h, p); } }} // namespace qpid::client #endif /*!QPID_CLIENT_PRIVATEIMPLPRIVATE_H*/