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 13 namespace BPackageKit { 14 15 16 class BSolverPackage; 17 class BSolverPackageSpecifier; 18 class BSolverPackageSpecifierList; 19 class BSolverProblem; 20 class BSolverProblemSolution; 21 class BSolverRepository; 22 class BSolverResult; 23 24 25 class BSolver { 26 public: 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 }; 36 37 // VerifyInstallation() flags 38 enum { 39 B_VERIFY_ALLOW_UNINSTALL = 0x01, 40 }; 41 42 public: 43 virtual ~BSolver(); 44 45 static status_t Create(BSolver*& _solver); 46 47 virtual status_t Init() = 0; 48 49 virtual void SetDebugLevel(int32 level) = 0; 50 51 virtual status_t AddRepository( 52 BSolverRepository* repository) = 0; 53 54 virtual status_t FindPackages(const char* searchString, 55 uint32 flags, 56 BObjectList<BSolverPackage>& _packages) = 0; 57 virtual status_t FindPackages( 58 const BSolverPackageSpecifierList& packages, 59 uint32 flags, 60 BObjectList<BSolverPackage>& _packages, 61 const BSolverPackageSpecifier** _unmatched 62 = NULL) = 0; 63 64 virtual status_t Install( 65 const BSolverPackageSpecifierList& packages, 66 const BSolverPackageSpecifier** _unmatched 67 = NULL) = 0; 68 virtual status_t Uninstall( 69 const BSolverPackageSpecifierList& packages, 70 const BSolverPackageSpecifier** _unmatched 71 = NULL) = 0; 72 virtual status_t Update( 73 const BSolverPackageSpecifierList& packages, 74 bool installNotYetInstalled, 75 const BSolverPackageSpecifier** _unmatched 76 = NULL) = 0; 77 virtual status_t FullSync() = 0; 78 virtual status_t VerifyInstallation(uint32 flags = 0) = 0; 79 80 bool HasProblems() const 81 { return CountProblems() > 0; } 82 virtual int32 CountProblems() const = 0; 83 virtual BSolverProblem* ProblemAt(int32 index) const = 0; 84 85 virtual status_t SelectProblemSolution( 86 BSolverProblem* problem, 87 const BSolverProblemSolution* solution) = 0; 88 virtual status_t SolveAgain() = 0; 89 90 virtual status_t GetResult(BSolverResult& _result) = 0; 91 92 protected: 93 BSolver(); 94 }; 95 96 97 // function exported by the libsolv based add-on 98 extern "C" BSolver* create_solver(); 99 100 101 } // namespace BPackageKit 102 103 104 #endif // _PACKAGE__SOLVER_H_ 105