2 Copyright (C) 2012 Intel Corporation
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.
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.
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
20 #ifndef BluemonkeySink_H
21 #define BluemonkeySink_H
23 #include "abstractsource.h"
24 #include "ambpluginimpl.h"
30 #include <QJsonDocument>
32 #include <QScriptValue>
33 #include "uuidhelper.h"
35 #include "authenticate.h"
43 virtual std::map<std::string, QObject*> objects(std::map<string, string> config) = 0;
46 Q_DECLARE_INTERFACE(ModuleInterface, "org.automotive.bluemonkey.moduleinterface")
48 class Property: public QObject, public AbstractSink
51 Q_PROPERTY(QString type READ type)
52 Q_PROPERTY(QVariant value READ value WRITE setValue)
55 Property(VehicleProperty::Property, QString srcFilter, AbstractRoutingEngine* re, QObject *parent = 0);
58 void setType(QString t);
60 virtual PropertyList subscriptions() { return PropertyList(); }
61 virtual void supportedChanged(const PropertyList &)
63 DebugOut()<<"Bluemonkey Property Supported Changed"<<endl;
66 virtual void propertyChanged(AbstractPropertyType* value);
68 virtual const std::string uuid() { return mUuid; }
71 void setValue(QVariant v);
73 void getHistory(QDateTime begin, QDateTime end, QScriptValue cbFunction);
76 void changed(QVariant val);
79 AbstractPropertyType* mValue;
80 const std::string mUuid;
84 class BluemonkeySink : public QObject, public AmbPluginImpl
88 BluemonkeySink(AbstractRoutingEngine* e, map<string, string> config, AbstractSource& parent);
89 virtual PropertyList subscriptions();
90 virtual void supportedChanged(const PropertyList & supportedProperties);
91 virtual void propertyChanged(AbstractPropertyType* value);
92 virtual const std::string uuid() const;
94 QScriptEngine* engine;
96 virtual int supportedOperations();
98 private: //source privates
100 PropertyList mSupported;
101 std::list<AbstractPropertyType*> propertyValueCache;
106 QObject* subscribeTo(QString str);
107 QObject* subscribeTo(QString str, QString srcFilter);
109 QStringList sourcesForProperty(QString property);
111 QStringList supportedProperties();
113 bool authenticate(QString pass);
115 void loadConfig(QString str);
117 void loadModule(QString path);
121 void writeProgram(QString program);
123 void log(QString str);
125 void getHistory(QStringList properties, QDateTime begin, QDateTime end, QScriptValue cbFunction);
127 void setSilentMode(bool m)
132 void createCustomProperty(QString name, QScriptValue defaultValue);
135 QStringList configsToLoad;
138 BluemonkeyAgent* agent;
143 #endif // BluemonkeySink_H