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  {
83  shared_ptr< const BinaryVersion > version;
86 
88  RelationExpressionReason(const shared_ptr< const BinaryVersion >&,
90  virtual string toString() const;
91  };
93 
99  {
100  shared_ptr< const BinaryVersion > version;
102 
104  SynchronizationReason(const shared_ptr< const BinaryVersion >&, const string&);
105  virtual string toString() const;
106  };
107 
109 
113  {
114  shared_ptr< const BinaryVersion > version;
115  // TODO/API break/: change the field to 'automaticallyInstalledFlag'
117  vector< shared_ptr< const Reason > > reasons;
118  };
119  typedef map< string, SuggestedPackage > SuggestedPackages;
120 
121  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 
141  Resolver() {};
142 
146  virtual void installVersion(const shared_ptr< const BinaryVersion >&) = 0;
150  virtual void satisfyRelationExpression(const RelationExpression&) = 0;
154  virtual void unsatisfyRelationExpression(const RelationExpression&) = 0;
160  virtual void removePackage(const string& packageName) = 0;
164  virtual void upgrade() = 0;
165 
167 
173  virtual bool resolve(CallbackType) = 0;
174 
176  virtual ~Resolver() {};
177 };
178 
179 }
180 }
181 
182 #endif
183