Pacm module

InstallTask

Downloads, extracts, and finalizes a single package installation.

#include <icy/pacm/installtask.h>

class InstallTask

Defined in src/pacm/include/icy/pacm/installtask.h:89

List of all members

NameKindOwner
PackageManagerfriendDeclared here
InstallMonitorfriendDeclared here
ProgressvariableDeclared here
CompletevariableDeclared here
InstallTaskfunctionDeclared here
~InstallTaskfunctionDeclared here
InstallTaskfunctionDeclared here
operator=functionDeclared here
InstallTaskfunctionDeclared here
operator=functionDeclared here
startfunctionDeclared here
cancelfunctionDeclared here
doDownloadfunctionDeclared here
doExtractfunctionDeclared here
doFinalizefunctionDeclared here
setCompletefunctionDeclared here
getRemoteAssetfunctionDeclared here
localfunctionDeclared here
remotefunctionDeclared here
optionsfunctionDeclared here
loopfunctionDeclared here
validfunctionDeclared here
cancelledfunctionDeclared here
failedfunctionDeclared here
successfunctionDeclared here
completefunctionDeclared here
progressfunctionDeclared here
_mutexvariableDeclared here
_runnervariableDeclared here
_errorvariableDeclared here
_managervariableDeclared here
_localvariableDeclared here
_remotevariableDeclared here
_optionsvariableDeclared here
_progressvariableDeclared here
_downloadingvariableDeclared here
_dlconnvariableDeclared here
_loopvariableDeclared here
runfunctionDeclared here
onStateChangefunctionDeclared here
onDownloadProgressfunctionDeclared here
onDownloadCompletefunctionDeclared here
setProgressfunctionDeclared here
PtrtypedefDeclared here
RunnablefunctionInherited from Runnable
~RunnablefunctionInherited from Runnable
runfunctionInherited from Runnable
cancelfunctionInherited from Runnable
cancelledfunctionInherited from Runnable
exitvariableInherited from Runnable
StateChangevariableInherited from Stateful
StatefulfunctionInherited from Stateful
~StatefulfunctionInherited from Stateful
stateEqualsfunctionInherited from Stateful
stateBetweenfunctionInherited from Stateful
statefunctionInherited from Stateful
statefunctionInherited from Stateful
_statevariableInherited from Stateful
beforeStateChangefunctionInherited from Stateful
onStateChangefunctionInherited from Stateful
setStatefunctionInherited from Stateful
setStatefunctionInherited from Stateful

Inherited from Runnable

KindNameDescription
functionRunnable inline
function~Runnable virtualDefaulted destructor.
functionrun virtualThe run method will be called by the asynchronous context.
functioncancel virtual inlineCancel the current task. The run() method should return ASAP.
functioncancelled virtual const inlineReturns true when the task has been cancelled.
variableexit

Inherited from Stateful

KindNameDescription
variableStateChangeSignals when the state changes.
functionStateful inline
function~Stateful virtual inline
functionstateEquals virtual const inlineReturns true if the current state ID equals the given ID.
functionstateBetween virtual const inlineReturns true if the current state ID is in the inclusive range [lid, rid].
functionstate virtual inlineReturns a mutable reference to the current state.
functionstate virtual const inlineReturns a copy of the current state.
variable_state
functionbeforeStateChange virtual inlineOverride to handle pre state change logic. Return false to prevent state change.
functiononStateChange virtual inlineOverride to handle post state change logic.
functionsetState virtual inlineSets the state and sends the state signal if the state change was successful.
functionsetState virtual inlineSets the state and sends the state signal if the state change was successful.

Friends


PackageManager

friend class PackageManager

Defined in src/pacm/include/icy/pacm/installtask.h:202


InstallMonitor

friend class InstallMonitor

Defined in src/pacm/include/icy/pacm/installtask.h:203

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

Type: Signal< void(InstallTask &, int &)>

Defined in src/pacm/include/icy/pacm/installtask.h:171

Signals on progress update [0-100].


Complete

Signal< void(InstallTask &)> Complete

Type: Signal< void(InstallTask &)>

Defined in src/pacm/include/icy/pacm/installtask.h:175

Signals on task completion for both success and failure cases.

Public Methods

ReturnNameDescription
InstallTask
~InstallTask virtual noexcept
InstallTaskDeleted constructor.
InstallTask &operator=Deleted assignment operator.
InstallTaskDeleted constructor.
InstallTask &operator=Deleted assignment operator.
voidstart virtualValidates options, resolves the install directory, and launches the background runner.
voidcancel virtual overrideTransitions 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 const overrideReturns 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 = InstallOptions(), uv::Loop * loop = uv::defaultLoop())

Defined in src/pacm/include/icy/pacm/installtask.h:101

Parameters

ParameterTypeDescription
managerPackageManager &Owning PackageManager instance.
localLocalPackage *Local package record (must not be null).
remoteRemotePackage *Remote package record to install from (may be null for local-only ops).
optionsconst InstallOptions &Version and path overrides for this installation.
loopuv::Loop *libuv event loop to use for async HTTP downloads.

Exceptions

ExceptionDescription
std::runtime_errorif the task configuration is invalid.

~InstallTask

virtual noexcept

