sneedmc/api/logic/BaseInstanceProvider.h

58 lines
1.3 KiB
C
Raw Normal View History

2016-10-02 22:55:54 +00:00
#pragma once
#include <QObject>
#include <QString>
#include "BaseInstance.h"
#include "settings/SettingsObject.h"
#include "multimc_logic_export.h"
using InstanceId = QString;
using InstanceLocator = std::pair<InstancePtr, int>;
enum class InstCreateError
{
2018-07-15 12:51:05 +00:00
NoCreateError = 0,
NoSuchVersion,
UnknownCreateError,
InstExists,
CantCreateDir
2016-10-02 22:55:54 +00:00
};
class MULTIMC_LOGIC_EXPORT BaseInstanceProvider : public QObject
{
2018-07-15 12:51:05 +00:00
Q_OBJECT
2016-10-02 22:55:54 +00:00
public:
2018-07-15 12:51:05 +00:00
BaseInstanceProvider(SettingsObjectPtr settings) : m_globalSettings(settings)
{
// nil
}
2016-10-02 22:55:54 +00:00
public:
2018-07-15 12:51:05 +00:00
virtual QList<InstanceId> discoverInstances() = 0;
virtual InstancePtr loadInstance(const InstanceId &id) = 0;
virtual void loadGroupList() = 0;
virtual void saveGroupList() = 0;
virtual QString getStagedInstancePath()
{
return QString();
}
virtual bool commitStagedInstance(const QString & path, const QString& instanceName, const QString & groupName)
{
return false;
}
virtual bool destroyStagingPath(const QString & path)
{
return true;
}
2016-10-02 22:55:54 +00:00
signals:
2018-07-15 12:51:05 +00:00
// Emit this when the list of provided instances changed
void instancesChanged();
// Emit when the set of groups your provider supplies changes.
void groupsChanged(QSet<QString> groups);
2016-10-02 22:55:54 +00:00
protected:
2018-07-15 12:51:05 +00:00
SettingsObjectPtr m_globalSettings;
2016-10-02 22:55:54 +00:00
};