summaryrefslogtreecommitdiffstats
path: root/logic/OneSixRule.h
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-09-11 23:43:17 +0200
committerPetr Mrázek <peterix@gmail.com>2013-09-11 23:43:17 +0200
commit7721c57e5e1093a3d8597b6b6f30c97d2aa3d8a5 (patch)
tree5b8e5d3401d535c9f429d1bcdaa51e6968998470 /logic/OneSixRule.h
parent108a5a677c4bf248b70e77046502ea96bd9cfe65 (diff)
downloadMultiMC-7721c57e5e1093a3d8597b6b6f30c97d2aa3d8a5.tar
MultiMC-7721c57e5e1093a3d8597b6b6f30c97d2aa3d8a5.tar.gz
MultiMC-7721c57e5e1093a3d8597b6b6f30c97d2aa3d8a5.tar.lz
MultiMC-7721c57e5e1093a3d8597b6b6f30c97d2aa3d8a5.tar.xz
MultiMC-7721c57e5e1093a3d8597b6b6f30c97d2aa3d8a5.zip
Split OneSixVersion into parts.
Diffstat (limited to 'logic/OneSixRule.h')
-rw-r--r--logic/OneSixRule.h70
1 files changed, 70 insertions, 0 deletions
diff --git a/logic/OneSixRule.h b/logic/OneSixRule.h
new file mode 100644
index 00000000..465c963f
--- /dev/null
+++ b/logic/OneSixRule.h
@@ -0,0 +1,70 @@
+#pragma once
+#include <QString>
+#include <QSharedPointer>
+
+class OneSixLibrary;
+#include "OneSixLibrary.h"
+
+enum RuleAction
+{
+ Allow,
+ Disallow,
+ Defer
+};
+
+RuleAction RuleAction_fromString(QString);
+
+class Rule
+{
+protected:
+ RuleAction m_result;
+ virtual bool applies(OneSixLibrary * parent) = 0;
+public:
+ Rule(RuleAction result)
+ :m_result(result) {}
+ virtual ~Rule(){};
+ RuleAction apply(OneSixLibrary * parent)
+ {
+ if(applies(parent))
+ return m_result;
+ else
+ return Defer;
+ };
+};
+
+class OsRule : public Rule
+{
+private:
+ // the OS
+ OpSys m_system;
+ // the OS version regexp
+ QString m_version_regexp;
+protected:
+ virtual bool applies ( OneSixLibrary* )
+ {
+ return (m_system == currentSystem);
+ }
+ OsRule(RuleAction result, OpSys system, QString version_regexp)
+ : Rule(result), m_system(system), m_version_regexp(version_regexp) {}
+public:
+ static QSharedPointer<OsRule> create(RuleAction result, OpSys system, QString version_regexp)
+ {
+ return QSharedPointer<OsRule> (new OsRule(result, system, version_regexp));
+ }
+};
+
+class ImplicitRule : public Rule
+{
+protected:
+ virtual bool applies ( OneSixLibrary* )
+ {
+ return true;
+ }
+ ImplicitRule(RuleAction result)
+ : Rule(result) {}
+public:
+ static QSharedPointer<ImplicitRule> create(RuleAction result)
+ {
+ return QSharedPointer<ImplicitRule> (new ImplicitRule(result));
+ }
+};