Home
Pacm module

PackageManager

Loads package manifests and coordinates install, update, and uninstall workflows.

PackageManager

#include <icy/pacm/packagemanager.h>
class PackageManager

Defined in src/pacm/include/icy/pacm/packagemanager.h:62

Loads package manifests and coordinates install, update, and uninstall workflows.

List of all members

NameKindOwner
RemotePackageResponsevariableDeclared here
PackageUninstalledvariableDeclared here
InstallTaskCreatedvariableDeclared here
InstallTaskCompletevariableDeclared here
PackageManagerfunctionDeclared here
~PackageManagerfunctionDeclared here
PackageManagerfunctionDeclared here
operator=functionDeclared here
PackageManagerfunctionDeclared here
operator=functionDeclared here
initializefunctionDeclared here
uninitializefunctionDeclared here
initializedfunctionDeclared here
createDirectoriesfunctionDeclared here
queryRemotePackagesfunctionDeclared here
loadLocalPackagesfunctionDeclared here
loadLocalPackagesfunctionDeclared here
saveLocalPackagesfunctionDeclared here
saveLocalPackagefunctionDeclared here
parseRemotePackagesfunctionDeclared here
installPackagefunctionDeclared here
installPackagesfunctionDeclared here
updatePackagefunctionDeclared here
updatePackagesfunctionDeclared here
updateAllPackagesfunctionDeclared here
uninstallPackagesfunctionDeclared here
uninstallPackagefunctionDeclared here
hasUnfinalizedPackagesfunctionDeclared here
finalizeInstallationsfunctionDeclared here
getInstallTaskfunctionDeclared here
tasksfunctionDeclared here
cancelAllTasksfunctionDeclared here
getPackagePairsfunctionDeclared here
getUpdatablePackagePairsfunctionDeclared here
getPackagePairfunctionDeclared here
getOrCreatePackagePairfunctionDeclared here
createInstallTaskfunctionDeclared here
installedPackageVersionfunctionDeclared here
getLatestInstallableAssetfunctionDeclared here
hasAvailableUpdatesfunctionDeclared here
clearCachefunctionDeclared here
clearPackageCachefunctionDeclared here
clearCacheFilefunctionDeclared here
hasCachedFilefunctionDeclared here
isSupportedFileTypefunctionDeclared here
getCacheFilePathfunctionDeclared here
getPackageDataDirfunctionDeclared here
mutableOptionsfunctionDeclared here
optionsfunctionDeclared here
remotePackagesfunctionDeclared here
localPackagesfunctionDeclared here
_mutexvariableDeclared here
_localPackagesvariableDeclared here
_remotePackagesvariableDeclared here
_tasksvariableDeclared here
_optionsvariableDeclared here
onPackageInstallCompletefunctionDeclared here

Public Attributes

ReturnNameDescription
Signal< void(const http::Response &)>RemotePackageResponseEvents.
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.

RemotePackageResponse

Signal< void(const http::Response &)> RemotePackageResponse

Defined in src/pacm/include/icy/pacm/packagemanager.h:311

Events.

Signals when the remote package list have been downloaded from the server.


PackageUninstalled

Signal< void(LocalPackage &)> PackageUninstalled

Defined in src/pacm/include/icy/pacm/packagemanager.h:314

Signals when a package is uninstalled.


InstallTaskCreated

Signal< void(InstallTask &)> InstallTaskCreated

Defined in src/pacm/include/icy/pacm/packagemanager.h:318

Signals when an installation task is created, before it is started.


InstallTaskComplete

Signal< void(const InstallTask &)> InstallTaskComplete

Defined in src/pacm/include/icy/pacm/packagemanager.h:322

Signals when a package installation tasks completes, either successfully or in error.

Public Methods

