|
Cupt
|
00001 /************************************************************************** 00002 * Copyright (C) 2010 by Eugene V. Lyubimkin * 00003 * * 00004 * This program is free software; you can redistribute it and/or modify * 00005 * it under the terms of the GNU General Public License * 00006 * (version 3 or above) as published by the Free Software Foundation. * 00007 * * 00008 * This program is distributed in the hope that it will be useful, * 00009 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00011 * GNU General Public License for more details. * 00012 * * 00013 * You should have received a copy of the GNU GPL * 00014 * along with this program; if not, write to the * 00015 * Free Software Foundation, Inc., * 00016 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * 00017 **************************************************************************/ 00018 #ifndef CUPT_COMMON_RESOLVER_SEEN 00019 #define CUPT_COMMON_RESOLVER_SEEN 00020 00022 00023 #include <functional> 00024 00025 #include <cupt/common.hpp> 00026 #include <cupt/cache/binaryversion.hpp> 00027 00028 namespace cupt { 00029 namespace system { 00030 00031 using namespace cache; 00032 00034 00042 class CUPT_API Resolver 00043 { 00044 Resolver(const Resolver&); 00045 Resolver& operator=(const Resolver&); 00046 public: 00048 struct Reason 00049 { 00050 protected: 00051 CUPT_LOCAL Reason() {}; 00052 public: 00053 virtual ~Reason() {}; // polymorphic 00054 virtual string toString() const = 0; 00055 }; 00057 00061 struct UserReason: public Reason 00062 { 00063 virtual string toString() const; 00064 }; 00066 00072 struct AutoRemovalReason: public Reason 00073 { 00074 virtual string toString() const; 00075 }; 00077 00081 struct RelationExpressionReason: public Reason 00082 { 00083 shared_ptr< const BinaryVersion > version; 00084 BinaryVersion::RelationTypes::Type dependencyType; 00085 RelationExpression relationExpression; 00086 00088 RelationExpressionReason(const shared_ptr< const BinaryVersion >&, 00089 BinaryVersion::RelationTypes::Type, const RelationExpression&); 00090 virtual string toString() const; 00091 }; 00093 00098 struct SynchronizationReason: public Reason 00099 { 00100 shared_ptr< const BinaryVersion > version; 00101 string relatedPackageName; 00102 00104 SynchronizationReason(const shared_ptr< const BinaryVersion >&, const string&); 00105 virtual string toString() const; 00106 }; 00107 00109 00112 struct SuggestedPackage 00113 { 00114 shared_ptr< const BinaryVersion > version; 00115 bool manuallySelected; 00116 vector< shared_ptr< const Reason > > reasons; 00117 }; 00118 typedef map< string, SuggestedPackage > SuggestedPackages; 00119 00120 struct Offer 00121 { 00122 SuggestedPackages suggestedPackages; 00123 vector< shared_ptr< const Reason > > unresolvedProblems; 00124 }; 00125 00127 struct UserAnswer 00128 { 00129 enum Type 00130 { 00131 Accept, 00132 Decline, 00133 Abandon 00134 }; 00135 }; 00136 00138 typedef std::function< UserAnswer::Type (const Offer&) > CallbackType; 00139 00140 Resolver() {}; 00141 00145 virtual void installVersion(const shared_ptr< const BinaryVersion >&) = 0; 00149 virtual void satisfyRelationExpression(const RelationExpression&) = 0; 00153 virtual void unsatisfyRelationExpression(const RelationExpression&) = 0; 00159 virtual void removePackage(const string& packageName) = 0; 00163 virtual void upgrade() = 0; 00164 00166 00172 virtual bool resolve(CallbackType) = 0; 00173 00175 virtual ~Resolver() {}; 00176 }; 00177 00178 } 00179 } 00180 00181 #endif 00182
1.7.4