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 
92  {
96 
100  virtual string toString() const;
101  };
103 
109  {
112 
114  SynchronizationReason(const BinaryVersion*, const string&);
115  virtual string toString() const;
116  };
117 
119 
123  {
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  {
144  Abandon
145  };
146  };
147 
149  typedef std::function< UserAnswer::Type (const Offer&) > CallbackType;
150 
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 
Type
Definition: resolver.hpp:140
map< string, SuggestedPackage > SuggestedPackages
Definition: resolver.hpp:129
reason: auto-removal
Definition: resolver.hpp:82
BinaryVersion::RelationTypes::Type dependencyType
type of dependency that caused the change
Definition: resolver.hpp:94
Definition: resolver.hpp:151
Definition: binarypackage.hpp:26
Type
type
Definition: binaryversion.hpp:37
finish computations and return true
Definition: resolver.hpp:142
std::function< UserAnswer::Type(const Offer &) > CallbackType
callback function type
Definition: resolver.hpp:149
reason: asked by user
Definition: resolver.hpp:61
reason: implicitly changed by resolver
Definition: resolver.hpp:71
vector< shared_ptr< const Reason > > reasons
list of resolver reasons if tracked
Definition: resolver.hpp:126
base class for resolver decision reasons
Definition: resolver.hpp:48
RelationExpression relationExpression
relation expression which caused the change
Definition: resolver.hpp:95
const BinaryVersion * version
package version
Definition: resolver.hpp:124
throw out the proposed solution and work on other ones
Definition: resolver.hpp:143
const BinaryVersion * version
version that caused the change
Definition: resolver.hpp:110
reason: other version&#39;s dependency
Definition: resolver.hpp:91
const BinaryVersion * version
version that caused the change
Definition: resolver.hpp:93
the result of resolver&#39;s work
Definition: resolver.hpp:131
binary version info
Definition: binaryversion.hpp:31
user callback answer variants
Definition: resolver.hpp:138
SuggestedPackages suggestedPackages
target system package set
Definition: resolver.hpp:133
dependency problems resolver
Definition: resolver.hpp:42
virtual ~Resolver()
destructor
Definition: resolver.hpp:229
group of alternative relations
Definition: relation.hpp:109
string relatedPackageName
name of related binary package
Definition: resolver.hpp:111
reason: source-synchronized with a related binary package
Definition: resolver.hpp:108
vector< string > reasonPackageNames
changes in these packages caused the change in this package
Definition: resolver.hpp:127
resolver&#39;s main solution item
Definition: resolver.hpp:122