paludis  Version 2.0.0
repository_name_cache.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, 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_REPOSITORY_NAME_CACHE_HH
21 #define PALUDIS_GUARD_PALUDIS_REPOSITORY_NAME_CACHE_HH 1
22 
23 #include <paludis/util/pimp.hh>
24 #include <paludis/util/fs_path-fwd.hh>
25 #include <paludis/name.hh>
26 #include <memory>
27 
28 /** \file
29  * Declarations for RepositoryNameCache, which is used by some Repository
30  * subclasses to implement a names class.
31  *
32  * \ingroup g_repository
33  *
34  * \section Examples
35  *
36  * - None at this time.
37  */
38 
39 namespace paludis
40 {
41  class Repository;
42 
43  /**
44  * Used by various Repository subclasses to implement a names cache.
45  *
46  * \see Repository
47  * \ingroup g_repository
48  * \nosubgrouping
49  */
51  {
52  private:
54 
55  public:
56  ///\name Basic operations
57  ///\{
58 
60  const FSPath & location,
61  const Repository * const repo);
62 
63  virtual ~RepositoryNameCache();
64 
65 
66  ///\}
67 
68  ///\name Cache helper functions
69  ///\{
70 
71  /**
72  * Implement category_names_containing_package.
73  *
74  * May return a zero pointer, in which case the repository should
75  * fall back to Repository::do_category_names_containing_package or
76  * its own implementation.
77  */
78  std::shared_ptr<const CategoryNamePartSet> category_names_containing_package(
79  const PackageNamePart & p) const;
80 
81  /**
82  * Whether or not our cache is usable.
83  *
84  * Initially this will be true. After the first query the value may
85  * change to false (the query will return a zero pointer too).
86  */
87  bool usable() const PALUDIS_ATTRIBUTE((nothrow));
88 
89  /**
90  * Implement cache regeneration.
91  */
92  void regenerate_cache() const;
93 
94  /**
95  * Add a new package to the cache.
96  */
97  void add(const QualifiedPackageName &);
98 
99  /**
100  * Remove a package from the cache.
101  */
102  void remove(const QualifiedPackageName &);
103 
104  ///\}
105  };
106 }
107 
108 #endif
Definition: pimp.hh:51
Definition: repository_name_cache.hh:50
Definition: name.hh:110
Definition: fs_path.hh:33
Definition: repository.hh:246
#define PALUDIS_ATTRIBUTE(x)
Definition: attributes.hh:64
#define PALUDIS_VISIBLE
Definition: attributes.hh:71