generic_task.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #ifndef __GENERIC_TASK_HPP__
  2. #define __GENERIC_TASK_HPP__
  3. #include <include/task/task.hpp>
  4. #include <type_traits>
  5. namespace Scheduler {
  6. namespace GenericArgs {
  7. const QString HEADER_TYPE = "header";
  8. const QString FILE_TYPE = "files";
  9. const QString DESCRIPTION_TYPE = "description";
  10. } // namespace Args
  11. static constexpr const char* GENERIC_NAME = "Generic";
  12. namespace TaskCode {
  13. static constexpr int GENTASKBYTE = 0xFC;
  14. }
  15. } // namespace Scheduler
  16. /**
  17. * @brief The GenericTask class
  18. *
  19. * Class to organize and transport data necessary to perform generic tasks.
  20. */
  21. class GenericTask : public Scheduler::Task {
  22. public:
  23. /**
  24. * @constructor
  25. */
  26. GenericTask();
  27. /**
  28. * Overrides @abstract Task::defineTaskArguments
  29. *
  30. * Useful for avoiding repetitive input of data.
  31. */
  32. virtual void defineTaskArguments() override;
  33. /**
  34. * Overrides @abstract Task::getTaskArguments
  35. *
  36. * Use this method to take over ownership of the task's arguments.
  37. */
  38. virtual const Scheduler::TaskArguments&& getTaskArguments() override;
  39. /**
  40. * Overrides @abstract Task::getTaskArgument
  41. *
  42. * Easy access to an argument.
  43. */
  44. virtual Scheduler::TaskArgument&& getTaskArgument(QString name) override;
  45. /**
  46. * Overrides @abstract Task::getTaskArgumentValue
  47. *
  48. * Easy access to an argument's value.
  49. */
  50. virtual const Scheduler::TypeVariant getTaskArgumentValue(QString name) override;
  51. /**
  52. * Overrides @abstract Task::getArgumentValues
  53. *
  54. * Easy access to all of the arguments that can be represented as a string.
  55. */
  56. virtual Scheduler::ArgumentValues getArgumentValues() override;
  57. /**
  58. * Overrides @abstract Task::getArgumentNames
  59. *
  60. * Provides the names of the arguments.
  61. */
  62. virtual QVector<QString> getArgumentNames() override;
  63. /**
  64. * Overrides @abstract Task::getFiles
  65. *
  66. * Easy access to the task's files.
  67. */
  68. virtual const QVector<Scheduler::KFileData> getFiles() override;
  69. /**
  70. * Overrides @abstract Task::getType
  71. *
  72. * Informs the caller of the task's type.
  73. */
  74. virtual Scheduler::TaskType getType() override;
  75. /**
  76. * Overrides @abstract Task::getTaskCode
  77. *
  78. * Returns the task's byte code.
  79. */
  80. virtual uint32_t getTaskCode() override;
  81. /**
  82. * Overrides @abstract Task::setArgument
  83. *
  84. * Set the value of an existing argument.
  85. */
  86. virtual void setArgument(QString name, Scheduler::TypeVariant arg) override;
  87. /**
  88. * Overrides @abstract Task::addArgument
  89. *
  90. * Add an additional value to a file container argument.
  91. */
  92. virtual void addArgument(QString name, Scheduler::KFileData file) override;
  93. /**
  94. * Overrides @abstract Task::addArgument
  95. *
  96. * Add an additional value to a string container argument.
  97. */
  98. virtual void addArgument(QString name, QString string) override;
  99. /**
  100. * Overrides @abstract Task::removeArgument
  101. *
  102. * Remove a value from a container argument.
  103. */
  104. virtual void removeArgument(QString name, Scheduler::TypeVariant arg) override;
  105. /**
  106. * Overrides @abstract Task::hasFiles
  107. *
  108. * Tells the caller if the task has files.
  109. */
  110. virtual bool hasFiles() override;
  111. /**
  112. * Overrides @abstract Task::isReady
  113. *
  114. * Informs the caller if the prerequisite arguments have values.
  115. */
  116. virtual bool isReady() override;
  117. /**
  118. * Overrides @abstract Task::clear
  119. *
  120. * Clears the values of all arguments, without removing the arguments.
  121. */
  122. virtual void clear() override;
  123. /**
  124. * Overrides @abstract Task::setDefaultValues
  125. *
  126. * Set default values for the arguments.
  127. */
  128. virtual void setDefaultValues() override;
  129. /**
  130. * Overrides @abstract Task::~Task
  131. * @destructor
  132. */
  133. virtual ~GenericTask() override;
  134. private:
  135. /**
  136. * @brief m_arguments
  137. *
  138. * A container storing the task's arguments
  139. */
  140. Scheduler::TaskArguments m_arguments;
  141. };
  142. #endif // __GENERIC_TASK_HPP