paludis  Version 2.6.0
dep_spec_flattener.hh
Go to the documentation of this file.
1 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
2 
3 /*
4  * Copyright (c) 2006, 2007, 2008, 2009, 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_DEP_ATOM_FLATTENER_HH
21 #define PALUDIS_GUARD_PALUDIS_DEP_ATOM_FLATTENER_HH 1
22 
25 #include <paludis/dep_spec-fwd.hh>
26 #include <paludis/spec_tree.hh>
28 #include <paludis/util/pimp.hh>
29 #include <paludis/util/no_type.hh>
30 #include <paludis/util/wrapped_forward_iterator.hh>
31 #include <memory>
32 #include <type_traits>
33 
34 /** \file
35  * Declarations for DepSpecFlattener.
36  *
37  * \ingroup g_dep_spec
38  *
39  * \section Examples
40  *
41  * - \ref example_dep_spec_flattener.cc "example_dep_spec_flattener.cc"
42  */
43 
44 namespace paludis
45 {
46  /**
47  * Extract the enabled components of a dep heirarchy for a particular
48  * package. Sets, via NamedSetDepSpec, are automatically expanded.
49  *
50  * This template can be instantiated as:
51  *
52  * - DepSpecFlattener<PlainTextSpecTree, PlainTextDepSpec>
53  * - DepSpecFlattener<SetSpecTree, PackageDepSpec>
54  * - DepSpecFlattener<SimpleURISpecTree, SimpleURIDepSpec>
55  *
56  * It is <b>not</b> suitable for heirarchies that can contain AnyDepSpec.
57  * Any labels are discarded.
58  *
59  * \ingroup g_dep_spec
60  * \since 0.26
61  * \nosubgrouping
62  */
63  template <typename Heirarchy_, typename Item_>
65  {
66  private:
68 
69  public:
70  ///\name Visit operations
71  ///\{
72 
73  void visit(const typename Heirarchy_::template NodeType<NamedSetDepSpec>::Type & node);
74  void visit(const typename Heirarchy_::template NodeType<PlainTextDepSpec>::Type & node);
75  void visit(const typename Heirarchy_::template NodeType<PackageDepSpec>::Type & node);
76  void visit(const typename Heirarchy_::template NodeType<SimpleURIDepSpec>::Type & node);
77  void visit(const typename Heirarchy_::template NodeType<PlainTextLabelDepSpec>::Type & node);
78 
79  void visit(const typename Heirarchy_::template NodeType<AllDepSpec>::Type & node);
80  void visit(const typename Heirarchy_::template NodeType<AnyDepSpec>::Type & node);
81  void visit(const typename Heirarchy_::template NodeType<ConditionalDepSpec>::Type & node);
82 
83  ///\}
84 
85  ///\name Visit implementation operations
86 
87  template <bool b_> void handle_named_set(const NamedSetDepSpec & spec);
88  void handle_item(const Item_ & spec);
89 
90  ///\}
91 
92  ///\name Basic operations
93  ///\{
94 
96  const Environment * const,
97  const std::shared_ptr<const PackageID> & = typename std::enable_if<
98  std::is_same<Heirarchy_, SetSpecTree>::value,
99  std::shared_ptr<const PackageID> >::type());
100 
101  ~DepSpecFlattener();
102 
103  DepSpecFlattener(const DepSpecFlattener &) = delete;
104 
105  DepSpecFlattener & operator= (const DepSpecFlattener &) = delete;
106 
107  ///\}
108 
109  ///\name Iterate over our dep specs
110  ///\{
111 
112  struct ConstIteratorTag;
114 
115  ConstIterator begin() const;
116  ConstIterator end() const;
117 
118  ///\}
119  };
120 
124 
126  const std::shared_ptr<const PlainTextDepSpec> >;
128  const std::shared_ptr<const PackageDepSpec> >;
130  const std::shared_ptr<const SimpleURIDepSpec> >;
131 }
132 
133 #endif
Definition: pimp.hh:51
Definition: about_metadata-fwd.hh:23
Definition: dep_spec_flattener.hh:64
Definition: dep_spec.hh:477
Definition: environment.hh:200
Definition: wrapped_forward_iterator-fwd.hh:26
#define PALUDIS_VISIBLE
Definition: attributes.hh:59