#include <icy/pacm/packagemanager.h>Loads package manifests and coordinates install, update, and uninstall workflows.
| Return | Name | Description |
|---|---|---|
Signal< void(const http::Response &)> | RemotePackageResponse | Events. |
Signal< void(LocalPackage &)> | PackageUninstalled | Signals when a package is uninstalled. |
Signal< void(InstallTask &)> | InstallTaskCreated | Signals when an installation task is created, before it is started. |
Signal< void(const InstallTask &)> | InstallTaskComplete | Signals when a package installation tasks completes, either successfully or in error. |
Signal< void(const http::Response &)> RemotePackageResponseEvents.
Signals when the remote package list have been downloaded from the server.
Signal< void(LocalPackage &)> PackageUninstalledSignals when a package is uninstalled.
Signal< void(InstallTask &)> InstallTaskCreatedSignals when an installation task is created, before it is started.
Signal< void(const InstallTask &)> InstallTaskCompleteSignals when a package installation tasks completes, either successfully or in error.
| Return | Name | Description |
|---|---|---|
PackageManager | #### Parameters | |
PackageManager | Deleted constructor. | |
PackageManager | Deleted constructor. | |
void | initialize virtual | Initialization Methods. |
void | uninitialize virtual | Releases resources and cancels any in-progress tasks. |
bool | initialized virtual const | Returns true if initialize() has been called successfully. |
void | createDirectories virtual | Creates the package manager directory structure if it does not already exist. |
void | queryRemotePackages virtual | Queries the server for a list of available packages. |
void | loadLocalPackages virtual | Loads all local package manifests from file system. Clears all in memory package manifests. |
void | loadLocalPackages virtual | Loads all local package manifests residing the the given directory. This method may be called multiple times for different paths because it does not clear in memory package manifests. |
bool | saveLocalPackages virtual | Saves all local package manifests to the data directory. |
bool | saveLocalPackage virtual | Saves the local package manifest to the file system. |
void | parseRemotePackages virtual | Parse the remote packages from the given JSON data string. |
InstallTask::Ptr | installPackage virtual | Package Installation Methods. |
bool | installPackages virtual | Installs multiple packages. The same options will be passed to each task. If a InstallMonitor instance was passed in the tasks will need to be started, otherwise they will be auto-started. The PackageManager does not take ownership of the InstallMonitor. |
InstallTask::Ptr | updatePackage virtual | Updates a single package. Throws an exception if the package does not exist. The returned InstallTask must be started. |
bool | updatePackages virtual | Updates multiple packages. Throws an exception if the package does not exist. If a InstallMonitor instance was passed in the tasks will need to be started, otherwise they will be auto-started. The PackageManager does not take ownership of the InstallMonitor. |
bool | updateAllPackages virtual | Updates all installed packages. |
bool | uninstallPackages virtual | Uninstalls multiple packages. |
bool | uninstallPackage virtual | Uninstalls a single package. |
bool | hasUnfinalizedPackages virtual | Returns true if there are updates available that have not yet been finalized. Packages may be unfinalized if there were files in use at the time of installation. |
bool | finalizeInstallations virtual | Finalizes active installations by moving all package files to their target destination. If files are to be overwritten they must not be in use or finalization will fail. |
InstallTask::Ptr | getInstallTask virtual const | Task Helper Methods. |
InstallTaskPtrVec | tasks virtual const | Returns a list of all tasks. |
void | cancelAllTasks virtual | Aborts all package installation tasks. All tasks must be aborted before clearing local or remote manifests. |
PackagePairVec | getPackagePairs virtual const | Package Helper Methods. |
PackagePairVec | getUpdatablePackagePairs virtual const | Returns a list of package pairs which may be updated. All pairs will have both local and remote package pointers, and the remote version will be newer than the local version. |
PackagePair | getPackagePair virtual const | Returns a local and remote package pair. An exception will be thrown if either the local or remote packages aren't available or are invalid. |
PackagePair | getOrCreatePackagePair virtual | Returns a local and remote package pair. If the local package doesn't exist it will be created from the remote package. If the remote package doesn't exist a NotFoundException will be thrown. |
InstallTask::Ptr | createInstallTask virtual | Creates a package installation task for the given pair. |
std::string | installedPackageVersion virtual const | Returns the version number of an installed package. Exceptions will be thrown if the package does not exist, or is not fully installed. |
Package::Asset | getLatestInstallableAsset virtual const | Returns the best asset to install, or throws a descriptive exception if no updates are available, or if the package is already up-to-date. This method takes version and SDK locks into consideration. |
bool | hasAvailableUpdates virtual const | Returns true if there are updates available for this package, false otherwise. |
void | clearCache | File Helper Methods. |
bool | clearPackageCache | Clears a package archive from the local cache. |
bool | clearCacheFile | Clears a file from the local cache. |
bool | hasCachedFile | Checks if a package archive exists in the local cache. |
bool | isSupportedFileType | Checks if the file type is a supported package archive. |
std::string | getCacheFilePath | Returns the full path of the cached file if it exists, or an empty path if the file doesn't exist. |
std::string | getPackageDataDir | Returns the package data directory for the given package ID. |
Options & | mutableOptions virtual | Accessors. |
const Options & | options virtual const | Returns a read-only view of the current options. |
RemotePackageStore & | remotePackages virtual | Returns a reference to the in-memory remote package store. |
LocalPackageStore & | localPackages virtual | Returns a reference to the in-memory local package store. |
PackageManager(const Options & options)options Configuration for directories, endpoints, and credentials.PackageManager(const PackageManager &) = deleteDeleted constructor.
PackageManager(PackageManager &&) = deleteDeleted constructor.
virtual
virtual void initialize()Initialization Methods.
Initializes the package manager: creates directories, loads local manifests, and queries the remote package index.
virtual
virtual void uninitialize()Releases resources and cancels any in-progress tasks.
virtual const
virtual bool initialized() constReturns true if initialize() has been called successfully.
virtual
virtual void createDirectories()Creates the package manager directory structure if it does not already exist.
virtual
virtual void queryRemotePackages()Queries the server for a list of available packages.
virtual
virtual void loadLocalPackages()Loads all local package manifests from file system. Clears all in memory package manifests.
virtual
virtual void loadLocalPackages(const std::string & dir)Loads all local package manifests residing the the given directory. This method may be called multiple times for different paths because it does not clear in memory package manifests.
virtual
virtual bool saveLocalPackages(bool whiny)Saves all local package manifests to the data directory.
whiny If true, re-throws on write error; otherwise returns false.true on success.
virtual
virtual bool saveLocalPackage(LocalPackage & package, bool whiny)Saves the local package manifest to the file system.
virtual
virtual void parseRemotePackages(const std::string & data)Parse the remote packages from the given JSON data string.
virtual
virtual InstallTask::Ptr installPackage(const std::string & name, const InstallOptions & options)Package Installation Methods.
Installs a single package. The returned InstallTask must be started. If the package is already up-to-date, a nullptr will be returned. Any other error will throw a std::runtime_error.
virtual
virtual bool installPackages(const StringVec & ids, const InstallOptions & options, InstallMonitor * monitor, bool whiny)Installs multiple packages. The same options will be passed to each task. If a InstallMonitor instance was passed in the tasks will need to be started, otherwise they will be auto-started. The PackageManager does not take ownership of the InstallMonitor.
virtual
virtual InstallTask::Ptr updatePackage(const std::string & name, const InstallOptions & options)Updates a single package. Throws an exception if the package does not exist. The returned InstallTask must be started.
virtual
virtual bool updatePackages(const StringVec & ids, const InstallOptions & options, InstallMonitor * monitor, bool whiny)Updates multiple packages. Throws an exception if the package does not exist. If a InstallMonitor instance was passed in the tasks will need to be started, otherwise they will be auto-started. The PackageManager does not take ownership of the InstallMonitor.
virtual
virtual bool updateAllPackages(bool whiny)Updates all installed packages.
virtual
virtual bool uninstallPackages(const StringVec & ids, bool whiny)Uninstalls multiple packages.
virtual
virtual bool uninstallPackage(const std::string & id, bool whiny)Uninstalls a single package.
virtual
virtual bool hasUnfinalizedPackages()Returns true if there are updates available that have not yet been finalized. Packages may be unfinalized if there were files in use at the time of installation.
virtual
virtual bool finalizeInstallations(bool whiny)Finalizes active installations by moving all package files to their target destination. If files are to be overwritten they must not be in use or finalization will fail.
virtual const
virtual InstallTask::Ptr getInstallTask(const std::string & id) constTask Helper Methods.
Gets the install task for the given package ID.
virtual const
virtual InstallTaskPtrVec tasks() constReturns a list of all tasks.
virtual
virtual void cancelAllTasks()Aborts all package installation tasks. All tasks must be aborted before clearing local or remote manifests.
virtual const
virtual PackagePairVec getPackagePairs() constPackage Helper Methods.
Returns all package pairs, valid or invalid. Some pairs may not have both local and remote package pointers.
virtual const
virtual PackagePairVec getUpdatablePackagePairs() constReturns a list of package pairs which may be updated. All pairs will have both local and remote package pointers, and the remote version will be newer than the local version.
virtual const
virtual PackagePair getPackagePair(const std::string & id, bool whiny) constReturns a local and remote package pair. An exception will be thrown if either the local or remote packages aren't available or are invalid.
virtual
virtual PackagePair getOrCreatePackagePair(const std::string & id)Returns a local and remote package pair. If the local package doesn't exist it will be created from the remote package. If the remote package doesn't exist a NotFoundException will be thrown.
virtual
virtual InstallTask::Ptr createInstallTask(PackagePair & pair, const InstallOptions & options)Creates a package installation task for the given pair.
virtual const
virtual std::string installedPackageVersion(const std::string & id) constReturns the version number of an installed package. Exceptions will be thrown if the package does not exist, or is not fully installed.
virtual const
virtual Package::Asset getLatestInstallableAsset(const PackagePair & pair, const InstallOptions & options) constReturns the best asset to install, or throws a descriptive exception if no updates are available, or if the package is already up-to-date. This method takes version and SDK locks into consideration.
virtual const
virtual bool hasAvailableUpdates(const PackagePair & pair) constReturns true if there are updates available for this package, false otherwise.
void clearCache()File Helper Methods.
Clears all files in the cache directory.
bool clearPackageCache(LocalPackage & package)Clears a package archive from the local cache.
bool clearCacheFile(std::string_view fileName, bool whiny)Clears a file from the local cache.
bool hasCachedFile(Package::Asset & asset)Checks if a package archive exists in the local cache.
bool isSupportedFileType(std::string_view fileName)Checks if the file type is a supported package archive.
std::string getCacheFilePath(std::string_view fileName)Returns the full path of the cached file if it exists, or an empty path if the file doesn't exist.
std::string getPackageDataDir(std::string_view id)Returns the package data directory for the given package ID.
virtual
virtual Options & mutableOptions()Accessors.
Returns the mutable startup configuration for this manager. Callers should finish edits before initialize().
virtual const
virtual const Options & options() constReturns a read-only view of the current options.
virtual
virtual RemotePackageStore & remotePackages()Returns a reference to the in-memory remote package store.
virtual
virtual LocalPackageStore & localPackages()Returns a reference to the in-memory local package store.
| Return | Name | Description |
|---|---|---|
std::mutex | _mutex | |
LocalPackageStore | _localPackages | |
RemotePackageStore | _remotePackages | |
InstallTaskPtrVec | _tasks | |
Options | _options |
std::mutex _mutexLocalPackageStore _localPackagesRemotePackageStore _remotePackagesInstallTaskPtrVec _tasksOptions _options| Return | Name | Description |
|---|---|---|
void | onPackageInstallComplete | Callbacks. |
void onPackageInstallComplete(InstallTask & task)Callbacks.