This file is indexed.

/usr/include/cupt/system/resolver.hpp is in libcupt4-dev 2.9.9.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
/**************************************************************************
*   Copyright (C) 2010 by Eugene V. Lyubimkin                             *
*                                                                         *
*   This program is free software; you can redistribute it and/or modify  *
*   it under the terms of the GNU General Public License                  *
*   (version 3 or above) as published by the Free Software Foundation.    *
*                                                                         *
*   This program is distributed in the hope that it will be useful,       *
*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
*   GNU General Public License for more details.                          *
*                                                                         *
*   You should have received a copy of the GNU GPL                        *
*   along with this program; if not, write to the                         *
*   Free Software Foundation, Inc.,                                       *
*   51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA               *
**************************************************************************/
#ifndef CUPT_COMMON_RESOLVER_SEEN
#define CUPT_COMMON_RESOLVER_SEEN

/// @file

#include <functional>

#include <cupt/common.hpp>
#include <cupt/cache/binaryversion.hpp>

namespace cupt {
namespace system {

using namespace cache;

/// dependency problems resolver
/**
 * This class provides the dependency problems resolver interface for system state
 * modifications.
 *
 * First, you call class methods to specify how would you want to modify the
 * system, and then you finally call @ref resolve to get a consistent package
 * set(s) for specified modifications.
 */
class CUPT_API Resolver
{
	Resolver(const Resolver&);
	Resolver& operator=(const Resolver&);
 public:
	/// base class for resolver decision reasons
	struct Reason
	{
	 protected:
		CUPT_LOCAL Reason() {};
	 public:
		virtual ~Reason() {}; // polymorphic
		virtual string toString() const = 0; ///< returns localized reason description
	};
	/// reason: asked by user
	/**
	 * This reason means that change was asked by "user" by calling @ref
	 * installVersion, @ref removeVersions etc. methods.
	 */
	struct UserReason: public Reason
	{
		virtual string toString() const;
	};
	/// reason: auto-removal
	/**
	 * This reason applies only to package removals. It means that resolver
	 * decided to remove the package since it's automatically installed and no
	 * manually installed packages or their dependencies depend on this package
	 * anymore.
	 */
	struct AutoRemovalReason: public Reason
	{
		virtual string toString() const;
	};
	/// reason: other version's dependency
	/**
	 * This reason means that a resolver decided to change a package state
	 * because of some dependency of another package version.
	 */
	struct RelationExpressionReason: public Reason
	{
		const BinaryVersion* version; ///< version that caused the change
		BinaryVersion::RelationTypes::Type dependencyType; ///< type of dependency that caused the change
		RelationExpression relationExpression; ///< relation expression which caused the change

		/// trivial constructor
		RelationExpressionReason(const BinaryVersion*,
				BinaryVersion::RelationTypes::Type, const RelationExpression&);
		virtual string toString() const;
	};
	/// reason: source-synchronized with a related binary package
	/**
	 * This reason means that synchronizing by source versions was enabled and
	 * this package was synchronized to the version of other binary package
	 * from the same source.
	 */
	struct SynchronizationReason: public Reason
	{
		const BinaryVersion* version; ///< version that caused the change
		string relatedPackageName; ///< name of related binary package

		/// trivial constructor
		SynchronizationReason(const BinaryVersion*, const string&);
		virtual string toString() const;
	};

	/// resolver's main solution item
	/**
	 * Represents a binary package in the suggested system.
	 */
	struct SuggestedPackage
	{
		const BinaryVersion* version; ///< package version
		bool automaticallyInstalledFlag;
		vector< shared_ptr< const Reason > > reasons; ///< list of resolver reasons if tracked
		vector< string > reasonPackageNames; ///< changes in these packages caused the change in this package
	};
	typedef map< string, SuggestedPackage > SuggestedPackages; ///< suggested set of packages
	/// the result of resolver's work
	struct Offer
	{
		SuggestedPackages suggestedPackages; ///< target system package set
		vector< shared_ptr< const Reason > > unresolvedProblems;
	};

	/// user callback answer variants
	struct UserAnswer
	{
		enum Type
		{
			Accept, ///< finish computations and return @c true
			Decline, ///< throw out the proposed solution and work on other ones
			Abandon ///< finish computations and return @c false
		};
	};

	/// callback function type
	typedef std::function< UserAnswer::Type (const Offer&) > CallbackType;

	struct RequestImportance
	{
		typedef uint32_t Value;

		static const Value Must;
		static const Value Try;
		static const Value Wish;

		RequestImportance(Value value)
			: p_value(value)
		{}
		operator Value() const
		{
			return p_value;
		}
     private:
		Value p_value;
	};

	Resolver() {};

	/**
	 * Requests installation of one of the specific version(s).  If more than
	 * one version is supplied, installing any of them will be enough to
	 * satisfy this request.
	 *
	 * @param annotation passed to @ref satisfyRelationExpression
	 * @param importance passed to @ref satisfyRelationExpression
	 */
	void installVersion(const vector< const BinaryVersion* >&,
			const string& annotation = string(), RequestImportance importance = RequestImportance::Must);
	/**
	 * Requests removal of all supplied versions.
	 *
	 * @param annotation passed to @ref satisfyRelationExpression
	 * @param importance passed to @ref satisfyRelationExpression
	 */
	void removeVersions(const vector< const BinaryVersion* >&,
			const string& annotation = string(), RequestImportance importance = RequestImportance::Must);
	/**
	 * Requests that specified relation expression is satisfied.
	 *
	 * @param invert if set to @c true, unsatisfies the expression rather than satisfy it
	 * @param annotation user-friendly description of request; if empty,
	 * standard one will be generated
	 * @param importance specifies is the request mandatory, and if not, what is the penalty:
	 * - Must: request is mandatory;
	 * - Try: request is optional, penalty is the value of 'cupt::resolver::score::unsatisfied-try' option;
	 * - Wish: request is optiona, penalty is the value of 'cupt::resolver::score::unsatisfied-wish' option;
	 * - any other value: request is optional, penalty is the value itself.
	 * @param asAutomatic if new packages are to be installed as a result of
	 * perfoming this request, their 'automaticallyInstalledFlag' will have the
	 * value of this parameter.
	 */
	virtual void satisfyRelationExpression(const RelationExpression&,
			bool invert = false, const string& annotation = string(), RequestImportance importance = RequestImportance::Must,
			bool asAutomatic = false) = 0;
	/**
	 * Requests an upgrade of all installed packages (to their preferred version).
	 */
	virtual void upgrade() = 0;
	/**
	 * Requests that if a solution will have the package @a packageName,
	 * its corresponding Offer::SuggestedPackage::automaticallyInstalledFlag
	 * will have the value of @a flagValue.
	 */
	virtual void setAutomaticallyInstalledFlag(const string& packageName, bool flagValue) = 0;

	/// perform a resolve computations
	/**
	 * Takes all requested data and tries to find the best valid set of
	 * packages which conforms to what was requested.
	 *
	 * @return @c true if the solution was found and accepted by user, @c false otherwise
	 */
	virtual bool resolve(CallbackType) = 0;

	/// destructor
	virtual ~Resolver() {};
};

}
}

#endif