paludis Version 3.0.2
The one true package mangler
spec_tree.hh
1/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3/*
4 * Copyright (c) 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_SPEC_TREE_HH
21#define PALUDIS_GUARD_PALUDIS_SPEC_TREE_HH 1
22
23#include <paludis/spec_tree-fwd.hh>
24#include <paludis/util/wrapped_forward_iterator.hh>
25#include <paludis/util/visitor.hh>
27#include <type_traits>
28
29namespace paludis
30{
31 namespace spec_tree_internals
32 {
33 template <typename Tree_>
35 public virtual DeclareAbstractAcceptMethods<BasicNode<Tree_>, typename Tree_::VisitableTypeList>
36 {
37 public:
38 virtual ~BasicNode() = default;
39 };
40
41 template <typename Tree_, typename Item_>
42 class PALUDIS_VISIBLE LeafNode :
43 public BasicNode<Tree_>,
44 public ImplementAcceptMethods<BasicNode<Tree_>, LeafNode<Tree_, Item_> >
45 {
46 private:
47 const std::shared_ptr<const Item_> _spec;
48
49 public:
50 explicit LeafNode(const std::shared_ptr<const Item_> & i);
51
52 template <typename OtherTree_>
53 operator LeafNode<OtherTree_, Item_> () const;
54
55 const std::shared_ptr<const Item_> spec() const;
56 };
57
58 template <typename Tree_, typename Item_>
59 class InnerNode;
60
61 template <typename Tree_>
62 class PALUDIS_VISIBLE BasicInnerNode :
63 public BasicNode<Tree_>
64 {
65 private:
67 std::shared_ptr<ChildList> _child_list;
68
69 public:
70 BasicInnerNode();
71
72 typedef BasicInnerNodeConstIteratorTag<Tree_> ConstIteratorTag;
73 typedef WrappedForwardIterator<ConstIteratorTag,
74 const std::shared_ptr<const BasicNode<Tree_> > > ConstIterator;
75
76 ConstIterator begin() const;
77
78 ConstIterator end() const;
79
80 void append_node(const std::shared_ptr<const BasicNode<Tree_> > & t);
81
82 template <typename T_>
83 const std::shared_ptr<typename Tree_::template NodeType<T_>::Type>
84 append(const std::shared_ptr<const T_> & t);
85
86 template <typename T_>
87 const std::shared_ptr<typename Tree_::template NodeType<T_>::Type>
88 append(const std::shared_ptr<T_> & t);
89 };
90
91 template <typename Tree_, typename Item_>
92 class PALUDIS_VISIBLE InnerNode :
93 public BasicInnerNode<Tree_>,
94 public ImplementAcceptMethods<BasicNode<Tree_>, InnerNode<Tree_, Item_> >
95 {
96 private:
97 const std::shared_ptr<const Item_> _spec;
98
99 public:
100 explicit InnerNode(const std::shared_ptr<const Item_> & i);
101
102 template <typename OtherTree_>
103 operator InnerNode<OtherTree_, Item_> () const;
104
105 const std::shared_ptr<const Item_> spec() const;
106 };
107
108 template <typename Tree_>
110 {
111 typedef TypeListTail Type;
112 };
113
114 template <typename Tree_, typename Item_, typename Tail_>
120
121 template <typename Tree_, typename Item_, typename Tail_>
127
128 template <typename Tree_, typename NodeList_>
130 {
132 };
133 }
134
135 template <typename NodeList_, typename RootNode_>
136 class PALUDIS_VISIBLE SpecTree
137 {
138 public:
139 typedef typename spec_tree_internals::MakeVisitableTypeList<SpecTree, NodeList_>::Type VisitableTypeList;
140
143
144 template <typename Node_>
149
150 template <typename Node_>
155
156 template <typename Node_>
157 struct NodeType
158 {
159 typedef typename std::conditional<
161 typename SpecTree::template LeafNodeType<Node_>::Type,
162 typename std::conditional<
164 typename InnerNodeType<Node_>::Type,
166 >::type
167 >::type Type;
168 };
169
170 explicit SpecTree(const std::shared_ptr<RootNode_> & spec);
171
172 explicit SpecTree(const std::shared_ptr<const RootNode_> & spec);
173
174 const std::shared_ptr<typename InnerNodeType<RootNode_>::Type> top();
175
176 const std::shared_ptr<const typename InnerNodeType<RootNode_>::Type> top() const;
177
178 private:
179 const std::shared_ptr<typename InnerNodeType<RootNode_>::Type> _top;
180 };
181
182 extern template class PALUDIS_VISIBLE SpecTree<MakeTypeList<
199
200 extern template class PALUDIS_VISIBLE SpecTree<MakeTypeList<
206
207 extern template class PALUDIS_VISIBLE SpecTree<MakeTypeList<
213
214 extern template class PALUDIS_VISIBLE SpecTree<MakeTypeList<
219
220 extern template class PALUDIS_VISIBLE SpecTree<MakeTypeList<
225
226 extern template class PALUDIS_VISIBLE SpecTree<MakeTypeList<
232
233 extern template class PALUDIS_VISIBLE SpecTree<MakeTypeList<
241
242 extern template class PALUDIS_VISIBLE SpecTree<MakeTypeList<
251
252 extern template class PALUDIS_VISIBLE SpecTree<MakeTypeList<
257
259 const std::shared_ptr<const spec_tree_internals::BasicNode<GenericSpecTree> > >;
261 const std::shared_ptr<const spec_tree_internals::BasicNode<DependencySpecTree> > >;
263 const std::shared_ptr<const spec_tree_internals::BasicNode<SetSpecTree> > >;
265 const std::shared_ptr<const spec_tree_internals::BasicNode<PlainTextSpecTree> > >;
267 const std::shared_ptr<const spec_tree_internals::BasicNode<RequiredUseSpecTree> > >;
269 const std::shared_ptr<const spec_tree_internals::BasicNode<SimpleURISpecTree> > >;
271 const std::shared_ptr<const spec_tree_internals::BasicNode<FetchableURISpecTree> > >;
273 const std::shared_ptr<const spec_tree_internals::BasicNode<LicenseSpecTree> > >;
274}
275
276#endif
Definition dep_spec.hh:139
Definition visitor.hh:326
Definition visitor.hh:411
Definition sequence.hh:51
Definition spec_tree.hh:137
Definition wrapped_forward_iterator.hh:42
Definition spec_tree.hh:36
Definition spec_tree.hh:95
Definition spec_tree.hh:45
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24
Definition type_list-fwd.hh:31
Definition spec_tree-fwd.hh:29
Definition spec_tree-fwd.hh:32
Definition spec_tree.hh:152
Definition spec_tree.hh:146
Definition spec_tree.hh:158
Definition type_list-fwd.hh:46
Definition type_list.hh:33
Definition type_list.hh:28