plugify  1.0.0.0
package_manager.hpp
1 #pragma once
2 
3 #include <filesystem>
4 #include <functional>
5 #include <optional>
6 #include <plugify_export.h>
7 
8 namespace plugify {
9  struct LocalPackage;
10  struct RemotePackage;
11 
16  using LocalPackageOpt = std::optional<LocalPackage>;
17 
22  using RemotePackageOpt = std::optional<RemotePackage>;
23 
29  public:
30  virtual ~IPackageManager() = default;
31 
36  virtual bool Initialize() = 0;
37 
41  virtual void Terminate() = 0;
42 
47  virtual bool IsInitialized() const = 0;
48 
53  virtual bool Reload() = 0;
54 
60  virtual void InstallPackage(std::string_view packageName, std::optional<int32_t> requiredVersion = {}) = 0;
61 
66  virtual void InstallPackages(std::span<const std::string> packageNames) = 0;
67 
73  virtual void InstallAllPackages(const std::filesystem::path& manifestFilePath, bool reinstall) = 0;
74 
80  virtual void InstallAllPackages(const std::string& manifestUrl, bool reinstall) = 0;
81 
87  virtual void UpdatePackage(std::string_view packageName, std::optional<int32_t> requiredVersion = {}) = 0;
88 
93  virtual void UpdatePackages(std::span<const std::string> packageNames) = 0;
94 
98  virtual void UpdateAllPackages() = 0;
99 
104  virtual void UninstallPackage(std::string_view packageName) = 0;
105 
110  virtual void UninstallPackages(std::span<const std::string> packageNames) = 0;
111 
115  virtual void UninstallAllPackages() = 0;
116 
122  virtual void SnapshotPackages(const std::filesystem::path& manifestFilePath, bool prettify) = 0;
123 
128  virtual bool HasMissedPackages() const = 0;
129 
134  virtual bool HasConflictedPackages() const = 0;
135 
139  virtual void InstallMissedPackages() = 0;
140 
144  virtual void UninstallConflictedPackages() = 0;
145 
151  virtual LocalPackageOpt FindLocalPackage(std::string_view packageName) const = 0;
152 
158  virtual RemotePackageOpt FindRemotePackage(std::string_view packageName) const = 0;
159 
164  virtual std::vector<LocalPackage> GetLocalPackages() const = 0;
165 
170  virtual std::vector<RemotePackage> GetRemotePackages() const = 0;
171  };
172 
173 } // namespace plugify
Interface for the package manager provided to the user, implemented in the core.
virtual void UpdateAllPackages()=0
Update all installed packages.
virtual void UninstallPackages(std::span< const std::string > packageNames)=0
Uninstall multiple packages.
virtual void UninstallConflictedPackages()=0
Uninstall conflicted packages.
virtual bool IsInitialized() const =0
Check if the package manager is initialized.
virtual void UpdatePackages(std::span< const std::string > packageNames)=0
Update multiple packages.
virtual bool HasMissedPackages() const =0
Check if there are missed packages (not installed but required by other packages).
virtual void Terminate()=0
Terminate the package manager.
virtual LocalPackageOpt FindLocalPackage(std::string_view packageName) const =0
Find a local package by name.
virtual std::vector< LocalPackage > GetLocalPackages() const =0
Get a vector of all local packages.
virtual void UninstallPackage(std::string_view packageName)=0
Uninstall a specific package.
virtual void InstallMissedPackages()=0
Install missed packages.
virtual bool Initialize()=0
Initialize the package manager.
virtual void InstallAllPackages(const std::filesystem::path &manifestFilePath, bool reinstall)=0
Install all packages listed in a manifest file.
virtual bool Reload()=0
Reload the package manager.
virtual void UninstallAllPackages()=0
Uninstall all installed packages.
virtual void InstallPackages(std::span< const std::string > packageNames)=0
Install multiple packages.
virtual bool HasConflictedPackages() const =0
Check if there are conflicted packages (installed with conflicting versions).
virtual void InstallAllPackages(const std::string &manifestUrl, bool reinstall)=0
Install all packages listed in a manifest file from a remote location.
virtual void InstallPackage(std::string_view packageName, std::optional< int32_t > requiredVersion={})=0
Install a package.
virtual void SnapshotPackages(const std::filesystem::path &manifestFilePath, bool prettify)=0
Snapshot the list of installed packages to a manifest file.
virtual void UpdatePackage(std::string_view packageName, std::optional< int32_t > requiredVersion={})=0
Update a specific package.
virtual std::vector< RemotePackage > GetRemotePackages() const =0
Get a vector of all remote packages.
virtual RemotePackageOpt FindRemotePackage(std::string_view packageName) const =0
Find a remote package by name.