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() {}; // polymorphic
54  virtual string toString() const = 0;
55  };
57 
61  struct UserReason: public Reason
62  {
63  virtual string toString() const;
64  };
66 
72  struct AutoRemovalReason: public Reason
73  {
74  virtual string toString() const;
75  };
77 
82  {
86 
90  virtual string toString() const;
91  };
93 
99  {
102 
104  SynchronizationReason(const BinaryVersion*, const string&);
105  virtual string toString() const;
106  };
107 
109 
113  {
115  bool automaticallyInstalledFlag;
116  vector< shared_ptr< const Reason > > reasons;
117  vector< string > reasonPackageNames;
118  };
119  typedef map< string, SuggestedPackage > SuggestedPackages;
120  struct Offer
122  {
124  vector< shared_ptr< const Reason > > unresolvedProblems;
125  };
126 
128  struct UserAnswer
129  {
130  enum Type
131  {
134  Abandon
135  };
136  };
137 
139  typedef std::function< UserAnswer::Type (const Offer&) > CallbackType;
140 
142  {
143  typedef uint32_t Value;
144 
145  static const Value Must;
146  static const Value Try;
147  static const Value Wish;
148 
149  RequestImportance(Value value)
150  : p_value(value)
151  {}
152  operator Value() const
153  {
154  return p_value;
155  }
156  private:
157  Value p_value;
158  };
159 
160  Resolver() {};
161 
170  void installVersion(const vector< const BinaryVersion* >&,
171  const string& annotation = string(), RequestImportance importance = RequestImportance::Must);
178  void removeVersions(const vector< const BinaryVersion* >&,
179  const string& annotation = string(), RequestImportance importance = RequestImportance::Must);
195  virtual void satisfyRelationExpression(const RelationExpression&,
196  bool invert = false, const string& annotation = string(), RequestImportance importance = RequestImportance::Must,
197  bool asAutomatic = false) = 0;
201  virtual void upgrade() = 0;
207  virtual void setAutomaticallyInstalledFlag(const string& packageName, bool flagValue) = 0;
208 
210 
216  virtual bool resolve(CallbackType) = 0;
217 
219  virtual ~Resolver() {};
220 };
221 
222 }
223 }
224 
225 #endif
226 
Type
Definition: resolver.hpp:130
map< string, SuggestedPackage > SuggestedPackages
Definition: resolver.hpp:119
reason: auto-removal
Definition: resolver.hpp:72
BinaryVersion::RelationTypes::Type dependencyType
type of dependency that caused the change
Definition: resolver.hpp:84
Definition: resolver.hpp:141
Type
type
Definition: binaryversion.hpp:37
finish computations and return true
Definition: resolver.hpp:132
std::function< UserAnswer::Type(const Offer &) > CallbackType
callback function type
Definition: resolver.hpp:139
reason: asked by user
Definition: resolver.hpp:61
vector< shared_ptr< const Reason > > reasons
list of resolver reasons if tracked
Definition: resolver.hpp:116
base class for resolver decision reasons
Definition: resolver.hpp:48
RelationExpression relationExpression
relation expression which caused the change
Definition: resolver.hpp:85
const BinaryVersion * version
package version
Definition: resolver.hpp:114
throw out the proposed solution and work on other ones
Definition: resolver.hpp:133
const BinaryVersion * version
version that caused the change
Definition: resolver.hpp:100
reason: other version&#39;s dependency
Definition: resolver.hpp:81
const BinaryVersion * version
version that caused the change
Definition: resolver.hpp:83
the result of resolver&#39;s work
Definition: resolver.hpp:121
binary version info
Definition: binaryversion.hpp:31
user callback answer variants
Definition: resolver.hpp:128
SuggestedPackages suggestedPackages
target system package set
Definition: resolver.hpp:123
dependency problems resolver
Definition: resolver.hpp:42
virtual ~Resolver()
destructor
Definition: resolver.hpp:219
group of alternative relations
Definition: relation.hpp:102
string relatedPackageName
name of related binary package
Definition: resolver.hpp:101
reason: source-synchronized with a related binary package
Definition: resolver.hpp:98
vector< string > reasonPackageNames
changes in these packages caused the change in this package
Definition: resolver.hpp:117
resolver&#39;s main solution item
Definition: resolver.hpp:112