4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief pimpl_ptr inline template implementation */
26 //#include "pimpl_ptr.ih"
29 #include "IgnoreValue.hh"
31 #define prefix_ inline
32 ///////////////////////////////cti.p///////////////////////////////////////
34 ///////////////////////////////////////////////////////////////////////////
35 // senf::pimpl_ptr<T,CloneAllocator>
37 template <typename T, class CloneAllocator>
38 prefix_ senf::pimpl_ptr<T,CloneAllocator>::pimpl_ptr(T* pointee)
41 // Is it fair to assume pointer assignment to be atomic on multi-threaded platforms ?
43 doDelete_ = &myDeleteFn;
46 template <typename T, class CloneAllocator>
47 prefix_ senf::pimpl_ptr<T,CloneAllocator>::pimpl_ptr(const pimpl_ptr & rhs)
51 template <typename T, class CloneAllocator>
52 prefix_ senf::pimpl_ptr<T,CloneAllocator>::~pimpl_ptr()
58 template <typename T, class CloneAllocator>
59 prefix_ const T* senf::pimpl_ptr<T,CloneAllocator>::get()
65 template <typename T, class CloneAllocator>
66 prefix_ T* senf::pimpl_ptr<T,CloneAllocator>::get()
72 template <typename T, class CloneAllocator>
73 prefix_ const T* senf::pimpl_ptr<T,CloneAllocator>::operator->()
79 template <typename T, class CloneAllocator>
80 prefix_ T* senf::pimpl_ptr<T,CloneAllocator>::operator->()
86 template <typename T, class CloneAllocator>
87 prefix_ const T& senf::pimpl_ptr<T,CloneAllocator>::operator*()
93 template <typename T, class CloneAllocator>
94 prefix_ T& senf::pimpl_ptr<T,CloneAllocator>::operator*()
100 template <typename T, class CloneAllocator>
101 prefix_ void senf::pimpl_ptr<T,CloneAllocator>::swap(pimpl_ptr & with)
104 std::swap(p, with.p);
107 template <typename T, class CloneAllocator>
108 prefix_ senf::pimpl_ptr<T,CloneAllocator> &
109 senf::pimpl_ptr<T,CloneAllocator>::operator=(const pimpl_ptr & rhs)
111 T* pp = doCopy_(rhs.p);
117 template <typename T, class CloneAllocator>
118 prefix_ void senf::pimpl_ptr<T,CloneAllocator>::myDeleteFn(T* p)
120 return CloneAllocator::deallocate_clone(p);
123 template <typename T, class CloneAllocator>
124 prefix_ T* senf::pimpl_ptr<T,CloneAllocator>::myCopyFn(const T* p)
126 return CloneAllocator::allocate_clone(*p);
129 ///////////////////////////////////////////////////////////////////////////
131 template <class T, class CloneAllocator>
132 prefix_ void std::swap(senf::pimpl_ptr<T,CloneAllocator> & lhs,
133 senf::pimpl_ptr<T,CloneAllocator> & rhs)
139 template <class T, class CloneAllocator>
140 typename senf::pimpl_ptr<T,CloneAllocator>::Copier
141 senf::pimpl_ptr<T,CloneAllocator>::doCopy_ (0);
143 template <class T, class CloneAllocator>
144 typename senf::pimpl_ptr<T,CloneAllocator>::Deleter
145 senf::pimpl_ptr<T,CloneAllocator>::doDelete_ (0);
147 ///////////////////////////////cti.e///////////////////////////////////////
154 // comment-column: 40
155 // c-file-style: "senf"
156 // indent-tabs-mode: nil
157 // ispell-local-dictionary: "american"
158 // compile-command: "scons -u test"