| 4 | #include "InstanceTask.h" |
| 5 | |
| 6 | class InstanceCreationTask : public InstanceTask { |
| 7 | Q_OBJECT |
| 8 | public: |
| 9 | InstanceCreationTask() = default; |
| 10 | virtual ~InstanceCreationTask() = default; |
| 11 | |
| 12 | protected: |
| 13 | void executeTask() final override; |
| 14 | |
| 15 | /** |
| 16 | * Tries to update an already existing instance. |
| 17 | * |
| 18 | * This can be implemented by subclasses to provide a way of updating an already existing |
| 19 | * instance, according to that implementation's concept of 'identity' (i.e. instances that |
| 20 | * are updates / downgrades of one another). |
| 21 | * |
| 22 | * If this returns true, createInstance() will not run, so you should do all update steps in here. |
| 23 | * Otherwise, createInstance() is run as normal. |
| 24 | */ |
| 25 | virtual bool updateInstance() { return false; }; |
| 26 | |
| 27 | /** |
| 28 | * Creates a new instance. |
| 29 | * |
| 30 | * Returns whether the instance creation was successful (true) or not (false). |
| 31 | */ |
| 32 | virtual bool createInstance() { return false; }; |
| 33 | |
| 34 | QString getError() const { return m_error_message; } |
| 35 | |
| 36 | protected: |
| 37 | void setError(const QString& message) { m_error_message = message; }; |
| 38 | |
| 39 | protected: |
| 40 | bool m_abort = false; |
| 41 | |
| 42 | QStringList m_files_to_remove; |
| 43 | |
| 44 | private: |
| 45 | QString m_error_message; |
| 46 | }; |