paludis  Version 2.6.0
fake_repository_base.hh
Go to the documentation of this file.
1 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
2 
3 /*
4  * Copyright (c) 2005, 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_FAKE_REPOSITORY_BASE_HH
21 #define PALUDIS_GUARD_PALUDIS_FAKE_REPOSITORY_BASE_HH 1
22 
23 #include <paludis/repository.hh>
24 #include <paludis/action-fwd.hh>
25 #include <paludis/util/pimp.hh>
26 
27 /** \file
28  * Declarations for the FakeRepositoryBase class.
29  *
30  * \ingroup grpfakerepository
31  */
32 
33 namespace paludis
34 {
35  class FakePackageID;
36 
37  /**
38  * A FakeRepositoryBase is a Repository subclass whose subclasses are used for
39  * various test cases.
40  *
41  * \see FakeRepository
42  * \see FakeInstalledRepository
43  * \ingroup grpfakerepository
44  */
46  public Repository,
47  public std::enable_shared_from_this<FakeRepositoryBase>
48  {
49  private:
51 
52  protected:
53  /**
54  * Constructor.
55  */
56  FakeRepositoryBase(const Environment * const env, const RepositoryName & name,
57  const RepositoryCapabilities & caps);
58 
59  virtual void need_keys_added() const;
60 
61  public:
62  /**
63  * Destructor.
64  */
66 
67  /**
68  * Add a category.
69  */
70  void add_category(const CategoryNamePart &);
71 
72  /**
73  * Add a package, and a category if necessary.
74  */
75  void add_package(const QualifiedPackageName &);
76 
77  /**
78  * Add a version, and a package and category if necessary, and set some
79  * default values for its metadata, and return said metadata.
80  */
81  std::shared_ptr<FakePackageID> add_version(const QualifiedPackageName &, const VersionSpec &);
82 
83  /**
84  * Add a version, and a package and category if necessary, and set some
85  * default values for its metadata, and return said metadata (convenience
86  * overload taking strings).
87  */
88  std::shared_ptr<FakePackageID> add_version(const std::string & c, const std::string & p,
89  const std::string & v);
90 
91  virtual void invalidate();
92 
93  /**
94  * Fetch our associated environment.
95  */
96  const Environment * environment() const;
97 
98  /* Repository */
99 
100  virtual std::shared_ptr<const PackageIDSequence> package_ids(
101  const QualifiedPackageName &, const RepositoryContentMayExcludes &) const
102  PALUDIS_ATTRIBUTE((warn_unused_result));
103 
104  virtual std::shared_ptr<const QualifiedPackageNameSet> package_names(
105  const CategoryNamePart &, const RepositoryContentMayExcludes &) const
106  PALUDIS_ATTRIBUTE((warn_unused_result));
107 
108  virtual std::shared_ptr<const CategoryNamePartSet> category_names(const RepositoryContentMayExcludes &) const
109  PALUDIS_ATTRIBUTE((warn_unused_result));
110 
111  virtual bool has_package_named(const QualifiedPackageName &, const RepositoryContentMayExcludes &) const
112  PALUDIS_ATTRIBUTE((warn_unused_result));
113 
114  virtual bool has_category_named(const CategoryNamePart &, const RepositoryContentMayExcludes &) const
115  PALUDIS_ATTRIBUTE((warn_unused_result));
116 
117  virtual bool sync(const std::string &, const std::string &, const std::shared_ptr<OutputManager> &) const;
118 
119  ///\name Set methods
120  ///\{
121 
122  virtual void populate_sets() const;
123 
124  ///\}
125 
126  virtual HookResult perform_hook(const Hook & hook, const std::shared_ptr<OutputManager> &);
127  };
128 }
129 
130 
131 #endif
Definition: pimp.hh:51
Definition: about_metadata-fwd.hh:23
Definition: name.hh:110
Definition: version_spec.hh:107
Definition: hook.hh:61
Definition: environment.hh:200
Definition: repository.hh:93
Definition: hook.hh:74
Definition: wrapped_value-fwd.hh:29
Definition: options-fwd.hh:34
Definition: repository.hh:246
Definition: fake_repository_base.hh:45
#define PALUDIS_ATTRIBUTE(x)
Definition: attributes.hh:53
#define PALUDIS_VISIBLE
Definition: attributes.hh:59