ReturnNameDescription
PackageManager
PackageManagerDeleted constructor.
PackageManagerDeleted constructor.
voidinitialize virtualInitialization Methods.
voiduninitialize virtualReleases resources and cancels any in-progress tasks.
boolinitialized virtual constReturns true if initialize() has been called successfully.
voidcreateDirectories virtualCreates the package manager directory structure if it does not already exist.
voidqueryRemotePackages virtualQueries the server for a list of available packages.
voidloadLocalPackages virtualLoads all local package manifests from file system. Clears all in memory package manifests.
voidloadLocalPackages virtualLoads 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.
boolsaveLocalPackages virtualSaves all local package manifests to the data directory.
boolsaveLocalPackage virtualSaves the local package manifest to the file system.
voidparseRemotePackages virtualParse the remote packages from the given JSON data string.
InstallTask::PtrinstallPackage virtualPackage Installation Methods.
boolinstallPackages virtualInstalls 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::PtrupdatePackage virtualUpdates a single package. Throws an exception if the package does not exist. The returned InstallTask must be started.
boolupdatePackages virtualUpdates 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.
boolupdateAllPackages virtualUpdates all installed packages.
booluninstallPackages virtualUninstalls multiple packages.
booluninstallPackage virtualUninstalls a single package.
boolhasUnfinalizedPackages virtualReturns 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.
boolfinalizeInstallations virtualFinalizes 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::PtrgetInstallTask virtual constTask Helper Methods.
InstallTaskPtrVectasks virtual constReturns a list of all tasks.
voidcancelAllTasks virtualAborts all package installation tasks. All tasks must be aborted before clearing local or remote manifests.
PackagePairVecgetPackagePairs virtual constPackage Helper Methods.
PackagePairVecgetUpdatablePackagePairs virtual 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.
PackagePairgetPackagePair virtual 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.
PackagePairgetOrCreatePackagePair virtualReturns 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::PtrcreateInstallTask virtualCreates a package installation task for the given pair.
std::stringinstalledPackageVersion virtual constReturns the version number of an installed package. Exceptions will be thrown if the package does not exist, or is not fully installed.
Package::AssetgetLatestInstallableAsset virtual 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.
boolhasAvailableUpdates virtual constReturns true if there are updates available for this package, false otherwise.
voidclearCacheFile Helper Methods.
boolclearPackageCacheClears a package archive from the local cache.
boolclearCacheFileClears a file from the local cache.
boolhasCachedFileChecks if a package archive exists in the local cache.
boolisSupportedFileTypeChecks if the file type is a supported package archive.
std::stringgetCacheFilePathReturns the full path of the cached file if it exists, or an empty path if the file doesn't exist.
std::stringgetPackageDataDirReturns the package data directory for the given package ID.
Options &mutableOptions virtualAccessors.
const Options &options virtual constReturns a read-only view of the current options.
RemotePackageStore &remotePackages virtualReturns a reference to the in-memory remote package store.
LocalPackageStore &localPackages virtualReturns a reference to the in-memory local package store.

PackageManager

PackageManager(const Options & options = Options())

Defined in src/pacm/include/icy/pacm/packagemanager.h:99

Parameters

  • options Configuration for directories, endpoints, and credentials.

PackageManager

PackageManager(const PackageManager &) = delete

Defined in src/pacm/include/icy/pacm/packagemanager.h:102

Deleted constructor.


PackageManager

PackageManager(PackageManager &&) = delete

Defined in src/pacm/include/icy/pacm/packagemanager.h:104

Deleted constructor.


initialize

virtual

virtual void initialize()

Defined in src/pacm/include/icy/pacm/packagemanager.h:112

Initialization Methods.

Initializes the package manager: creates directories, loads local manifests, and queries the remote package index.


uninitialize

virtual

virtual void uninitialize()

Defined in src/pacm/include/icy/pacm/packagemanager.h:115

Releases resources and cancels any in-progress tasks.


initialized

virtual const

virtual bool initialized() const

Defined in src/pacm/include/icy/pacm/packagemanager.h:118

Returns true if initialize() has been called successfully.


createDirectories

virtual

virtual void createDirectories()

Defined in src/pacm/include/icy/pacm/packagemanager.h:122

Creates the package manager directory structure if it does not already exist.


queryRemotePackages

virtual

virtual void queryRemotePackages()

Defined in src/pacm/include/icy/pacm/packagemanager.h:125

Queries the server for a list of available packages.


loadLocalPackages

virtual

virtual void loadLocalPackages()

Defined in src/pacm/include/icy/pacm/packagemanager.h:129

Loads all local package manifests from file system. Clears all in memory package manifests.


loadLocalPackages

virtual

