dep_spec_flattener.hh

Go to the documentation of this file.
00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
00005  *
00006  * This file is part of the Paludis package manager. Paludis is free software;
00007  * you can redistribute it and/or modify it under the terms of the GNU General
00008  * Public License version 2, as published by the Free Software Foundation.
00009  *
00010  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
00011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00012  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00013  * details.
00014  *
00015  * You should have received a copy of the GNU General Public License along with
00016  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00017  * Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 
00020 #ifndef PALUDIS_GUARD_PALUDIS_DEP_ATOM_FLATTENER_HH
00021 #define PALUDIS_GUARD_PALUDIS_DEP_ATOM_FLATTENER_HH 1
00022 
00023 #include <paludis/environment-fwd.hh>
00024 #include <paludis/package_id-fwd.hh>
00025 #include <paludis/dep_spec-fwd.hh>
00026 #include <paludis/spec_tree.hh>
00027 #include <paludis/util/attributes.hh>
00028 #include <paludis/util/instantiation_policy.hh>
00029 #include <paludis/util/private_implementation_pattern.hh>
00030 #include <paludis/util/no_type.hh>
00031 #include <paludis/util/wrapped_forward_iterator-fwd.hh>
00032 #include <tr1/memory>
00033 
00034 /** \file
00035  * Declarations for DepSpecFlattener.
00036  *
00037  * \ingroup g_dep_spec
00038  *
00039  * \section Examples
00040  *
00041  * - \ref example_dep_spec_flattener.cc "example_dep_spec_flattener.cc"
00042  */
00043 
00044 namespace paludis
00045 {
00046     /**
00047      * Extract the enabled components of a dep heirarchy for a particular
00048      * package. Sets, via NamedSetDepSpec, are automatically expanded.
00049      *
00050      * This template can be instantiated as:
00051      *
00052      * - DepSpecFlattener<ProvideSpecTree, PackageDepSpec>
00053      * - DepSpecFlattener<PlainTextSpecTree, PlainTextDepSpec>
00054      * - DepSpecFlattener<SetSpecTree, PackageDepSpec>
00055      * - DepSpecFlattener<SimpleURISpecTree, SimpleURIDepSpec>
00056      *
00057      * It is <b>not</b> suitable for heirarchies that can contain AnyDepSpec.
00058      * Any labels are discarded.
00059      *
00060      * \ingroup g_dep_spec
00061      * \since 0.26
00062      * \nosubgrouping
00063      */
00064     template <typename Heirarchy_, typename Item_>
00065     class PALUDIS_VISIBLE DepSpecFlattener :
00066         private InstantiationPolicy<DepSpecFlattener<Heirarchy_, Item_>, instantiation_method::NonCopyableTag>,
00067         private PrivateImplementationPattern<DepSpecFlattener<Heirarchy_, Item_> >
00068     {
00069         private:
00070             typename PrivateImplementationPattern<DepSpecFlattener<Heirarchy_, Item_> >::ImpPtr & _imp;
00071 
00072         public:
00073             ///\name Visit operations
00074             ///\{
00075 
00076             void visit(const typename Heirarchy_::template NodeType<NamedSetDepSpec>::Type & node);
00077             void visit(const typename Heirarchy_::template NodeType<PlainTextDepSpec>::Type & node);
00078             void visit(const typename Heirarchy_::template NodeType<PackageDepSpec>::Type & node);
00079             void visit(const typename Heirarchy_::template NodeType<SimpleURIDepSpec>::Type & node);
00080             void visit(const typename Heirarchy_::template NodeType<PlainTextLabelDepSpec>::Type & node);
00081 
00082             void visit(const typename Heirarchy_::template NodeType<AllDepSpec>::Type & node);
00083             void visit(const typename Heirarchy_::template NodeType<AnyDepSpec>::Type & node);
00084             void visit(const typename Heirarchy_::template NodeType<ConditionalDepSpec>::Type & node);
00085 
00086             ///\}
00087 
00088             ///\name Visit implementation operations
00089 
00090             template <bool b_> void handle_named_set(const NamedSetDepSpec & spec);
00091             void handle_item(const Item_ & spec);
00092 
00093             ///\}
00094 
00095             ///\name Basic operations
00096             ///\{
00097 
00098             DepSpecFlattener(const Environment * const);
00099 
00100             ~DepSpecFlattener();
00101 
00102             ///\}
00103 
00104             ///\name Iterate over our dep specs
00105             ///\{
00106 
00107             struct ConstIteratorTag;
00108             typedef WrappedForwardIterator<ConstIteratorTag, const std::tr1::shared_ptr<const Item_> > ConstIterator;
00109 
00110             ConstIterator begin() const;
00111             ConstIterator end() const;
00112 
00113             ///\}
00114     };
00115 
00116 #ifdef PALUDIS_HAVE_EXTERN_TEMPLATE
00117     extern template class DepSpecFlattener<ProvideSpecTree, PackageDepSpec>;
00118     extern template class DepSpecFlattener<PlainTextSpecTree, PlainTextDepSpec>;
00119     extern template class DepSpecFlattener<SetSpecTree, PackageDepSpec>;
00120     extern template class DepSpecFlattener<SimpleURISpecTree, SimpleURIDepSpec>;
00121 #endif
00122 }
00123 
00124 #endif

Generated on Mon Sep 21 10:36:08 2009 for paludis by  doxygen 1.5.4