1479ca816SIngo Weinhold/*
2479ca816SIngo Weinhold * Copyright 2013, Haiku, Inc. All Rights Reserved.
3479ca816SIngo Weinhold * Distributed under the terms of the MIT License.
4479ca816SIngo Weinhold */
5479ca816SIngo Weinhold#ifndef _PACKAGE__SOLVER_H_
6479ca816SIngo Weinhold#define _PACKAGE__SOLVER_H_
7479ca816SIngo Weinhold
8479ca816SIngo Weinhold
9fc57db48SIngo Weinhold#include <ObjectList.h>
10479ca816SIngo Weinhold#include <SupportDefs.h>
11479ca816SIngo Weinhold
12479ca816SIngo Weinhold
13479ca816SIngo Weinholdnamespace BPackageKit {
14479ca816SIngo Weinhold
15479ca816SIngo Weinhold
16fc57db48SIngo Weinholdclass BSolverPackage;
170d8ed3f2SIngo Weinholdclass BSolverPackageSpecifier;
18479ca816SIngo Weinholdclass BSolverPackageSpecifierList;
191a4d020dSIngo Weinholdclass BSolverProblem;
208e6c3631SIngo Weinholdclass BSolverProblemSolution;
21479ca816SIngo Weinholdclass BSolverRepository;
221a4d020dSIngo Weinholdclass BSolverResult;
23479ca816SIngo Weinhold
24479ca816SIngo Weinhold
25479ca816SIngo Weinholdclass BSolver {
26fc57db48SIngo Weinholdpublic:
27fc57db48SIngo Weinhold			// FindPackages() flags
28fc57db48SIngo Weinhold			enum {
29fc57db48SIngo Weinhold				B_FIND_CASE_INSENSITIVE		= 0x01,
30663e351cSIngo Weinhold				B_FIND_IN_NAME				= 0x02,
31663e351cSIngo Weinhold				B_FIND_IN_SUMMARY			= 0x04,
32663e351cSIngo Weinhold				B_FIND_IN_DESCRIPTION		= 0x08,
3375d15eb4SIngo Weinhold				B_FIND_IN_PROVIDES			= 0x10,
3475d15eb4SIngo Weinhold				B_FIND_INSTALLED_ONLY		= 0x20,
35af585d03SJérôme Duval				B_FIND_IN_REQUIRES			= 0x40,
36fc57db48SIngo Weinhold			};
37fc57db48SIngo Weinhold
3889cb0015SIngo Weinhold			// VerifyInstallation() flags
3989cb0015SIngo Weinhold			enum {
4089cb0015SIngo Weinhold				B_VERIFY_ALLOW_UNINSTALL	= 0x01,
4189cb0015SIngo Weinhold			};
4289cb0015SIngo Weinhold
43479ca816SIngo Weinholdpublic:
441a4d020dSIngo Weinhold	virtual						~BSolver();
451a4d020dSIngo Weinhold
461a4d020dSIngo Weinhold	static	status_t			Create(BSolver*& _solver);
47479ca816SIngo Weinhold
481a4d020dSIngo Weinhold	virtual	status_t			Init() = 0;
49479ca816SIngo Weinhold
5074b582a4SIngo Weinhold	virtual	void				SetDebugLevel(int32 level) = 0;
5174b582a4SIngo Weinhold
521a4d020dSIngo Weinhold	virtual	status_t			AddRepository(
531a4d020dSIngo Weinhold									BSolverRepository* repository) = 0;
54479ca816SIngo Weinhold
55fc57db48SIngo Weinhold	virtual	status_t			FindPackages(const char* searchString,
56fc57db48SIngo Weinhold									uint32 flags,
57fc57db48SIngo Weinhold									BObjectList<BSolverPackage>& _packages) = 0;
5875d15eb4SIngo Weinhold	virtual	status_t			FindPackages(
5975d15eb4SIngo Weinhold									const BSolverPackageSpecifierList& packages,
6075d15eb4SIngo Weinhold									uint32 flags,
6175d15eb4SIngo Weinhold									BObjectList<BSolverPackage>& _packages,
6275d15eb4SIngo Weinhold									const BSolverPackageSpecifier** _unmatched
6375d15eb4SIngo Weinhold										= NULL) = 0;
64fc57db48SIngo Weinhold
651a4d020dSIngo Weinhold	virtual	status_t			Install(
66de62d761SIngo Weinhold									const BSolverPackageSpecifierList& packages,
67de62d761SIngo Weinhold									const BSolverPackageSpecifier** _unmatched
68de62d761SIngo Weinhold										= NULL) = 0;
69de62d761SIngo Weinhold	virtual	status_t			Uninstall(
70de62d761SIngo Weinhold									const BSolverPackageSpecifierList& packages,
710d8ed3f2SIngo Weinhold									const BSolverPackageSpecifier** _unmatched
720d8ed3f2SIngo Weinhold										= NULL) = 0;
73212c636fSIngo Weinhold	virtual	status_t			Update(
74212c636fSIngo Weinhold									const BSolverPackageSpecifierList& packages,
75212c636fSIngo Weinhold									bool installNotYetInstalled,
76212c636fSIngo Weinhold									const BSolverPackageSpecifier** _unmatched
77212c636fSIngo Weinhold										= NULL) = 0;
786ef57ae2SIngo Weinhold	virtual	status_t			FullSync() = 0;
7989cb0015SIngo Weinhold	virtual	status_t			VerifyInstallation(uint32 flags = 0) = 0;
801a4d020dSIngo Weinhold
811a4d020dSIngo Weinhold			bool				HasProblems() const
821a4d020dSIngo Weinhold									{ return CountProblems() > 0; }
831a4d020dSIngo Weinhold	virtual	int32				CountProblems() const = 0;
841a4d020dSIngo Weinhold	virtual	BSolverProblem*		ProblemAt(int32 index) const = 0;
85479ca816SIngo Weinhold
868e6c3631SIngo Weinhold	virtual	status_t			SelectProblemSolution(
878e6c3631SIngo Weinhold									BSolverProblem* problem,
888e6c3631SIngo Weinhold									const BSolverProblemSolution* solution) = 0;
898e6c3631SIngo Weinhold	virtual	status_t			SolveAgain() = 0;
908e6c3631SIngo Weinhold
911a4d020dSIngo Weinhold	virtual	status_t			GetResult(BSolverResult& _result) = 0;
92479ca816SIngo Weinhold
931a4d020dSIngo Weinholdprotected:
941a4d020dSIngo Weinhold								BSolver();
95479ca816SIngo Weinhold};
96479ca816SIngo Weinhold
97479ca816SIngo Weinhold
981a4d020dSIngo Weinhold// function exported by the libsolv based add-on
991a4d020dSIngo Weinholdextern "C" BSolver* create_solver();
1001a4d020dSIngo Weinhold
1011a4d020dSIngo Weinhold
102479ca816SIngo Weinhold}	// namespace BPackageKit
103479ca816SIngo Weinhold
104479ca816SIngo Weinhold
105479ca816SIngo Weinhold#endif // _PACKAGE__SOLVER_H_