forked from qt-creator/qt-creator
TaskTree: Adapt docs for onStorage{Setup,Done} handlers
Change-Id: I3dcd6dce573b23914952c30b935e6ddaa59d9c19 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -2110,8 +2110,8 @@ void TaskNode::invokeEndHandler(bool success)
|
|||||||
TreeStorage<CopyStorage> storage;
|
TreeStorage<CopyStorage> storage;
|
||||||
const Group root = ...; // storage placed inside root's group and inside handlers
|
const Group root = ...; // storage placed inside root's group and inside handlers
|
||||||
TaskTree taskTree(root);
|
TaskTree taskTree(root);
|
||||||
auto initStorage = [](CopyStorage *storage){
|
auto initStorage = [](CopyStorage &storage){
|
||||||
storage->content = "initial content";
|
storage.content = "initial content";
|
||||||
};
|
};
|
||||||
taskTree.onStorageSetup(storage, initStorage);
|
taskTree.onStorageSetup(storage, initStorage);
|
||||||
taskTree.start();
|
taskTree.start();
|
||||||
@@ -2130,8 +2130,8 @@ void TaskNode::invokeEndHandler(bool success)
|
|||||||
TreeStorage<CopyStorage> storage;
|
TreeStorage<CopyStorage> storage;
|
||||||
const Group root = ...; // storage placed inside root's group and inside handlers
|
const Group root = ...; // storage placed inside root's group and inside handlers
|
||||||
TaskTree taskTree(root);
|
TaskTree taskTree(root);
|
||||||
auto collectStorage = [](CopyStorage *storage){
|
auto collectStorage = [](const CopyStorage &storage){
|
||||||
qDebug() << "final content" << storage->content;
|
qDebug() << "final content" << storage.content;
|
||||||
};
|
};
|
||||||
taskTree.onStorageDone(storage, collectStorage);
|
taskTree.onStorageDone(storage, collectStorage);
|
||||||
taskTree.start();
|
taskTree.start();
|
||||||
@@ -2529,7 +2529,7 @@ int TaskTree::progressValue() const
|
|||||||
Installs a storage setup \a handler for the \a storage to pass the initial data
|
Installs a storage setup \a handler for the \a storage to pass the initial data
|
||||||
dynamically to the running task tree.
|
dynamically to the running task tree.
|
||||||
|
|
||||||
The \c StorageHandler takes the pointer to the \c StorageStruct instance:
|
The \c StorageHandler takes a reference to the \c StorageStruct instance:
|
||||||
|
|
||||||
\code
|
\code
|
||||||
static void save(const QString &fileName, const QByteArray &array) { ... }
|
static void save(const QString &fileName, const QByteArray &array) { ... }
|
||||||
@@ -2546,8 +2546,8 @@ int TaskTree::progressValue() const
|
|||||||
};
|
};
|
||||||
|
|
||||||
TaskTree taskTree(root);
|
TaskTree taskTree(root);
|
||||||
auto initStorage = [](QByteArray *storage){
|
auto initStorage = [](QByteArray &storage){
|
||||||
*storage = "initial content";
|
storage = "initial content";
|
||||||
};
|
};
|
||||||
taskTree.onStorageSetup(storage, initStorage);
|
taskTree.onStorageSetup(storage, initStorage);
|
||||||
taskTree.start();
|
taskTree.start();
|
||||||
@@ -2567,10 +2567,10 @@ int TaskTree::progressValue() const
|
|||||||
/*!
|
/*!
|
||||||
\fn template <typename StorageStruct, typename StorageHandler> void TaskTree::onStorageDone(const TreeStorage<StorageStruct> &storage, StorageHandler &&handler)
|
\fn template <typename StorageStruct, typename StorageHandler> void TaskTree::onStorageDone(const TreeStorage<StorageStruct> &storage, StorageHandler &&handler)
|
||||||
|
|
||||||
Installs a storage done \a handler for the \a storage to retrie the final data
|
Installs a storage done \a handler for the \a storage to retrieve the final data
|
||||||
dynamically from the running task tree.
|
dynamically from the running task tree.
|
||||||
|
|
||||||
The \c StorageHandler takes the pointer to the \c StorageStruct instance:
|
The \c StorageHandler takes a const reference to the \c StorageStruct instance:
|
||||||
|
|
||||||
\code
|
\code
|
||||||
static QByteArray load(const QString &fileName) { ... }
|
static QByteArray load(const QString &fileName) { ... }
|
||||||
@@ -2590,8 +2590,8 @@ int TaskTree::progressValue() const
|
|||||||
};
|
};
|
||||||
|
|
||||||
TaskTree taskTree(root);
|
TaskTree taskTree(root);
|
||||||
auto collectStorage = [](QByteArray *storage){
|
auto collectStorage = [](const QByteArray &storage){
|
||||||
qDebug() << "final content" << *storage;
|
qDebug() << "final content" << storage;
|
||||||
};
|
};
|
||||||
taskTree.onStorageDone(storage, collectStorage);
|
taskTree.onStorageDone(storage, collectStorage);
|
||||||
taskTree.start();
|
taskTree.start();
|
||||||
|
Reference in New Issue
Block a user