automotive-message-broker  0.14.803
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
bluemonkey.h
1 /*
2  Copyright (C) 2012 Intel Corporation
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library 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 GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18 
19 
20 #ifndef Bluemonkey_H
21 #define Bluemonkey_H
22 
23 #include <map>
24 
25 #include <QObject>
26 #include <QVariant>
27 #include <QJsonDocument>
28 #include <QDateTime>
29 #include <QJSValue>
30 #include <QCoreApplication>
31 
32 #include "authenticate.h"
33 
34 class QJSEngine;
35 
36 class Bluemonkey : public QObject
37 {
38  Q_OBJECT
39  Q_PROPERTY(QStringList arguments READ arguments)
40 
41 public:
42  Bluemonkey(QObject * parent = nullptr);
43 
44  ~Bluemonkey();
45 
46  bool loadModule(const QString &name, QObject* module);
47 
48  QStringList arguments() { return mArguments;}
49  void setArguments(const QStringList & args) { mArguments = args; }
50  void setArguments(int len, char **args);
51 
52 public Q_SLOTS:
53 
54  void assertIsTrue(bool isTrue, const QString &msg="");
55 
56  void loadScript(QString str);
57 
58  bool loadModule(QString path);
59 
60  void writeProgram(QString program);
61 
62  void log(QJSValue str);
63 
64  QObject* createTimer();
65  QObject* createQObject();
66 
67  QObject* createCoreApplication();
68 
69  int run(QCoreApplication *app);
70 
71 Q_SIGNALS:
72 
73  void ready();
74 
75 private:
76  QList<void*> modules;
77  QJSEngine* engine;
78  QStringList configsToLoad;
79  QStringList mArguments;
80  std::map<std::string, std::string> configuration;
81 };
82 
83 #endif // Bluemonkey_H