paludis  Version 2.6.0
clone.hh
Go to the documentation of this file.
1 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
2 
3 /*
4  * Copyright (c) 2007 David Leverton
5  * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
6  *
7  * This file is part of the Paludis package manager. Paludis is free software;
8  * you can redistribute it and/or modify it under the terms of the GNU General
9  * Public License version 2, as published by the Free Software Foundation.
10  *
11  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
18  * Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 #ifndef PALUDIS_GUARD_PALUDIS_UTIL_CLONE_HH
22 #define PALUDIS_GUARD_PALUDIS_UTIL_CLONE_HH 1
23 
25 #include <memory>
26 
27 /** \file
28  * Declares the Cloneable class and helpers.
29  *
30  * \ingroup g_oo
31  *
32  * \section Examples
33  *
34  * - None at this time.
35  */
36 
37 namespace paludis
38 {
39  /**
40  * Base class for objects that can be cloned.
41  *
42  * \ingroup g_oo
43  * \nosubgrouping
44  */
45  template <typename T_>
47  {
48  public:
49  ///\name Cloning
50  ///\{
51 
52  /**
53  * Return a new copy of ourselves.
54  */
55  virtual std::shared_ptr<T_> clone() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
56 
57  ///\}
58 
59  ///\name Basic operations
60  ///\{
61 
62  virtual ~Cloneable();
63 
64  ///\}
65  };
66 
67  /**
68  * Helper class implementing the clone() method using the copy
69  * contructor.
70  *
71  * \ingroup g_oo
72  * \nosubgrouping
73  */
74  template <typename Base_, typename Child_>
76  public virtual Cloneable<Base_>
77  {
78  public:
79  virtual std::shared_ptr<Base_> clone() const PALUDIS_ATTRIBUTE((warn_unused_result));
80 
81  ///\name Basic operations
82  ///\{
83 
84  virtual ~CloneUsingThis();
85 
86  ///\}
87  };
88 }
89 
90 #endif
91 
92 
Definition: about_metadata-fwd.hh:23
Definition: clone.hh:46
Definition: clone.hh:75
#define PALUDIS_ATTRIBUTE(x)
Definition: attributes.hh:53
#define PALUDIS_VISIBLE
Definition: attributes.hh:59