1/*
2 * Copyright 2013, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _PACKAGE__SOLVER_H_
6#define _PACKAGE__SOLVER_H_
7
8
9#include <ObjectList.h>
10#include <SupportDefs.h>
11
12
13namespace BPackageKit {
14
15
16class BSolverPackage;
17class BSolverPackageSpecifier;
18class BSolverPackageSpecifierList;
19class BSolverProblem;
20class BSolverProblemSolution;
21class BSolverRepository;
22class BSolverResult;
23
24
25class BSolver {
26public:
27			// FindPackages() flags
28			enum {
29				B_FIND_CASE_INSENSITIVE		= 0x01,
30				B_FIND_IN_NAME				= 0x02,
31				B_FIND_IN_SUMMARY			= 0x04,
32				B_FIND_IN_DESCRIPTION		= 0x08,
33				B_FIND_IN_PROVIDES			= 0x10,
34				B_FIND_INSTALLED_ONLY		= 0x20,
35				B_FIND_IN_REQUIRES			= 0x40,
36			};
37
38			// VerifyInstallation() flags
39			enum {
40				B_VERIFY_ALLOW_UNINSTALL	= 0x01,
41			};
42
43public:
44	virtual						~BSolver();
45
46	static	status_t			Create(BSolver*& _solver);
47
48	virtual	status_t			Init() = 0;
49
50	virtual	void				SetDebugLevel(int32 level) = 0;
51
52	virtual	status_t			AddRepository(
53									BSolverRepository* repository) = 0;
54
55	virtual	status_t			FindPackages(const char* searchString,
56									uint32 flags,
57									BObjectList<BSolverPackage>& _packages) = 0;
58	virtual	status_t			FindPackages(
59									const BSolverPackageSpecifierList& packages,
60									uint32 flags,
61									BObjectList<BSolverPackage>& _packages,
62									const BSolverPackageSpecifier** _unmatched
63										= NULL) = 0;
64
65	virtual	status_t			Install(
66									const BSolverPackageSpecifierList& packages,
67									const BSolverPackageSpecifier** _unmatched
68										= NULL) = 0;
69	virtual	status_t			Uninstall(
70									const BSolverPackageSpecifierList& packages,
71									const BSolverPackageSpecifier** _unmatched
72										= NULL) = 0;
73	virtual	status_t			Update(
74									const BSolverPackageSpecifierList& packages,
75									bool installNotYetInstalled,
76									const BSolverPackageSpecifier** _unmatched
77										= NULL) = 0;
78	virtual	status_t			FullSync() = 0;
79	virtual	status_t			VerifyInstallation(uint32 flags = 0) = 0;
80
81			bool				HasProblems() const
82									{ return CountProblems() > 0; }
83	virtual	int32				CountProblems() const = 0;
84	virtual	BSolverProblem*		ProblemAt(int32 index) const = 0;
85
86	virtual	status_t			SelectProblemSolution(
87									BSolverProblem* problem,
88									const BSolverProblemSolution* solution) = 0;
89	virtual	status_t			SolveAgain() = 0;
90
91	virtual	status_t			GetResult(BSolverResult& _result) = 0;
92
93protected:
94								BSolver();
95};
96
97
98// function exported by the libsolv based add-on
99extern "C" BSolver* create_solver();
100
101
102}	// namespace BPackageKit
103
104
105#endif // _PACKAGE__SOLVER_H_
106