paludis Version 3.0.2
The one true package mangler
contents.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_CONTENTS_HH
21#define PALUDIS_GUARD_PALUDIS_CONTENTS_HH 1
22
24#include <paludis/util/visitor.hh>
25#include <paludis/util/pimp.hh>
26#include <paludis/util/type_list.hh>
27#include <paludis/util/wrapped_forward_iterator.hh>
28#include <paludis/util/fs_path-fwd.hh>
29#include <paludis/metadata_key_holder.hh>
30#include <memory>
31#include <string>
32
33/** \file
34 * Declarations for the Contents classes.
35 *
36 * \ingroup g_contents
37 *
38 * \section Examples
39 *
40 * - \ref example_contents.cc "example_contents.cc"
41 */
42
43namespace paludis
44{
45 /**
46 * Base class for a contents entry.
47 *
48 * \since 0.36 for MetadataKeyHolder methods.
49 *
50 * \ingroup g_contents
51 * \nosubgrouping
52 */
53 class PALUDIS_VISIBLE ContentsEntry :
54 public MetadataKeyHolder,
55 public virtual DeclareAbstractAcceptMethods<ContentsEntry, MakeTypeList<
56 ContentsFileEntry, ContentsDirEntry, ContentsSymEntry, ContentsOtherEntry>::Type>
57 {
58 private:
60
61 protected:
62 void need_keys_added() const override;
63
64 public:
65 ///\name Basic operations
66 ///\{
67
68 ContentsEntry(const FSPath & path);
69 ~ContentsEntry() override = 0;
70
71 ///\}
72
73 ///\name Metadata key operations
74 ///\{
75
76 /**
77 * Must be called straight after construction.
78 *
79 * \since 0.36
80 */
82
83 ///\}
84
85 ///\name Specific metadata keys
86 ///\{
87
88 /**
89 * Our path on disk. Must not be zero. Not modified for root.
90 *
91 * \since 0.36
92 */
93 const std::shared_ptr<const MetadataValueKey<FSPath> > location_key() const;
94
95 ///\}
96 };
97
98 /**
99 * A file contents entry.
100 *
101 * \ingroup g_contents
102 * \nosubgrouping
103 */
104 class PALUDIS_VISIBLE ContentsFileEntry :
105 public ContentsEntry,
106 public ImplementAcceptMethods<ContentsEntry, ContentsFileEntry>
107 {
108 private:
110
111 public:
112 ///\name Basic operations
113 ///\{
114
115 ContentsFileEntry(const FSPath &, const std::string &);
116 ~ContentsFileEntry() override;
117
118 ///\}
119
120 ///\name Specific metadata keys
121 ///\{
122
123 const std::shared_ptr<const MetadataValueKey<std::string> >
124 part_key() const;
125
126 ///\}
127 };
128
129 /**
130 * A directory contents entry.
131 *
132 * \ingroup g_contents
133 * \nosubgrouping
134 */
135 class PALUDIS_VISIBLE ContentsDirEntry :
136 public ContentsEntry,
137 public ImplementAcceptMethods<ContentsEntry, ContentsDirEntry>
138 {
139 public:
140 ///\name Basic operations
141 ///\{
142
143 ContentsDirEntry(const FSPath &);
144
145 ///\}
146 };
147
148 /**
149 * An 'other' contents entry, which we can't handle.
150 *
151 * \since 0.36
152 * \ingroup g_contents
153 * \nosubgrouping
154 */
155 class PALUDIS_VISIBLE ContentsOtherEntry :
156 public ContentsEntry,
157 public ImplementAcceptMethods<ContentsEntry, ContentsOtherEntry>
158 {
159 public:
160 ///\name Basic operations
161 ///\{
162
163 ContentsOtherEntry(const FSPath &);
164
165 ///\}
166 };
167
168 /**
169 * A sym contents entry.
170 *
171 * \ingroup g_contents
172 * \nosubgrouping
173 */
174 class PALUDIS_VISIBLE ContentsSymEntry :
175 public ContentsEntry,
176 public ImplementAcceptMethods<ContentsEntry, ContentsSymEntry>
177 {
178 private:
180
181 public:
182 ///\name Basic operations
183 ///\{
184
185 ContentsSymEntry(const FSPath &, const std::string &,
186 const std::string &);
187 ~ContentsSymEntry() override;
188
189 ///\}
190
191 ///\name Specific metadata keys
192 ///\{
193
194 /**
195 * Our target, as per readlink. Must not be zero.
196 *
197 * \since 0.36
198 */
199 const std::shared_ptr<const MetadataValueKey<std::string> > target_key() const;
200
201 const std::shared_ptr<const MetadataValueKey<std::string> >
202 part_key() const;
203
204 ///\}
205 };
206
207 /**
208 * A package's contents, obtainable by PackageID::contents.
209 *
210 * \ingroup g_contents
211 * \nosubgrouping
212 */
213 class PALUDIS_VISIBLE Contents
214 {
215 private:
216 Pimp<Contents> _imp;
217
218 public:
219 ///\name Basic operations
220 ///\{
221
222 Contents();
223 ~Contents();
224
225 Contents(const Contents &) = delete;
226 Contents & operator= (const Contents &) = delete;
227
228 ///\}
229
230 /// Add a new entry.
231 void add(const std::shared_ptr<const ContentsEntry> & c);
232
233 ///\name Iterate over our entries
234 ///\{
235
236 struct ConstIteratorTag;
238
239 ConstIterator begin() const
240 PALUDIS_ATTRIBUTE((warn_unused_result));
241
242 ConstIterator end() const
243 PALUDIS_ATTRIBUTE((warn_unused_result));
244
245 ///\}
246 };
247
248 extern template class Pimp<Contents>;
249 extern template class Pimp<ContentsEntry>;
250 extern template class Pimp<ContentsSymEntry>;
251 extern template class Pimp<ContentsFileEntry>;
252
253 extern template class PALUDIS_VISIBLE WrappedForwardIterator<Contents::ConstIteratorTag, const std::shared_ptr<const ContentsEntry> >;
254}
255
256#endif
Definition contents.hh:57
void need_keys_added() const override
const std::shared_ptr< const MetadataValueKey< FSPath > > location_key() const
Definition contents.hh:107
Definition contents.hh:177
const std::shared_ptr< const MetadataValueKey< std::string > > target_key() const
void add(const std::shared_ptr< const ContentsEntry > &c)
Add a new entry.
Definition visitor.hh:326
Definition fs_path.hh:34
Definition visitor.hh:411
virtual void add_metadata_key(const std::shared_ptr< const MetadataKey > &) const
Definition pimp.hh:52
Definition wrapped_forward_iterator.hh:42
#define PALUDIS_ATTRIBUTE(x)
Definition attributes.hh:53
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24