virtual void loadLocalPackages(const std::string & dir)

Defined in src/pacm/include/icy/pacm/packagemanager.h:135

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.


saveLocalPackages

virtual

virtual bool saveLocalPackages(bool whiny = false)

Defined in src/pacm/include/icy/pacm/packagemanager.h:140

Saves all local package manifests to the data directory.

Parameters

  • whiny If true, re-throws on write error; otherwise returns false.

Returns

true on success.


saveLocalPackage

virtual

virtual bool saveLocalPackage(LocalPackage & package, bool whiny = false)

Defined in src/pacm/include/icy/pacm/packagemanager.h:143

Saves the local package manifest to the file system.


parseRemotePackages

virtual

virtual void parseRemotePackages(const std::string & data)

Defined in src/pacm/include/icy/pacm/packagemanager.h:146

Parse the remote packages from the given JSON data string.


installPackage

virtual

virtual InstallTask::Ptr installPackage(const std::string & name, const InstallOptions & options = InstallOptions())

Defined in src/pacm/include/icy/pacm/packagemanager.h:156

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.


installPackages

virtual

virtual bool installPackages(const StringVec & ids, const InstallOptions & options = InstallOptions(), InstallMonitor * monitor = nullptr, bool whiny = false)

Defined in src/pacm/include/icy/pacm/packagemanager.h:165

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.


updatePackage

virtual

virtual InstallTask::Ptr updatePackage(const std::string & name, const InstallOptions & options = InstallOptions())

Defined in src/pacm/include/icy/pacm/packagemanager.h:173

Updates a single package. Throws an exception if the package does not exist. The returned InstallTask must be started.


updatePackages

virtual

virtual bool updatePackages(const StringVec & ids, const InstallOptions & options = InstallOptions(), InstallMonitor * monitor = nullptr, bool whiny = false)

Defined in src/pacm/include/icy/pacm/packagemanager.h:182

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.


updateAllPackages

virtual

virtual bool updateAllPackages(bool whiny = false)

Defined in src/pacm/include/icy/pacm/packagemanager.h:187

Updates all installed packages.


uninstallPackages

virtual

virtual bool uninstallPackages(const StringVec & ids, bool whiny = false)

Defined in src/pacm/include/icy/pacm/packagemanager.h:190

Uninstalls multiple packages.


uninstallPackage

virtual

virtual bool uninstallPackage(const std::string & id, bool whiny = false)

Defined in src/pacm/include/icy/pacm/packagemanager.h:193

Uninstalls a single package.


hasUnfinalizedPackages

virtual

virtual bool hasUnfinalizedPackages()

Defined in src/pacm/include/icy/pacm/packagemanager.h:198

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.


finalizeInstallations

virtual

virtual bool finalizeInstallations(bool whiny = false)

Defined in src/pacm/include/icy/pacm/packagemanager.h:204

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.


getInstallTask

virtual const

virtual InstallTask::Ptr getInstallTask(const std::string & id) const

Defined in src/pacm/include/icy/pacm/packagemanager.h:210

Task Helper Methods.

Gets the install task for the given package ID.


tasks

virtual const

virtual InstallTaskPtrVec tasks() const

Defined in src/pacm/include/icy/pacm/packagemanager.h:213

Returns a list of all tasks.


cancelAllTasks

virtual

virtual void cancelAllTasks()

Defined in src/pacm/include/icy/pacm/packagemanager.h:217

Aborts all package installation tasks. All tasks must be aborted before clearing local or remote manifests.


getPackagePairs

virtual const

virtual PackagePairVec getPackagePairs() const

Defined in src/pacm/include/icy/pacm/packagemanager.h:224

Package Helper Methods.

Returns all package pairs, valid or invalid. Some pairs may not have both local and remote package pointers.


getUpdatablePackagePairs

virtual const

virtual PackagePairVec getUpdatablePackagePairs() const

Defined in src/pacm/include/icy/pacm/packagemanager.h:229

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.


getPackagePair

virtual const

virtual PackagePair getPackagePair(const std::string & id, bool whiny = false) const

Defined in src/pacm/include/icy/pacm/packagemanager.h:234

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.


getOrCreatePackagePair

virtual

virtual PackagePair getOrCreatePackagePair(const std::string & id)

