Added a function to get an instance's type.
This commit is contained in:
parent
36396f7c6a
commit
69040f923b
@ -22,6 +22,7 @@
|
|||||||
#include <settingsobject.h>
|
#include <settingsobject.h>
|
||||||
|
|
||||||
#include "inifile.h"
|
#include "inifile.h"
|
||||||
|
#include "instancetypeinterface.h"
|
||||||
|
|
||||||
#include "libmmc_config.h"
|
#include "libmmc_config.h"
|
||||||
|
|
||||||
@ -251,6 +252,16 @@ public:
|
|||||||
QString modListFile() const;
|
QString modListFile() const;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////// INSTANCE TYPE STUFF ////////
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns a pointer to this instance's type.
|
||||||
|
* \return A pointer to this instance's type interface.
|
||||||
|
*/
|
||||||
|
virtual const InstanceTypeInterface *instanceType() const = 0;
|
||||||
|
|
||||||
|
|
||||||
//////// OTHER FUNCTIONS ////////
|
//////// OTHER FUNCTIONS ////////
|
||||||
|
|
||||||
//// Version System ////
|
//// Version System ////
|
||||||
|
@ -21,11 +21,12 @@
|
|||||||
|
|
||||||
#include <javautils.h>
|
#include <javautils.h>
|
||||||
|
|
||||||
StdInstance::StdInstance(const QString &rootDir, QObject *parent) :
|
StdInstance::StdInstance(const QString &rootDir, const InstanceTypeInterface *iType, QObject *parent) :
|
||||||
Instance(rootDir, parent)
|
Instance(rootDir, parent)
|
||||||
{
|
{
|
||||||
settings().registerSetting(new Setting("lastVersionUpdate", 0));
|
m_instType = iType;
|
||||||
|
|
||||||
|
settings().registerSetting(new Setting("lastVersionUpdate", 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StdInstance::shouldUpdateCurrentVersion()
|
bool StdInstance::shouldUpdateCurrentVersion()
|
||||||
@ -55,3 +56,8 @@ void StdInstance::updateCurrentVersion(bool keepCurrent)
|
|||||||
setCurrentVersion(newVersion);
|
setCurrentVersion(newVersion);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const InstanceTypeInterface *StdInstance::instanceType() const
|
||||||
|
{
|
||||||
|
return m_instType;
|
||||||
|
}
|
||||||
|
@ -22,15 +22,20 @@ class StdInstance : public Instance
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit StdInstance(const QString &rootDir, QObject *parent = 0);
|
explicit StdInstance(const QString &rootDir, const InstanceTypeInterface *iType, QObject *parent = 0);
|
||||||
|
|
||||||
virtual bool shouldUpdateCurrentVersion();
|
virtual bool shouldUpdateCurrentVersion();
|
||||||
|
|
||||||
virtual void updateCurrentVersion(bool keepCurrent);
|
virtual void updateCurrentVersion(bool keepCurrent);
|
||||||
|
|
||||||
|
virtual const InstanceTypeInterface *instanceType() const;
|
||||||
|
|
||||||
////// TIMESTAMPS //////
|
////// TIMESTAMPS //////
|
||||||
virtual qint64 lastVersionUpdate() { return settings().get("lastVersionUpdate").value<qint64>(); }
|
virtual qint64 lastVersionUpdate() { return settings().get("lastVersionUpdate").value<qint64>(); }
|
||||||
virtual void setLastVersionUpdate(qint64 val) { settings().set("lastVersionUpdate", val); }
|
virtual void setLastVersionUpdate(qint64 val) { settings().set("lastVersionUpdate", val); }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const InstanceTypeInterface *m_instType;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // STDINSTANCE_H
|
#endif // STDINSTANCE_H
|
||||||
|
@ -36,7 +36,7 @@ InstanceLoader::InstTypeError StdInstanceType::createInstance(Instance *&inst,
|
|||||||
return InstanceLoader::CantCreateDir;
|
return InstanceLoader::CantCreateDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
StdInstance *stdInst = new StdInstance(instDir);
|
StdInstance *stdInst = new StdInstance(instDir, this);
|
||||||
|
|
||||||
// TODO: Verify that the instance is valid.
|
// TODO: Verify that the instance is valid.
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ InstanceLoader::InstTypeError StdInstanceType::createInstance(Instance *&inst,
|
|||||||
InstanceLoader::InstTypeError StdInstanceType::loadInstance(Instance *&inst,
|
InstanceLoader::InstTypeError StdInstanceType::loadInstance(Instance *&inst,
|
||||||
const QString &instDir) const
|
const QString &instDir) const
|
||||||
{
|
{
|
||||||
StdInstance *stdInst = new StdInstance(instDir);
|
StdInstance *stdInst = new StdInstance(instDir, this);
|
||||||
|
|
||||||
// TODO: Verify that the instance is valid.
|
// TODO: Verify that the instance is valid.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user