1 /* 2 * Copyright 2013, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _PACKAGE__SOLVER_REPOSITORY_H_ 6 #define _PACKAGE__SOLVER_REPOSITORY_H_ 7 8 9 #include <ObjectList.h> 10 #include <package/PackageDefs.h> 11 #include <package/PackageInfoSet.h> 12 #include <String.h> 13 14 15 namespace BPackageKit { 16 17 18 class BPackageInfo; 19 class BRepositoryConfig; 20 class BSolverPackage; 21 22 23 class BSolverRepository { 24 public: 25 enum BAllInstallationLocations { 26 B_ALL_INSTALLATION_LOCATIONS 27 }; 28 29 typedef BPackageInfoSet::Iterator Iterator; 30 31 public: 32 BSolverRepository(); 33 BSolverRepository(const BString& name); 34 BSolverRepository( 35 BPackageInstallationLocation location); 36 BSolverRepository(BAllInstallationLocations); 37 BSolverRepository( 38 const BRepositoryConfig& config); 39 ~BSolverRepository(); 40 41 status_t SetTo(const BString& name); 42 status_t SetTo(BPackageInstallationLocation location); 43 status_t SetTo(BAllInstallationLocations); 44 status_t SetTo(const BRepositoryConfig& config); 45 void Unset(); 46 47 status_t InitCheck(); 48 49 bool IsInstalled() const; 50 void SetInstalled(bool isInstalled); 51 52 BString Name() const; 53 54 int32 Priority() const; 55 void SetPriority(int32 priority); 56 // negative priority is fine 57 58 bool IsEmpty() const; 59 int32 CountPackages() const; 60 BSolverPackage* PackageAt(int32 index) const; 61 62 status_t AddPackage(const BPackageInfo& info, 63 BSolverPackage** _package = NULL); 64 status_t AddPackages( 65 BPackageInstallationLocation location); 66 67 uint64 ChangeCount() const; 68 69 private: 70 typedef BObjectList<BSolverPackage> PackageList; 71 72 private: 73 BString fName; 74 int32 fPriority; 75 bool fIsInstalled; 76 PackageList fPackages; 77 uint64 fChangeCount; 78 }; 79 80 81 } // namespace BPackageKit 82 83 84 #endif // _PACKAGE__SOLVER_REPOSITORY_H_ 85