|
@@ -1,8 +1,10 @@
|
|
#ifndef __TASK_HPP__
|
|
#ifndef __TASK_HPP__
|
|
#define __TASK_HPP__
|
|
#define __TASK_HPP__
|
|
|
|
|
|
|
|
+#include <QQueue>
|
|
#include <QString>
|
|
#include <QString>
|
|
#include <memory>
|
|
#include <memory>
|
|
|
|
+#include <variant>
|
|
#include <vector>
|
|
#include <vector>
|
|
|
|
|
|
enum FileType { VIDEO = 1, IMAGE = 2 };
|
|
enum FileType { VIDEO = 1, IMAGE = 2 };
|
|
@@ -26,10 +28,12 @@ static constexpr const char* BOOLEAN = "Boolean";
|
|
} // namespace Type
|
|
} // namespace Type
|
|
|
|
|
|
using ArgumentType = const char*;
|
|
using ArgumentType = const char*;
|
|
|
|
+using TypeVariant = std::variant<QString, bool, std::vector<std::string>, std::vector<KFileData>>;
|
|
|
|
|
|
class TaskArgumentBase {
|
|
class TaskArgumentBase {
|
|
public:
|
|
public:
|
|
virtual QString text() const = 0;
|
|
virtual QString text() const = 0;
|
|
|
|
+ virtual void setValue(TypeVariant v) = 0;
|
|
};
|
|
};
|
|
|
|
|
|
template <typename T>
|
|
template <typename T>
|
|
@@ -42,38 +46,25 @@ class TaskArgument : TaskArgumentBase {
|
|
}
|
|
}
|
|
TaskArgument(TaskArgument&& a) : name(std::move(a.name)), type(std::move(a.type)), value(std::move(a.value)) {}
|
|
TaskArgument(TaskArgument&& a) : name(std::move(a.name)), type(std::move(a.type)), value(std::move(a.value)) {}
|
|
virtual QString text() const { return name; }
|
|
virtual QString text() const { return name; }
|
|
- virtual void setValue(T new_value) { value = new_value; }
|
|
|
|
|
|
+ virtual void setValue(TypeVariant new_value) override { value = new_value; }
|
|
QString name;
|
|
QString name;
|
|
ArgumentType type;
|
|
ArgumentType type;
|
|
T value;
|
|
T value;
|
|
};
|
|
};
|
|
|
|
|
|
using TaskIterator = std::vector<std::unique_ptr<TaskArgumentBase>>::iterator;
|
|
using TaskIterator = std::vector<std::unique_ptr<TaskArgumentBase>>::iterator;
|
|
-
|
|
|
|
-class TaskArguments {
|
|
|
|
- public:
|
|
|
|
- TaskIterator getArgumentIterator(QString name) {
|
|
|
|
- return std::find_if(values.begin(), values.end(), [name](auto argument) { return argument.text() == name; });
|
|
|
|
- }
|
|
|
|
- TaskIterator begin() { return values.begin(); }
|
|
|
|
- TaskIterator end() { return values.end(); }
|
|
|
|
- bool isValidIterator(TaskIterator it) { return it != values.end(); }
|
|
|
|
- void setArguments(std::vector<std::unique_ptr<TaskArgumentBase>>&& new_values) { values = new_values; }
|
|
|
|
-
|
|
|
|
- private:
|
|
|
|
- std::vector<std::unique_ptr<TaskArgumentBase>> values;
|
|
|
|
-};
|
|
|
|
|
|
+using TaskArguments = std::vector<std::unique_ptr<TaskArgumentBase>>;
|
|
|
|
|
|
class Task {
|
|
class Task {
|
|
public:
|
|
public:
|
|
virtual void defineTaskArguments() = 0;
|
|
virtual void defineTaskArguments() = 0;
|
|
virtual bool isReady() = 0;
|
|
virtual bool isReady() = 0;
|
|
virtual const TaskArguments getTaskArguments() = 0;
|
|
virtual const TaskArguments getTaskArguments() = 0;
|
|
- template <typename T>
|
|
|
|
- void setArgument(QString name, T new_value){};
|
|
|
|
virtual void clear() = 0;
|
|
virtual void clear() = 0;
|
|
virtual ~Task(){};
|
|
virtual ~Task(){};
|
|
};
|
|
};
|
|
} // namespace Scheduler
|
|
} // namespace Scheduler
|
|
|
|
|
|
|
|
+typedef QQueue<Task> TaskQueue;
|
|
|
|
+
|
|
#endif // __TASK_HPP__
|
|
#endif // __TASK_HPP__
|