virtual ~InstallTask() noexcept

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


InstallTask

InstallTask(const InstallTask &) = delete

Defined in src/pacm/include/icy/pacm/installtask.h:106

Deleted constructor.


operator=

InstallTask & operator=(const InstallTask &) = delete

Defined in src/pacm/include/icy/pacm/installtask.h:107

Deleted assignment operator.


InstallTask

InstallTask(InstallTask &&) = delete

Defined in src/pacm/include/icy/pacm/installtask.h:108

Deleted constructor.


operator=

InstallTask & operator=(InstallTask &&) = delete

Defined in src/pacm/include/icy/pacm/installtask.h:109

Deleted assignment operator.


start

virtual

virtual void start()

Defined in src/pacm/include/icy/pacm/installtask.h:113

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

Exceptions

ExceptionDescription
std::runtime_errorif the requested version or SDK version asset is unavailable.

cancel

virtual override

virtual void cancel(bool flag = true) override

Defined in src/pacm/include/icy/pacm/installtask.h:116

Transitions the task to the Cancelled state.

Reimplements


doDownload

virtual

virtual void doDownload()

Defined in src/pacm/include/icy/pacm/installtask.h:119

Downloads the package archive from the server.


doExtract

virtual

virtual void doExtract()

Defined in src/pacm/include/icy/pacm/installtask.h:123

Extracts the downloaded package files to the intermediate directory.


doFinalize

virtual

virtual void doFinalize()

Defined in src/pacm/include/icy/pacm/installtask.h:127

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


setComplete

virtual

virtual void setComplete()

Defined in src/pacm/include/icy/pacm/installtask.h:132

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


getRemoteAsset

virtual const

virtual Package::Asset getRemoteAsset() const

Defined in src/pacm/include/icy/pacm/installtask.h:136

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

Defined in src/pacm/include/icy/pacm/installtask.h:139

Returns a pointer to the local package record.


remote

virtual const

virtual RemotePackage * remote() const

Defined in src/pacm/include/icy/pacm/installtask.h:142

Returns a pointer to the remote package record.


options

virtual const

virtual const InstallOptions & options() const

Defined in src/pacm/include/icy/pacm/installtask.h:145

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


loop

virtual const

virtual uv::Loop * loop() const

Defined in src/pacm/include/icy/pacm/installtask.h:148

Returns the libuv event loop used for async operations.


valid

virtual const

virtual bool valid() const

Defined in src/pacm/include/icy/pacm/installtask.h:152

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


cancelled

virtual const override

virtual bool cancelled() const override

Defined in src/pacm/include/icy/pacm/installtask.h:155

Returns true if the task is in the Cancelled state.

Reimplements


failed

virtual const

virtual bool failed() const

Defined in src/pacm/include/icy/pacm/installtask.h:158

Returns true if the task is in the Failed state.


success

virtual const

virtual bool success() const

Defined in src/pacm/include/icy/pacm/installtask.h:161

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


complete

virtual const

virtual bool complete() const

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

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


progress

virtual const

virtual int progress() const

Defined in src/pacm/include/icy/pacm/installtask.h:168

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

Protected Attributes


_mutex

std::mutex _mutex

Defined in src/pacm/include/icy/pacm/installtask.h:189


_runner

Idler _runner

Type: Idler

Defined in src/pacm/include/icy/pacm/installtask.h:191


_error

icy::Error _error

Type: icy::Error

Defined in src/pacm/include/icy/pacm/installtask.h:192


_manager

PackageManager & _manager

Type: PackageManager &

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


_local

LocalPackage * _local

Type: LocalPackage *

Defined in src/pacm/include/icy/pacm/installtask.h:194


_remote

RemotePackage * _remote

Type: RemotePackage *

Defined in src/pacm/include/icy/pacm/installtask.h:195


_options

InstallOptions _options

Type: InstallOptions

Defined in src/pacm/include/icy/pacm/installtask.h:196


_progress

int _progress

Defined in src/pacm/include/icy/pacm/installtask.h:197


_downloading

bool _downloading

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


_dlconn

http::ClientConnection::Ptr _dlconn

Type: http::ClientConnection::Ptr

Defined in src/pacm/include/icy/pacm/installtask.h:199


_loop

uv::Loop * _loop

Type: uv::Loop *

Defined in src/pacm/include/icy/pacm/installtask.h:200

Protected Methods

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

run

virtual override

virtual void run() override

Defined in src/pacm/include/icy/pacm/installtask.h:179

Called asynchronously by the thread to do the work.

Reimplements


onStateChange

override

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

Defined in src/pacm/include/icy/pacm/installtask.h:181


onDownloadProgress

virtual

virtual void onDownloadProgress(const double & progress)

Defined in src/pacm/include/icy/pacm/installtask.h:183


onDownloadComplete

virtual

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

Defined in src/pacm/include/icy/pacm/installtask.h:184


setProgress

virtual

virtual void setProgress(int value)

Defined in src/pacm/include/icy/pacm/installtask.h:186

Public Types

NameDescription
Ptr

Ptr

using Ptr = std::shared_ptr< InstallTask >

Type: std::shared_ptr< InstallTask >

Defined in src/pacm/include/icy/pacm/installtask.h:93