Defined in src/pacm/include/icy/pacm/packagemanager.h:242

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.


createInstallTask

virtual

virtual InstallTask::Ptr createInstallTask(PackagePair & pair, const InstallOptions & options = InstallOptions())

Defined in src/pacm/include/icy/pacm/packagemanager.h:245

Creates a package installation task for the given pair.


installedPackageVersion

virtual const

virtual std::string installedPackageVersion(const std::string & id) const

Defined in src/pacm/include/icy/pacm/packagemanager.h:251

Returns the version number of an installed package. Exceptions will be thrown if the package does not exist, or is not fully installed.


getLatestInstallableAsset

virtual const

virtual Package::Asset getLatestInstallableAsset(const PackagePair & pair, const InstallOptions & options = InstallOptions()) const

Defined in src/pacm/include/icy/pacm/packagemanager.h:256

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.


hasAvailableUpdates

virtual const

virtual bool hasAvailableUpdates(const PackagePair & pair) const

Defined in src/pacm/include/icy/pacm/packagemanager.h:262

Returns true if there are updates available for this package, false otherwise.


clearCache

void clearCache()

Defined in src/pacm/include/icy/pacm/packagemanager.h:268

File Helper Methods.

Clears all files in the cache directory.


clearPackageCache

bool clearPackageCache(LocalPackage & package)

Defined in src/pacm/include/icy/pacm/packagemanager.h:271

Clears a package archive from the local cache.


clearCacheFile

bool clearCacheFile(std::string_view fileName, bool whiny = false)

Defined in src/pacm/include/icy/pacm/packagemanager.h:274

Clears a file from the local cache.


hasCachedFile

bool hasCachedFile(Package::Asset & asset)

Defined in src/pacm/include/icy/pacm/packagemanager.h:277

Checks if a package archive exists in the local cache.


isSupportedFileType

bool isSupportedFileType(std::string_view fileName)

Defined in src/pacm/include/icy/pacm/packagemanager.h:280

Checks if the file type is a supported package archive.


getCacheFilePath

std::string getCacheFilePath(std::string_view fileName)

Defined in src/pacm/include/icy/pacm/packagemanager.h:284

Returns the full path of the cached file if it exists, or an empty path if the file doesn't exist.


getPackageDataDir

std::string getPackageDataDir(std::string_view id)

Defined in src/pacm/include/icy/pacm/packagemanager.h:288

Returns the package data directory for the given package ID.


mutableOptions

virtual

virtual Options & mutableOptions()

Defined in src/pacm/include/icy/pacm/packagemanager.h:295

Accessors.

Returns the mutable startup configuration for this manager. Callers should finish edits before initialize().


options

virtual const

virtual const Options & options() const

Defined in src/pacm/include/icy/pacm/packagemanager.h:298

Returns a read-only view of the current options.


remotePackages

virtual

virtual RemotePackageStore & remotePackages()

Defined in src/pacm/include/icy/pacm/packagemanager.h:301

Returns a reference to the in-memory remote package store.


localPackages

virtual

virtual LocalPackageStore & localPackages()

Defined in src/pacm/include/icy/pacm/packagemanager.h:304

Returns a reference to the in-memory local package store.

Protected Attributes

ReturnNameDescription
std::mutex_mutex
LocalPackageStore_localPackages
RemotePackageStore_remotePackages
InstallTaskPtrVec_tasks
Options_options

_mutex

std::mutex _mutex

Defined in src/pacm/include/icy/pacm/packagemanager.h:331


_localPackages

LocalPackageStore _localPackages

Defined in src/pacm/include/icy/pacm/packagemanager.h:332


_remotePackages

RemotePackageStore _remotePackages

Defined in src/pacm/include/icy/pacm/packagemanager.h:333


_tasks

InstallTaskPtrVec _tasks

Defined in src/pacm/include/icy/pacm/packagemanager.h:334


_options

Options _options

Defined in src/pacm/include/icy/pacm/packagemanager.h:335

Protected Methods

ReturnNameDescription
voidonPackageInstallCompleteCallbacks.

onPackageInstallComplete

void onPackageInstallComplete(InstallTask & task)

Defined in src/pacm/include/icy/pacm/packagemanager.h:328

Callbacks.