clone.hh

Go to the documentation of this file.
00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 2007 David Leverton
00005  * Copyright (c) 2007, 2008 Ciaran McCreesh
00006  *
00007  * This file is part of the Paludis package manager. Paludis is free software;
00008  * you can redistribute it and/or modify it under the terms of the GNU General
00009  * Public License version 2, as published by the Free Software Foundation.
00010  *
00011  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
00012  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00014  * details.
00015  *
00016  * You should have received a copy of the GNU General Public License along with
00017  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00018  * Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 #ifndef PALUDIS_GUARD_PALUDIS_UTIL_CLONE_HH
00022 #define PALUDIS_GUARD_PALUDIS_UTIL_CLONE_HH 1
00023 
00024 #include <paludis/util/attributes.hh>
00025 #include <tr1/memory>
00026 
00027 #ifdef PALUDIS_HAVE_CONCEPTS
00028 #  include <concepts>
00029 #endif
00030 
00031 /** \file
00032  * Declares the Cloneable class and helpers.
00033  *
00034  * \ingroup g_oo
00035  *
00036  * \section Examples
00037  *
00038  * - None at this time.
00039  */
00040 
00041 namespace paludis
00042 {
00043     /**
00044      * Base class for objects that can be cloned.
00045      *
00046      * \ingroup g_oo
00047      * \nosubgrouping
00048      */
00049     template <typename T_>
00050     class PALUDIS_VISIBLE Cloneable
00051     {
00052         public:
00053             ///\name Cloning
00054             ///\{
00055 
00056             /**
00057              * Return a new copy of ourselves.
00058              */
00059             virtual std::tr1::shared_ptr<T_> clone() const PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
00060 
00061             ///\}
00062 
00063             ///\name Basic operations
00064             ///\{
00065 
00066             virtual ~Cloneable();
00067 
00068             ///\}
00069     };
00070 
00071     /**
00072      * Helper class implementing the clone() method using the copy
00073      * contructor.
00074      *
00075      * \ingroup g_oo
00076      * \nosubgrouping
00077      */
00078     template <typename Base_, typename Child_>
00079     class PALUDIS_VISIBLE CloneUsingThis :
00080         public virtual Cloneable<Base_>
00081     {
00082         public:
00083             virtual std::tr1::shared_ptr<Base_> clone() const PALUDIS_ATTRIBUTE((warn_unused_result));
00084 
00085             ///\name Basic operations
00086             ///\{
00087 
00088             virtual ~CloneUsingThis();
00089 
00090             ///\}
00091     };
00092 }
00093 
00094 #endif
00095 
00096 

Generated on Mon Dec 22 19:43:51 2008 for paludis by  doxygen 1.5.7.1