Pacm module

InstallTask

Downloads, extracts, and finalizes a single package installation.

InstallTask

#include <icy/pacm/installtask.h>

Inherits: Runnable, Stateful< InstallationState >

Downloads, extracts, and finalizes a single package installation.

Public Attributes

ReturnNameDescription
Signal< void(InstallTask &, int &)>ProgressSignals on progress update [0-100].
Signal< void(InstallTask &)>CompleteSignals on task completion for both success and failure cases.

Progress

Signal< void(InstallTask &, int &)> Progress

Signals on progress update [0-100].


Complete

Signal< void(InstallTask &)> Complete

Signals on task completion for both success and failure cases.

Public Methods

ReturnNameDescription
InstallTask#### Parameters
InstallTaskDeleted constructor.
InstallTaskDeleted constructor.
voidstart virtualValidates options, resolves the install directory, and launches the background runner.
voidcancel virtualTransitions the task to the Cancelled state.
voiddoDownload virtualDownloads the package archive from the server.
voiddoExtract virtualExtracts the downloaded package files to the intermediate directory.
voiddoFinalize virtualMoves extracted files from the intermediate directory to the installation directory.
voidsetComplete virtualCalled when the task completes either successfully or in error. This will trigger destruction.
Package::AssetgetRemoteAsset virtual constReturns the remote asset selected by the current InstallOptions. Respects version and sdkVersion overrides; falls back to latestAsset().
LocalPackage *local virtual constReturns a pointer to the local package record.
RemotePackage *remote virtual constReturns a pointer to the remote package record.
const InstallOptions &options virtual constReturns a read-only view of the installation options for this task.
uv::Loop *loop virtual constReturns the libuv event loop used for async operations.
boolvalid virtual constReturns true if the task is not in a Failed state and both local and remote (if set) packages are valid.
boolcancelled virtual constReturns true if the task is in the Cancelled state.
boolfailed virtual constReturns true if the task is in the Failed state.
boolsuccess virtual constReturns true if the task is in the Installed (success) state.
boolcomplete virtual constReturns true if the task has reached a terminal state (Installed, Cancelled, or Failed).
intprogress virtual constReturns the current progress value in the range [0, 100].

InstallTask

InstallTask(PackageManager & manager, LocalPackage * local, RemotePackage * remote, const InstallOptions & options, uv::Loop * loop)

Parameters

  • manager Owning PackageManager instance.

  • local Local package record (must not be null).

  • remote Remote package record to install from (may be null for local-only ops).

  • options Version and path overrides for this installation.

  • loop libuv event loop to use for async HTTP downloads.

Exceptions

  • std::runtime_error if the task configuration is invalid.

InstallTask

InstallTask(const InstallTask &) = delete

Deleted constructor.


InstallTask

InstallTask(InstallTask &&) = delete

Deleted constructor.


start

virtual

virtual void start()

Validates options, resolves the install directory, and launches the background runner.

Exceptions

  • std::runtime_error if the requested version or SDK version asset is unavailable.

cancel

virtual

virtual void cancel(bool flag)

Transitions the task to the Cancelled state.


doDownload

virtual

virtual void doDownload()

Downloads the package archive from the server.


doExtract

virtual

virtual void doExtract()

Extracts the downloaded package files to the intermediate directory.


doFinalize

virtual

virtual void doFinalize()

Moves extracted files from the intermediate directory to the installation directory.


setComplete

virtual

virtual void setComplete()

Called when the task completes either successfully or in error. This will trigger destruction.


getRemoteAsset

virtual const

virtual Package::Asset getRemoteAsset() const

Returns the remote asset selected by the current InstallOptions. Respects version and sdkVersion overrides; falls back to latestAsset().


local

virtual const

virtual LocalPackage * local() const

Returns a pointer to the local package record.


remote

virtual const

virtual RemotePackage * remote() const

Returns a pointer to the remote package record.


options

virtual const

virtual const InstallOptions & options() const

Returns a read-only view of the installation options for this task.


loop

virtual const

virtual uv::Loop * loop() const

Returns the libuv event loop used for async operations.


valid

virtual const

virtual bool valid() const

Returns true if the task is not in a Failed state and both local and remote (if set) packages are valid.


cancelled

virtual const

virtual bool cancelled() const

Returns true if the task is in the Cancelled state.


failed

virtual const

virtual bool failed() const

Returns true if the task is in the Failed state.


success

virtual const

virtual bool success() const

Returns true if the task is in the Installed (success) state.


complete

virtual const

virtual bool complete() const

Returns true if the task has reached a terminal state (Installed, Cancelled, or Failed).


progress

virtual const

virtual int progress() const

Returns the current progress value in the range [0, 100].

Protected Attributes

ReturnNameDescription
std::mutex_mutex
Idler_runner
icy::Error_error
PackageManager &_manager
LocalPackage *_local
RemotePackage *_remote
InstallOptions_options
int_progress
bool_downloading
http::ClientConnection::Ptr_dlconn
uv::Loop *_loop

_mutex

std::mutex _mutex

_runner

Idler _runner

_error

icy::Error _error

_manager

PackageManager & _manager

_local

LocalPackage * _local

_remote

RemotePackage * _remote

_options

InstallOptions _options

_progress

int _progress

_downloading

bool _downloading

_dlconn

http::ClientConnection::Ptr _dlconn

_loop

uv::Loop * _loop

Protected Methods

ReturnNameDescription
voidrun virtualCalled asynchronously by the thread to do the work.
voidonStateChange
voidonDownloadProgress virtual
voidonDownloadComplete virtual
voidsetProgress virtual

run

virtual

virtual void run()

Called asynchronously by the thread to do the work.


onStateChange

void onStateChange(InstallationState & state, const InstallationState & oldState)

onDownloadProgress

virtual

virtual void onDownloadProgress(const double & progress)

onDownloadComplete

virtual

virtual void onDownloadComplete(const http::Response & response)

setProgress

virtual

virtual void setProgress(int value)

Public Types

NameDescription
Ptr

Ptr

std::shared_ptr< InstallTask > Ptr()