Cupt
resolver.hpp
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright (C) 2010 by Eugene V. Lyubimkin *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License *
6 * (version 3 or above) as published by the Free Software Foundation. *
7 * *
8 * This program is distributed in the hope that it will be useful, *
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
11 * GNU General Public License for more details. *
12 * *
13 * You should have received a copy of the GNU GPL *
14 * along with this program; if not, write to the *
15 * Free Software Foundation, Inc., *
16 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA *
17 **************************************************************************/
18 #ifndef CUPT_COMMON_RESOLVER_SEEN
19 #define CUPT_COMMON_RESOLVER_SEEN
20 
22 
23 #include <functional>
24 
25 #include <cupt/common.hpp>
27 
28 namespace cupt {
29 namespace system {
30 
31 using namespace cache;
32 
34 
42 class CUPT_API Resolver
43 {
44  Resolver(const Resolver&);
45  Resolver& operator=(const Resolver&);
46  public:
48  struct Reason
49  {
50  protected:
51  CUPT_LOCAL Reason() {};
52  public:
53  virtual ~Reason() {};
54  virtual string toString() const = 0;
55  };
57 
61  struct UserReason: public Reason
62  {
63  virtual string toString() const;
64  };
66 
71  struct ImplicitReason: public Reason
72  {
73  virtual string toString() const override;
74  };
76 
82  struct AutoRemovalReason: public Reason
83  {
84  virtual string toString() const;
85  };
87 
91  struct RelationExpressionReason: public Reason
92  {
93  const BinaryVersion* version;
95  RelationExpression relationExpression;
96 
100  virtual string toString() const;
101  };
103 
108  struct SynchronizationReason: public Reason
109  {
110  const BinaryVersion* version;
111  string relatedPackageName;
112 
114  SynchronizationReason(const BinaryVersion*, const string&);
115  virtual string toString() const;
116  };
117 
119 
122  struct SuggestedPackage
123  {
124  const BinaryVersion* version;
125  bool automaticallyInstalledFlag;
126  vector< shared_ptr< const Reason > > reasons;
127  vector< string > reasonPackageNames;
128  };
129  typedef map< string, SuggestedPackage > SuggestedPackages;
130  struct Offer
132  {
133  SuggestedPackages suggestedPackages;
134  vector< shared_ptr< const Reason > > unresolvedProblems;
135  };
136 
138  struct UserAnswer
139  {
140  enum Type
141  {
142  Accept,
143  Decline,
144  Abandon
145  };
146  };
147 
149  typedef std::function< UserAnswer::Type (const Offer&) > CallbackType;
150 
151  struct RequestImportance
152  {
153  typedef uint32_t Value;
154 
155  static const Value Must;
156  static const Value Try;
157  static const Value Wish;
158 
159  RequestImportance(Value value)
160  : p_value(value)
161  {}
162  operator Value() const
163  {
164  return p_value;
165  }
166  private:
167  Value p_value;
168  };
169 
170  Resolver() {};
171 
180  void installVersion(const vector< const BinaryVersion* >&,
181  const string& annotation = string(), RequestImportance importance = RequestImportance::Must);
188  void removeVersions(const vector< const BinaryVersion* >&,
189  const string& annotation = string(), RequestImportance importance = RequestImportance::Must);
205  virtual void satisfyRelationExpression(const RelationExpression&,
206  bool invert = false, const string& annotation = string(), RequestImportance importance = RequestImportance::Must,
207  bool asAutomatic = false) = 0;
211  virtual void upgrade() = 0;
217  virtual void setAutomaticallyInstalledFlag(const string& packageName, bool flagValue) = 0;
218 
220 
226  virtual bool resolve(CallbackType) = 0;
227 
229  virtual ~Resolver() {};
230 };
231 
232 }
233 }
234 
235 #endif
236 
cupt::system::Resolver::RequestImportance
Definition: resolver.hpp:150
binaryversion.hpp
common.hpp
cupt::system::Resolver::SuggestedPackages
map< string, SuggestedPackage > SuggestedPackages
Definition: resolver.hpp:128
cupt::system::Resolver
dependency problems resolver
Definition: resolver.hpp:41
cupt::system::Resolver::Reason
base class for resolver decision reasons
Definition: resolver.hpp:47
cupt::system::Resolver::SuggestedPackage
resolver's main solution item
Definition: resolver.hpp:121
cupt::system::Resolver::UserAnswer
user callback answer variants
Definition: resolver.hpp:137
cupt::system::Resolver::SynchronizationReason
reason: source-synchronized with a related binary package
Definition: resolver.hpp:107
cupt::cache::BinaryVersion
binary version info
Definition: binaryversion.hpp:30
cupt::system::Resolver::RelationExpressionReason
reason: other version's dependency
Definition: resolver.hpp:90
cupt::cache::BinaryVersion::RelationTypes::Type
Type
type
Definition: binaryversion.hpp:36
cupt::system::Resolver::UserAnswer::Type
Type
Definition: resolver.hpp:139
cupt::system::Resolver::Offer
the result of resolver's work
Definition: resolver.hpp:130
cupt::cache::RelationExpression
group of alternative relations
Definition: relation.hpp:108