Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Utils / pimpl_ptr.cti
1 // $Id$
2 //
3 // Copyright (C) 2010
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
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.
12 //
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.
17 //
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.
22
23 /** \file
24     \brief pimpl_ptr inline template implementation */
25
26 //#include "pimpl_ptr.ih"
27
28 // Custom includes
29 #include "IgnoreValue.hh"
30
31 #define prefix_ inline
32 //-/////////////////////////////////////////////////////////////////////////////////////////////////
33
34 //-/////////////////////////////////////////////////////////////////////////////////////////////////
35 // senf::pimpl_ptr<T,CloneAllocator>
36
37 template <typename T, class CloneAllocator>
38 prefix_ senf::pimpl_ptr<T,CloneAllocator>::pimpl_ptr(T* pointee)
39     : p (pointee)
40 {
41     // Is it fair to assume pointer assignment to be atomic on multi-threaded platforms ?
42     doCopy_ = &myCopyFn;
43     doDelete_ = &myDeleteFn;
44 }
45
46 template <typename T, class CloneAllocator>
47 prefix_ senf::pimpl_ptr<T,CloneAllocator>::pimpl_ptr(const pimpl_ptr & rhs)
48     : p (doCopy_(rhs.p))
49 {}
50
51 template <typename T, class CloneAllocator>
52 prefix_ senf::pimpl_ptr<T,CloneAllocator>::~pimpl_ptr()
53     throw()
54 {
55     doDelete_(p);
56 }
57
58 template <typename T, class CloneAllocator>
59 prefix_ const T* senf::pimpl_ptr<T,CloneAllocator>::get()
60     const throw()
61 {
62     return p;
63 }
64
65 template <typename T, class CloneAllocator>
66 prefix_ T* senf::pimpl_ptr<T,CloneAllocator>::get()
67     throw()
68 {
69     return p;
70 }
71
72 template <typename T, class CloneAllocator>
73 prefix_ const T* senf::pimpl_ptr<T,CloneAllocator>::operator->()
74     const throw()
75 {
76     return p;
77 }
78
79 template <typename T, class CloneAllocator>
80 prefix_ T* senf::pimpl_ptr<T,CloneAllocator>::operator->()
81     throw()
82 {
83     return p;
84 }
85
86 template <typename T, class CloneAllocator>
87 prefix_ const T& senf::pimpl_ptr<T,CloneAllocator>::operator*()
88     const throw()
89 {
90     return *p;
91 }
92
93 template <typename T, class CloneAllocator>
94 prefix_ T& senf::pimpl_ptr<T,CloneAllocator>::operator*()
95     throw()
96 {
97     return *p;
98 }
99
100 template <typename T, class CloneAllocator>
101 prefix_ void senf::pimpl_ptr<T,CloneAllocator>::swap(pimpl_ptr & with)
102     throw()
103 {
104     std::swap(p, with.p);
105 }
106
107 template <typename T, class CloneAllocator>
108 prefix_ senf::pimpl_ptr<T,CloneAllocator> &
109 senf::pimpl_ptr<T,CloneAllocator>::operator=(const pimpl_ptr & rhs)
110 {
111     T* pp = doCopy_(rhs.p);
112     doDelete_(p);
113     p = pp;
114     return *this;
115 }
116
117 template <typename T, class CloneAllocator>
118 prefix_ void senf::pimpl_ptr<T,CloneAllocator>::myDeleteFn(T* p)
119 {
120     return CloneAllocator::deallocate_clone(p);
121 }
122
123 template <typename T, class CloneAllocator>
124 prefix_ T* senf::pimpl_ptr<T,CloneAllocator>::myCopyFn(const T* p)
125 {
126     return CloneAllocator::allocate_clone(*p);
127 }
128
129 //-/////////////////////////////////////////////////////////////////////////////////////////////////
130
131 template <class T, class CloneAllocator>
132 prefix_ void std::swap(senf::pimpl_ptr<T,CloneAllocator> & lhs,
133                        senf::pimpl_ptr<T,CloneAllocator> & rhs)
134     throw()
135 {
136     lhs.swap(rhs);
137 }
138
139 template <class T, class CloneAllocator>
140 typename senf::pimpl_ptr<T,CloneAllocator>::Copier
141     senf::pimpl_ptr<T,CloneAllocator>::doCopy_ (0);
142
143 template <class T, class CloneAllocator>
144 typename senf::pimpl_ptr<T,CloneAllocator>::Deleter
145     senf::pimpl_ptr<T,CloneAllocator>::doDelete_ (0);
146
147 //-/////////////////////////////////////////////////////////////////////////////////////////////////
148 #undef prefix_
149
150 \f
151 // Local Variables:
152 // mode: c++
153 // fill-column: 100
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"
159 // End: