logic: allow the user to discard an aborted indexer run
* keep old database on filesystem while indexing * migrate old ".coatiproject" settings to new ".srctrlprj" extension when loading project * send new errors in MessageErrorCountUpdate after injecting * recheck filepath exist() in FileSystem's remove, rename, copy and create functions * updated tasks to new "override" policy
This commit is contained in:
@@ -203,45 +203,51 @@ TimeStamp FileSystem::getLastWriteTime(const FilePath& filePath)
|
||||
|
||||
bool FileSystem::remove(const FilePath& path)
|
||||
{
|
||||
return boost::filesystem::remove(path.getPath());
|
||||
const bool ret = boost::filesystem::remove(path.getPath());
|
||||
path.recheckExists();
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool FileSystem::rename(const FilePath& from, const FilePath& to)
|
||||
{
|
||||
if (!from.exists() || to.exists())
|
||||
if (!from.recheckExists() || to.recheckExists())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
boost::filesystem::rename(from.getPath(), to.getPath());
|
||||
to.recheckExists();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileSystem::copyFile(const FilePath& from, const FilePath& to)
|
||||
{
|
||||
if (!from.exists() || to.exists())
|
||||
if (!from.recheckExists() || to.recheckExists())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
boost::filesystem::copy_file(from.getPath(), to.getPath());
|
||||
to.recheckExists();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileSystem::copy_directory(const FilePath& from, const FilePath& to)
|
||||
{
|
||||
if (!from.exists() || to.exists())
|
||||
if (!from.recheckExists() || to.recheckExists())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
boost::filesystem::copy_directory(from.getPath(), to.getPath());
|
||||
to.recheckExists();
|
||||
return true;
|
||||
}
|
||||
|
||||
void FileSystem::createDirectory(const FilePath& path)
|
||||
{
|
||||
boost::filesystem::create_directories(path.str());
|
||||
path.recheckExists();
|
||||
}
|
||||
|
||||
std::vector<FilePath> FileSystem::getDirectSubDirectories(const FilePath& path)
|
||||
|
||||
@@ -21,6 +21,15 @@ class MessageFilterErrorCountUpdate
|
||||
{
|
||||
if ((*it)->getType() == MessageErrorCountUpdate::getStaticType())
|
||||
{
|
||||
MessageErrorCountUpdate* frontErrorsMessage = dynamic_cast<MessageErrorCountUpdate*>(message);
|
||||
MessageErrorCountUpdate* backErrorsMessage = dynamic_cast<MessageErrorCountUpdate*>(it->get());
|
||||
|
||||
backErrorsMessage->newErrors.insert(
|
||||
backErrorsMessage->newErrors.begin(),
|
||||
frontErrorsMessage->newErrors.begin(),
|
||||
frontErrorsMessage->newErrors.end()
|
||||
);
|
||||
|
||||
messageBuffer->pop_front();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -14,13 +14,20 @@ public:
|
||||
return "MessageErrorCountUpdate";
|
||||
}
|
||||
|
||||
MessageErrorCountUpdate(const ErrorCountInfo& errorCount)
|
||||
MessageErrorCountUpdate(const ErrorCountInfo& errorCount, const std::vector<ErrorInfo>& newErrors)
|
||||
: errorCount(errorCount)
|
||||
, newErrors(newErrors)
|
||||
{
|
||||
setSendAsTask(false);
|
||||
}
|
||||
|
||||
virtual void print(std::wostream& os) const
|
||||
{
|
||||
os << errorCount.total << '/' << errorCount.fatal << L" - " << newErrors.size() << L" new errors";
|
||||
}
|
||||
|
||||
const ErrorCountInfo errorCount;
|
||||
std::vector<ErrorInfo> newErrors;
|
||||
};
|
||||
|
||||
#endif // MESSAGE_ERROR_COUNT_UPDATE_H
|
||||
|
||||
@@ -6,10 +6,6 @@ TaskDecorator::TaskDecorator()
|
||||
{
|
||||
}
|
||||
|
||||
TaskDecorator::~TaskDecorator()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<TaskDecorator> TaskDecorator::addChildTask(std::shared_ptr<Task> child)
|
||||
{
|
||||
setTask(child);
|
||||
|
||||
@@ -13,11 +13,10 @@ class TaskDecorator
|
||||
{
|
||||
public:
|
||||
TaskDecorator();
|
||||
virtual ~TaskDecorator();
|
||||
std::shared_ptr<TaskDecorator> addChildTask(std::shared_ptr<Task> child);
|
||||
|
||||
virtual void setTask(std::shared_ptr<Task> task);
|
||||
virtual void terminate();
|
||||
void terminate() override;
|
||||
|
||||
protected:
|
||||
std::shared_ptr<TaskRunner> m_taskRunner;
|
||||
|
||||
@@ -14,11 +14,11 @@ public:
|
||||
TaskDecoratorDelay(size_t delayMS);
|
||||
|
||||
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);
|
||||
virtual void doTerminate();
|
||||
void doEnter(std::shared_ptr<Blackboard> blackboard) override;
|
||||
TaskState doUpdate(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doExit(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doReset(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doTerminate() override;
|
||||
|
||||
const size_t m_delayMS;
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ public:
|
||||
TaskDecoratorRepeat(ConditionType condition, TaskState exitState);
|
||||
|
||||
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);
|
||||
void doEnter(std::shared_ptr<Blackboard> blackboard) override;
|
||||
TaskState doUpdate(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doExit(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doReset(std::shared_ptr<Blackboard> blackboard) override;
|
||||
|
||||
const ConditionType m_condition;
|
||||
const TaskState m_exitState;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "utility/scheduling/TaskFindValue.h"
|
||||
|
||||
#include "utility/scheduling/Blackboard.h"
|
||||
|
||||
TaskFindValue::TaskFindValue(const std::string& valueName)
|
||||
: m_valueName(valueName)
|
||||
{
|
||||
}
|
||||
|
||||
void TaskFindValue::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
|
||||
Task::TaskState TaskFindValue::doUpdate(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(blackboard->getMutex());
|
||||
return (blackboard->exists(m_valueName)) ? STATE_SUCCESS : STATE_FAILURE;
|
||||
}
|
||||
|
||||
void TaskFindValue::doExit(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
|
||||
void TaskFindValue::doReset(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
#ifndef TASK_FIND_VALUE_H
|
||||
#define TASK_FIND_VALUE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "utility/scheduling/Task.h"
|
||||
|
||||
class Blackboard;
|
||||
|
||||
class TaskFindValue:
|
||||
public Task
|
||||
{
|
||||
public:
|
||||
TaskFindValue(const std::string& valueName);
|
||||
|
||||
private:
|
||||
void doEnter(std::shared_ptr<Blackboard> blackboard) override;
|
||||
TaskState doUpdate(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doExit(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doReset(std::shared_ptr<Blackboard> blackboard) override;
|
||||
|
||||
const std::string m_valueName;
|
||||
};
|
||||
|
||||
#endif // TASK_FIND_VALUE_H
|
||||
@@ -4,10 +4,6 @@ TaskGroup::TaskGroup()
|
||||
{
|
||||
}
|
||||
|
||||
TaskGroup::~TaskGroup()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<TaskGroup> TaskGroup::addChildTasks(std::shared_ptr<Task> child1)
|
||||
{
|
||||
addTask(child1);
|
||||
|
||||
@@ -12,13 +12,12 @@ class TaskGroup
|
||||
{
|
||||
public:
|
||||
TaskGroup();
|
||||
virtual ~TaskGroup();
|
||||
std::shared_ptr<TaskGroup> addChildTasks(std::shared_ptr<Task> child1);
|
||||
std::shared_ptr<TaskGroup> addChildTasks(std::shared_ptr<Task> child1, std::shared_ptr<Task> child2);
|
||||
std::shared_ptr<TaskGroup> addChildTasks(std::shared_ptr<Task> child1, std::shared_ptr<Task> child2, std::shared_ptr<Task> child3);
|
||||
|
||||
virtual void addTask(std::shared_ptr<Task> task) = 0;
|
||||
virtual void terminate();
|
||||
void terminate() override;
|
||||
|
||||
private:
|
||||
virtual void doTerminate() = 0;
|
||||
|
||||
@@ -15,7 +15,7 @@ public:
|
||||
TaskGroupParallel();
|
||||
virtual ~TaskGroupParallel();
|
||||
|
||||
virtual void addTask(std::shared_ptr<Task> task);
|
||||
void addTask(std::shared_ptr<Task> task) override;
|
||||
|
||||
private:
|
||||
struct TaskInfo
|
||||
@@ -29,11 +29,11 @@ private:
|
||||
volatile bool active;
|
||||
};
|
||||
|
||||
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);
|
||||
virtual void doTerminate();
|
||||
void doEnter(std::shared_ptr<Blackboard> blackboard) override;
|
||||
TaskState doUpdate(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doExit(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doReset(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doTerminate() override;
|
||||
|
||||
void processTaskThreaded(
|
||||
std::shared_ptr<TaskInfo> taskInfo,
|
||||
|
||||
@@ -4,10 +4,6 @@ TaskGroupSelector::TaskGroupSelector()
|
||||
{
|
||||
}
|
||||
|
||||
TaskGroupSelector::~TaskGroupSelector()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskGroupSelector::addTask(std::shared_ptr<Task> task)
|
||||
{
|
||||
m_taskRunners.push_back(std::make_shared<TaskRunner>(task));
|
||||
|
||||
@@ -9,16 +9,15 @@ class TaskGroupSelector
|
||||
{
|
||||
public:
|
||||
TaskGroupSelector();
|
||||
virtual ~TaskGroupSelector();
|
||||
|
||||
virtual void addTask(std::shared_ptr<Task> task);
|
||||
|
||||
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);
|
||||
virtual void doTerminate();
|
||||
void doEnter(std::shared_ptr<Blackboard> blackboard) override;
|
||||
TaskState doUpdate(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doExit(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doReset(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doTerminate() override;
|
||||
|
||||
std::vector<std::shared_ptr<TaskRunner>> m_taskRunners;
|
||||
int m_taskIndex;
|
||||
|
||||
@@ -4,10 +4,6 @@ TaskGroupSequence::TaskGroupSequence()
|
||||
{
|
||||
}
|
||||
|
||||
TaskGroupSequence::~TaskGroupSequence()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskGroupSequence::addTask(std::shared_ptr<Task> task)
|
||||
{
|
||||
m_taskRunners.push_back(std::make_shared<TaskRunner>(task));
|
||||
|
||||
@@ -9,16 +9,15 @@ class TaskGroupSequence
|
||||
{
|
||||
public:
|
||||
TaskGroupSequence();
|
||||
virtual ~TaskGroupSequence();
|
||||
|
||||
virtual void addTask(std::shared_ptr<Task> task);
|
||||
|
||||
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);
|
||||
virtual void doTerminate();
|
||||
void doEnter(std::shared_ptr<Blackboard> blackboard) override;
|
||||
TaskState doUpdate(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doExit(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doReset(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doTerminate() override;
|
||||
|
||||
std::vector<std::shared_ptr<TaskRunner>> m_taskRunners;
|
||||
int m_taskIndex;
|
||||
|
||||
@@ -5,10 +5,6 @@ TaskLambda::TaskLambda(std::function<void()> func)
|
||||
{
|
||||
}
|
||||
|
||||
TaskLambda::~TaskLambda()
|
||||
{
|
||||
}
|
||||
|
||||
void TaskLambda::doEnter(std::shared_ptr<Blackboard> blackboard)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -10,13 +10,12 @@ class TaskLambda
|
||||
{
|
||||
public:
|
||||
TaskLambda(std::function<void()> func);
|
||||
virtual ~TaskLambda();
|
||||
|
||||
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);
|
||||
void doEnter(std::shared_ptr<Blackboard> blackboard) override;
|
||||
TaskState doUpdate(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doExit(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doReset(std::shared_ptr<Blackboard> blackboard) override;
|
||||
|
||||
std::function<void()> m_func;
|
||||
};
|
||||
|
||||
@@ -18,10 +18,10 @@ public:
|
||||
TaskReturnSuccessWhile(const std::string& lhsValueName, ConditionType condition, T rhsValue);
|
||||
|
||||
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);
|
||||
void doEnter(std::shared_ptr<Blackboard> blackboard) override;
|
||||
TaskState doUpdate(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doExit(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doReset(std::shared_ptr<Blackboard> blackboard) override;
|
||||
|
||||
const std::string m_lhsValueName;
|
||||
const ConditionType m_condition;
|
||||
|
||||
@@ -12,10 +12,10 @@ public:
|
||||
TaskSetValue(const std::string& valueName, T value);
|
||||
|
||||
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);
|
||||
void doEnter(std::shared_ptr<Blackboard> blackboard) override;
|
||||
TaskState doUpdate(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doExit(std::shared_ptr<Blackboard> blackboard) override;
|
||||
void doReset(std::shared_ptr<Blackboard> blackboard) override;
|
||||
|
||||
const std::string m_valueName;
|
||||
const T m_value;
|
||||
|
||||
Reference in New Issue
Block a user