ndbam.hh

00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 2007, 2008, 2009 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_REPOSITORIES_UNPACKAGED_NDBAM_HH
00021 #define PALUDIS_GUARD_PALUDIS_REPOSITORIES_UNPACKAGED_NDBAM_HH 1
00022 
00023 #include <paludis/ndbam-fwd.hh>
00024 #include <paludis/util/private_implementation_pattern.hh>
00025 #include <paludis/util/attributes.hh>
00026 #include <paludis/util/fs_entry.hh>
00027 #include <paludis/util/sequence-fwd.hh>
00028 #include <paludis/util/mutex.hh>
00029 #include <paludis/util/named_value.hh>
00030 #include <paludis/name.hh>
00031 #include <paludis/version_spec.hh>
00032 #include <paludis/package_id-fwd.hh>
00033 #include <paludis/contents-fwd.hh>
00034 #include <tr1/functional>
00035 
00036 namespace paludis
00037 {
00038     namespace n
00039     {
00040         struct fs_location;
00041         struct magic;
00042         struct mutex;
00043         struct name;
00044         struct package_id;
00045         struct slot;
00046         struct version;
00047     }
00048 
00049     struct NDBAMEntry
00050     {
00051         NamedValue<n::fs_location, FSEntry> fs_location;
00052         NamedValue<n::magic, std::string> magic;
00053         NamedValue<n::mutex, std::tr1::shared_ptr<Mutex> > mutex;
00054         NamedValue<n::name, QualifiedPackageName> name;
00055         NamedValue<n::package_id, std::tr1::shared_ptr<PackageID> > package_id;
00056         NamedValue<n::slot, SlotName> slot;
00057         NamedValue<n::version, VersionSpec> version;
00058     };
00059 
00060     /**
00061      * NDBAM provides a partial implementation of a Repository for installed packages using
00062      * a Paludis-defined on-disk format. It is used by unpackaged repositories and exndbam,
00063      * where the format can be defined by us. NDBAM is designed to reduce unnecessary disk
00064      * access and to reduce the need for global locking.
00065      *
00066      * \ingroup g_ndbam
00067      * \since 0.26
00068      */
00069     class PALUDIS_VISIBLE NDBAM :
00070         private PrivateImplementationPattern<NDBAM>
00071     {
00072         public:
00073             ///\name Basic operations
00074             ///\{
00075 
00076             /**
00077              * Constructor.
00078              *
00079              * \param version_options \since 0.38
00080              */
00081             NDBAM(const FSEntry &,
00082                     const std::tr1::function<bool (const std::string &)> & check_format,
00083                     const std::string & preferred_format, const VersionSpecOptions & version_options);
00084             ~NDBAM();
00085 
00086             ///\}
00087 
00088             ///\name Repository method implementations
00089             ///\{
00090 
00091             std::tr1::shared_ptr<const CategoryNamePartSet> category_names()
00092                 PALUDIS_ATTRIBUTE((warn_unused_result));
00093 
00094             std::tr1::shared_ptr<const QualifiedPackageNameSet> package_names(
00095                     const CategoryNamePart & c)
00096                 PALUDIS_ATTRIBUTE((warn_unused_result));
00097 
00098             std::tr1::shared_ptr<const CategoryNamePartSet> category_names_containing_package(
00099                     const PackageNamePart &) const
00100                 PALUDIS_ATTRIBUTE((warn_unused_result));
00101 
00102             bool has_package_named(const QualifiedPackageName &)
00103                 PALUDIS_ATTRIBUTE((warn_unused_result));
00104 
00105             bool has_category_named(const CategoryNamePart &)
00106                 PALUDIS_ATTRIBUTE((warn_unused_result));
00107 
00108             std::tr1::shared_ptr<NDBAMEntrySequence> entries(const QualifiedPackageName &)
00109                 PALUDIS_ATTRIBUTE((warn_unused_result));
00110 
00111             void add_entry(const QualifiedPackageName &, const FSEntry &);
00112             void remove_entry(const QualifiedPackageName &, const FSEntry &);
00113 
00114             ///\}
00115 
00116             /**
00117              * Parse the contents file for a given ID, using the provided callbacks.
00118              */
00119             void parse_contents(const PackageID &,
00120                     const std::tr1::function<void (const std::tr1::shared_ptr<const ContentsEntry> &)> & on_file,
00121                     const std::tr1::function<void (const std::tr1::shared_ptr<const ContentsEntry> &)> & on_dir,
00122                     const std::tr1::function<void (const std::tr1::shared_ptr<const ContentsEntry> &)> & on_sym
00123                     ) const;
00124 
00125             /**
00126              * Index a newly added QualifiedPackageName, using the provided data directory
00127              * name part.
00128              */
00129             void index(const QualifiedPackageName &, const std::string &) const;
00130 
00131             /**
00132              * Deindex a QualifiedPackageName that no longer has any versions installed.
00133              */
00134             void deindex(const QualifiedPackageName &) const;
00135     };
00136 }
00137 
00138 #endif

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