aboutsummaryrefslogtreecommitdiff
path: root/launcher/InstanceCreationTask.h
blob: 68c5de596b1c2357d26902d1000275dfe3c7faf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once

#include "BaseVersion.h"
#include "InstanceTask.h"

class InstanceCreationTask : public InstanceTask {
    Q_OBJECT
   public:
    InstanceCreationTask();
    virtual ~InstanceCreationTask() = default;

   protected:
    void executeTask() final override;

    /**
     * Tries to update an already existing instance.
     *
     * This can be implemented by subclasses to provide a way of updating an already existing
     * instance, according to that implementation's concept of 'identity' (i.e. instances that
     * are updates / downgrades of one another).
     *
     * If this returns true, createInstance() will not run, so you should do all update steps in here.
     * Otherwise, createInstance() is run as normal.
     */
    virtual bool updateInstance() { return false; };

    /**
     * Creates a new instance.
     *
     * Returns whether the instance creation was successful (true) or not (false).
     */
    virtual bool createInstance() { return false; };

    QString getError() const { return m_error_message; }

   protected:
    void setError(QString message) { m_error_message = message; };

   private:
    QString m_error_message;
};