paludis Version 3.0.2
The one true package mangler
ndbam.hh
1/* vim: set sw=4 sts=4 et foldmethod=syntax : */
2
3/*
4 * Copyright (c) 2007, 2008, 2009, 2010, 2011, 2013 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_REPOSITORIES_UNPACKAGED_NDBAM_HH
21#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_UNPACKAGED_NDBAM_HH 1
22
23#include <paludis/ndbam-fwd.hh>
24#include <paludis/util/pimp.hh>
26#include <paludis/util/fs_path.hh>
28#include <paludis/util/named_value.hh>
29#include <paludis/name.hh>
33#include <functional>
34#include <mutex>
35
36namespace paludis
37{
38 namespace n
39 {
40 typedef Name<struct name_fs_location> fs_location;
41 typedef Name<struct name_magic> magic;
42 typedef Name<struct name_mutex> mutex;
43 typedef Name<struct name_name> name;
44 typedef Name<struct name_package_id> package_id;
45 typedef Name<struct name_slot> slot;
46 typedef Name<struct name_version> version;
47 }
48
59
60 /**
61 * NDBAM provides a partial implementation of a Repository for installed packages using
62 * a Paludis-defined on-disk format. It is used by unpackaged repositories and exndbam,
63 * where the format can be defined by us. NDBAM is designed to reduce unnecessary disk
64 * access and to reduce the need for global locking.
65 *
66 * \ingroup g_ndbam
67 * \since 0.26
68 */
70 {
71 private:
72 Pimp<NDBAM> _imp;
73
74 public:
75 ///\name Basic operations
76 ///\{
77
78 /**
79 * Constructor.
80 *
81 * \param version_options \since 0.38
82 */
83 NDBAM(const FSPath &,
84 const std::function<bool (const std::string &)> & check_format,
85 const std::string & preferred_format, const VersionSpecOptions & version_options);
86 ~NDBAM();
87
88 ///\}
89
90 ///\name Repository method implementations
91 ///\{
92
93 std::shared_ptr<const CategoryNamePartSet> category_names()
94 PALUDIS_ATTRIBUTE((warn_unused_result));
95
96 std::shared_ptr<const QualifiedPackageNameSet> package_names(
97 const CategoryNamePart & c)
98 PALUDIS_ATTRIBUTE((warn_unused_result));
99
100 std::shared_ptr<const CategoryNamePartSet> category_names_containing_package(
101 const PackageNamePart &) const
102 PALUDIS_ATTRIBUTE((warn_unused_result));
103
104 bool has_package_named(const QualifiedPackageName &)
105 PALUDIS_ATTRIBUTE((warn_unused_result));
106
107 bool has_category_named(const CategoryNamePart &)
108 PALUDIS_ATTRIBUTE((warn_unused_result));
109
110 std::shared_ptr<NDBAMEntrySequence> entries(const QualifiedPackageName &)
111 PALUDIS_ATTRIBUTE((warn_unused_result));
112
113 void add_entry(const QualifiedPackageName &, const FSPath &);
114 void remove_entry(const QualifiedPackageName &, const FSPath &);
115
116 ///\}
117
118 /**
119 * Parse the contents file for a given ID, using the provided callbacks.
120 */
122 const std::function<void (const std::shared_ptr<const ContentsEntry> &)> & on_file,
123 const std::function<void (const std::shared_ptr<const ContentsEntry> &)> & on_dir,
124 const std::function<void (const std::shared_ptr<const ContentsEntry> &)> & on_sym
125 ) const;
126
127 /**
128 * Index a newly added QualifiedPackageName, using the provided data directory
129 * name part.
130 */
131 void index(const QualifiedPackageName &, const std::string &) const;
132
133 /**
134 * Deindex a QualifiedPackageName that no longer has any versions installed.
135 */
136 void deindex(const QualifiedPackageName &) const;
137 };
138}
139
140#endif
Definition contents.hh:57
Definition fs_path.hh:34
void parse_contents(const PackageID &, const std::function< void(const std::shared_ptr< const ContentsEntry > &)> &on_file, const std::function< void(const std::shared_ptr< const ContentsEntry > &)> &on_dir, const std::function< void(const std::shared_ptr< const ContentsEntry > &)> &on_sym) const
void deindex(const QualifiedPackageName &) const
NDBAM(const FSPath &, const std::function< bool(const std::string &)> &check_format, const std::string &preferred_format, const VersionSpecOptions &version_options)
void index(const QualifiedPackageName &, const std::string &) const
Definition named_value.hh:51
Definition package_id.hh:99
Definition pimp.hh:52
Definition name.hh:112
Options< VersionSpecOption > VersionSpecOptions
Definition version_spec-fwd.hh:48
WrappedValue< CategoryNamePartTag > CategoryNamePart
Definition name-fwd.hh:61
WrappedValue< PackageNamePartTag > PackageNamePart
Definition name-fwd.hh:47
#define PALUDIS_ATTRIBUTE(x)
Definition attributes.hh:53
#define PALUDIS_VISIBLE
Definition attributes.hh:59
Definition about_metadata-fwd.hh:24
Definition ndbam.hh:50