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:
malte_langkabel
2016-11-11 15:40:28 +01:00
parent 65eca50be4
commit fb72f73567
20 changed files with 431 additions and 108 deletions
-24
View File
@@ -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;
}
+36
View File
@@ -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)
{
}
+33
View File
@@ -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