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
28namespace cupt {
29namespace system {
30
31using namespace cache;
32
34
42class 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
83 {
84 virtual string toString() const;
85 };
87
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;
131 struct Offer
132 {
134 vector< shared_ptr< const Reason > > unresolvedProblems;
135 };
136
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);
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
dependency problems resolver
Definition resolver.hpp:43
virtual ~Resolver()
destructor
Definition resolver.hpp:229
virtual void upgrade()=0
std::function< UserAnswer::Type(const Offer &) > CallbackType
callback function type
Definition resolver.hpp:149
void installVersion(const vector< const BinaryVersion * > &, const string &annotation=string(), RequestImportance importance=RequestImportance::Must)
map< string, SuggestedPackage > SuggestedPackages
Definition resolver.hpp:129
void removeVersions(const vector< const BinaryVersion * > &, const string &annotation=string(), RequestImportance importance=RequestImportance::Must)
virtual void setAutomaticallyInstalledFlag(const string &packageName, bool flagValue)=0
virtual void satisfyRelationExpression(const RelationExpression &, bool invert=false, const string &annotation=string(), RequestImportance importance=RequestImportance::Must, bool asAutomatic=false)=0
virtual bool resolve(CallbackType)=0
perform a resolve computations
Type
type
Definition binaryversion.hpp:37
binary version info
Definition binaryversion.hpp:32
group of alternative relations
Definition relation.hpp:110
reason: auto-removal
Definition resolver.hpp:83
virtual string toString() const
returns localized reason description
reason: implicitly changed by resolver
Definition resolver.hpp:72
virtual string toString() const override
returns localized reason description
the result of resolver's work
Definition resolver.hpp:132
SuggestedPackages suggestedPackages
target system package set
Definition resolver.hpp:133
base class for resolver decision reasons
Definition resolver.hpp:49
virtual string toString() const =0
returns localized reason description
reason: other version's dependency
Definition resolver.hpp:92
BinaryVersion::RelationTypes::Type dependencyType
type of dependency that caused the change
Definition resolver.hpp:94
RelationExpressionReason(const BinaryVersion *, BinaryVersion::RelationTypes::Type, const RelationExpression &)
trivial constructor
const BinaryVersion * version
version that caused the change
Definition resolver.hpp:93
RelationExpression relationExpression
relation expression which caused the change
Definition resolver.hpp:95
virtual string toString() const
returns localized reason description
resolver's main solution item
Definition resolver.hpp:123
const BinaryVersion * version
package version
Definition resolver.hpp:124
vector< string > reasonPackageNames
changes in these packages caused the change in this package
Definition resolver.hpp:127
vector< shared_ptr< const Reason > > reasons
list of resolver reasons if tracked
Definition resolver.hpp:126
reason: source-synchronized with a related binary package
Definition resolver.hpp:109
virtual string toString() const
returns localized reason description
string relatedPackageName
name of related binary package
Definition resolver.hpp:111
const BinaryVersion * version
version that caused the change
Definition resolver.hpp:110
SynchronizationReason(const BinaryVersion *, const string &)
trivial constructor
user callback answer variants
Definition resolver.hpp:139
Type
Definition resolver.hpp:141
@ Accept
finish computations and return true
Definition resolver.hpp:142
@ Decline
throw out the proposed solution and work on other ones
Definition resolver.hpp:143
reason: asked by user
Definition resolver.hpp:62
virtual string toString() const
returns localized reason description