summaryrefslogtreecommitdiffstats
path: root/tests/hawd/module.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/hawd/module.h')
-rw-r--r--tests/hawd/module.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/hawd/module.h b/tests/hawd/module.h
new file mode 100644
index 0000000..8f94707
--- /dev/null
+++ b/tests/hawd/module.h
@@ -0,0 +1,66 @@
1/*
2 * Copyright (C) 2014 Aaron Seigo <aseigo@kde.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the
16 * Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#pragma once
21
22#include "state.h"
23
24#include <QStringList>
25#include <QVector>
26
27namespace HAWD
28{
29
30class Module
31{
32public:
33 struct Syntax
34 {
35 Syntax();
36 Syntax(const QString &keyword, std::function<bool(const QStringList &, State &)> lambda = std::function<bool(const QStringList &, State &)>(), bool eventDriven = false);
37 QString keyword;
38 std::function<bool(const QStringList &, State &)> lambda;
39 QList<Syntax> children;
40 bool eventDriven;
41 };
42
43 static void addModule(const Module &module);
44 static QVector<Module> modules();
45 static bool match(const QStringList &commands, State &state);
46 static void loadModules();
47 static void printCommands();
48
49 Module();
50
51 Module::Syntax syntax() const;
52 void setSyntax(const Syntax &syntax);
53
54 QString description() const;
55 void setDescription(const QString &description);
56
57 bool matches(const QStringList &commands, State &state) const;
58
59private:
60 static void printSyntax(uint indent, const Syntax &syntax, const QString &description = QString());
61 Syntax m_syntax;
62 QString m_description;
63 static QVector<Module> s_modules;
64};
65
66} // namespace HAWD