12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #ifndef __TASK_HPP__
- #define __TASK_HPP__
- #include <QQueue>
- #include <QString>
- #include <memory>
- #include <variant>
- #include <vector>
- enum FileType { VIDEO = 1, IMAGE = 2 };
- struct KFileData {
- QString name;
- FileType type;
- QString path;
- QByteArray bytes;
- };
- namespace Scheduler {
- namespace Type {
- static constexpr const char* TEXT = "Text";
- static constexpr const char* FILE = "File";
- static constexpr const char* STRINGVECTOR = "StringVector";
- static constexpr const char* FILEVECTOR = "FileVector";
- static constexpr const char* DATETIME = "DateTime";
- static constexpr const char* BOOLEAN = "Boolean";
- } // namespace Type
- using ArgumentType = const char*;
- using TypeVariant = std::variant<QString, bool, std::vector<std::string>, std::vector<KFileData>>;
- class TaskArgumentBase {
- public:
- virtual QString text() const = 0;
- virtual void setValue(TypeVariant v) = 0;
- };
- template <typename T>
- class TaskArgument : TaskArgumentBase {
- public:
- TaskArgument(QString n, ArgumentType t, T _value) {
- name = n;
- type = t;
- value = _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 void setValue(TypeVariant new_value) override { value = new_value; }
- QString name;
- ArgumentType type;
- T value;
- };
- using TaskIterator = std::vector<std::unique_ptr<TaskArgumentBase>>::iterator;
- using TaskArguments = std::vector<std::unique_ptr<TaskArgumentBase>>;
- class Task {
- public:
- virtual void defineTaskArguments() = 0;
- virtual bool isReady() = 0;
- virtual const TaskArguments getTaskArguments() = 0;
- virtual void clear() = 0;
- virtual ~Task(){};
- };
- } // namespace Scheduler
- typedef QQueue<Task> TaskQueue;
- #endif // __TASK_HPP__
|