paludis  Version 2.0.0
pimp.hh
Go to the documentation of this file.
1 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
2 
3 /*
4  * Copyright (c) 2005, 2006, 2007, 2010, 2011 Ciaran McCreesh
5  *
6  * This file is part of the Paludis package manager. Paludis is free software;
7  * you can redistribute it and/or modify it under the terms of the GNU General
8  * Public License version 2, as published by the Free Software Foundation.
9  *
10  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License along with
16  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17  * Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 
20 #ifndef PALUDIS_GUARD_PALUDIS_PRIVATE_IMPLEMENTATION_PATTERN_HH
21 #define PALUDIS_GUARD_PALUDIS_PRIVATE_IMPLEMENTATION_PATTERN_HH 1
22 
23 /** \file
24  * Declarations for the Pimp pattern.
25  *
26  * \ingroup g_oo
27  *
28  * \section Examples
29  *
30  * - None at this time.
31  */
32 
33 namespace paludis
34 {
35  /**
36  * Private implementation data, to be specialised for any class that
37  * uses Pimp.
38  *
39  * \ingroup g_oo
40  */
41  template <typename C_>
42  struct Imp;
43 
44  /**
45  * Pointer to our implementation data.
46  *
47  * \ingroup g_oo
48  * \since 0.58
49  */
50  template <typename C_>
51  class Pimp
52  {
53  private:
54  Imp<C_> * _ptr;
55 
56  public:
57  ///\name Basic operations
58  ///\{
59 
60  template <typename... Args_>
61  explicit Pimp(Args_ && ... args);
62 
63  ~Pimp();
64 
65  Pimp(Pimp &&);
66 
67  Pimp(const Pimp &) = delete;
68  Pimp & operator= (const Pimp &) = delete;
69 
70  ///\}
71 
72  ///\name Dereference operators
73  //\{
74 
75  inline Imp<C_> * operator-> ();
76 
77  inline const Imp<C_> * operator-> () const;
78 
79  Imp<C_> * get();
80 
81  const Imp<C_> * get() const;
82 
83  ///\}
84 
85  /**
86  * Reset to a new Imp.
87  */
88  void reset(Imp<C_> * p);
89  };
90 }
91 
92 template <typename C_>
95 {
96  return _ptr;
97 }
98 
99 template <typename C_>
100 const paludis::Imp<C_> *
102 {
103  return _ptr;
104 }
105 
106 #endif
Definition: pimp.hh:51
Definition: pimp.hh:42
void reset(Imp< C_ > *p)