class ProjectLibraryOperation

Performs a project library operation such as save, move, copy or delete.

Operations are executed in three stages:

  1. Prepare (Main-thread) - Operation will ensure the input parameters are correct and return success if so. Operations will usually also register entries in the project library database at this stage (if possible). If this step fails, no further steps are executed. Since this executes on the main thread, this step should not take long so it doesn't block the UI.
  2. Run (Worker-thread) - This is where the bulk of the operation work will happen. Usually this involves serializing the package, writing moving, copying or deleting the file and similar.
  3. Finalize (Main-thread) - Triggers on the main thread after the worker thread has finished. Allows the main thread to wrap up the operation. For example this may involve refreshing the entry meta-data from the package that was saved by the worker thread.

Public

Constructors

ProjectLibraryOperation

ProjectLibraryOperation(const ProjectLibraryOperationContext &context, const String &name)

Methods

~ProjectLibraryOperation

virtual ~ProjectLibraryOperation() noexcept = default

GetOperationTracker

LongOperationTracker &GetOperationTracker()

Returns the tracker that should be used for notifications about operation's progress.

NotifyOperationWillStart

void NotifyOperationWillStart()

To be called by the operation worker just before calling PrepareOnMainThread.

NotifyOperationDidEnd

void NotifyOperationDidEnd()

To be called by the operation worker just after calling FinalizeOnMainThread.

PrepareOnMainThread

virtual Result PrepareOnMainThread()

Performs the first stage of the operation.

Verifies the input parameters are correct, creates library database entries (if possible) and returns success if operation will proceed to execute. Executed on the main thread.

Returns: Operation result and optional error message if failed.

RunOnWorkerThread

virtual void RunOnWorkerThread()

Performs the second stage of the operation.

Performs longer lasting tasks such as saving or loading a package, copying a file or generating preview icons. Executed on a worker thread.

FinalizeOnMainThread

virtual void FinalizeOnMainThread()

Performs the last stage of the operation.

This will be called after the worker thread completes. Will ensure the entries in the project library database match to packages written by the worker thread.

Protected

Fields

mEventNotifier

mDatabase

SPtr<ProjectLibraryDatabase> mDatabase

mImportedResourceFolder

Path mImportedResourceFolder

mSourceResourceFolder

Path mSourceResourceFolder

mOperationTracker

LongOperationTracker mOperationTracker