ui: split steps of indexing files and saving the last few batches of data
* implemented showing dialog for database injection * implemented easy-to-read way of creating behavior tree structures * moved injector wait logic out of injection task
This commit is contained in:
@@ -19,20 +19,6 @@ TaskInjectStorage::TaskInjectStorage(
|
||||
|
||||
void TaskInjectStorage::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
while (!m_hasInjected)
|
||||
{
|
||||
int indexerCount = 0;
|
||||
if (blackboard->get("indexer_count", indexerCount))
|
||||
{
|
||||
if (indexerCount > 0 || m_storageProvider->getStorageCount() > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const int SLEEP_TIME_MS = 25;
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME_MS));
|
||||
}
|
||||
}
|
||||
|
||||
Task::TaskState TaskInjectStorage::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
@@ -43,7 +29,6 @@ Task::TaskState TaskInjectStorage::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
if (source)
|
||||
{
|
||||
m_target->inject(source.get());
|
||||
m_hasInjected = true;
|
||||
return STATE_SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -53,15 +38,6 @@ Task::TaskState TaskInjectStorage::doUpdate(std::shared_ptr<Blackboard> blackboa
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME_MS));
|
||||
}
|
||||
|
||||
int indexerCount = 0;
|
||||
if (blackboard->get("indexer_count", indexerCount))
|
||||
{
|
||||
if (indexerCount > 0 || m_storageProvider->getStorageCount() > 0)
|
||||
{
|
||||
return STATE_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
return STATE_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
#include "data/TaskShowDialogView.h"
|
||||
|
||||
#include "component/view/DialogView.h"
|
||||
|
||||
TaskShowDialogView::TaskShowDialogView(
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
DialogView* dialogView
|
||||
)
|
||||
: m_title(title)
|
||||
, m_message(message)
|
||||
, m_dialogView(dialogView)
|
||||
{
|
||||
}
|
||||
|
||||
TaskShowDialogView::~TaskShowDialogView()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskShowDialogView::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
|
||||
Task::TaskState TaskShowDialogView::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
m_dialogView->showProgressDialog(m_title, m_message);
|
||||
return STATE_SUCCESS;
|
||||
}
|
||||
|
||||
void TaskShowDialogView::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
|
||||
void TaskShowDialogView::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
#ifndef TASK_SHOW_DIALOG_VIEW_H
|
||||
#define TASK_SHOW_DIALOG_VIEW_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "utility/scheduling/Task.h"
|
||||
|
||||
class DialogView;
|
||||
|
||||
class TaskShowDialogView
|
||||
: public Task
|
||||
{
|
||||
public:
|
||||
TaskShowDialogView(
|
||||
const std::string& title,
|
||||
const std::string& message,
|
||||
DialogView* dialogView
|
||||
);
|
||||
|
||||
virtual ~TaskShowDialogView();
|
||||
|
||||
private:
|
||||
virtual void doEnter(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual TaskState doUpdate(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doExit(std::shared_ptr<Blackboard> blackboard);
|
||||
virtual void doReset(std::shared_ptr<Blackboard> blackboard);
|
||||
|
||||
const std::string m_title;
|
||||
const std::string m_message;
|
||||
DialogView* m_dialogView;
|
||||
};
|
||||
|
||||
#endif // TASK_SHOW_DIALOG_VIEW_H
|
||||
Reference in New Issue
Block a user