pimpl_ptr.hh
Go to the documentation of this file.
1 //
2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
6 //
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
11 //
12 
13 
17 #ifndef HH_SENF_Utils_pimpl_ptr_
18 #define HH_SENF_Utils_pimpl_ptr_ 1
19 
20 // Custom includes
21 #include <algorithm>
22 #include <boost/ptr_container/clone_allocator.hpp>
23 
24 //#include "pimpl_ptr.mpp"
25 //-/////////////////////////////////////////////////////////////////////////////////////////////////
26 
27 namespace senf
28 {
29 
30  template<typename T, class CloneAllocator=boost::heap_clone_allocator>
31  class pimpl_ptr
32  {
33  typedef void (*Deleter)(T* p);
34  typedef T* (*Copier)(const T* p);
35 
36  public:
37  explicit pimpl_ptr(T* pointee);
38  pimpl_ptr(const pimpl_ptr & rhs);
39  ~pimpl_ptr() throw();
40 
41  const T* get() const throw();
42  T* get() throw();
43 
44  const T* operator->() const throw();
45  T* operator->() throw();
46 
47  const T& operator*() const throw();
48  T& operator*() throw();
49 
50  void swap(pimpl_ptr& with) throw();
51 
52  pimpl_ptr & operator=(const pimpl_ptr & rhs);
53 
54  private:
55  static Copier doCopy_;
56  static Deleter doDelete_;
57  T* p;
58 
59  static void myDeleteFn(T* p);
60  static T* myCopyFn(const T* p);
61  };
62 
63 }
64 
65 namespace std
66 {
67  template<class T, class CloneAllocator>
69  throw();
70 }
71 
72 //-/////////////////////////////////////////////////////////////////////////////////////////////////
73 //#include "pimpl_ptr.cci"
74 //#include "pimpl_ptr.ct"
75 #include "pimpl_ptr.cti"
76 #endif
77 
78 
79 // Local Variables:
80 // mode: c++
81 // fill-column: 100
82 // comment-column: 40
83 // c-file-style: "senf"
84 // indent-tabs-mode: nil
85 // ispell-local-dictionary: "american"
86 // compile-command: "scons -u test"
87 // End:
pimpl_ptr & operator=(const pimpl_ptr &rhs)
const T * operator->() const
STL namespace.
void swap(pimpl_ptr &with)
pimpl_ptr(T *pointee)
const T & operator*() const