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"
28 #include <QJsonDocument>
30 #include <QScriptValue>
31 #include "uuidhelper.h"
33 #include "authenticate.h"
36 class IrcCommunication;
39 class Property: public QObject, public AbstractSink
42 Q_PROPERTY(QString type READ type)
43 Q_PROPERTY(QVariant value READ value WRITE setValue)
46 Property(VehicleProperty::Property, QString srcFilter, AbstractRoutingEngine* re, QObject *parent = 0);
49 void setType(QString t);
51 virtual PropertyList subscriptions() { return PropertyList(); }
52 virtual void supportedChanged(const PropertyList &)
54 DebugOut()<<"Bluemonkey Property Supported Changed"<<endl;
57 virtual void propertyChanged(AbstractPropertyType* value);
59 virtual const std::string uuid() { return mUuid; }
62 void setValue(QVariant v);
64 void getHistory(QDateTime begin, QDateTime end, QScriptValue cbFunction);
67 void changed(QVariant val);
70 AbstractPropertyType* mValue;
71 const std::string mUuid;
75 class BluemonkeySink : public QObject, public AmbPluginImpl
79 BluemonkeySink(AbstractRoutingEngine* e, map<string, string> config, AbstractSource& parent);
80 virtual PropertyList subscriptions();
81 virtual void supportedChanged(const PropertyList & supportedProperties);
82 virtual void propertyChanged(AbstractPropertyType* value);
83 virtual const std::string uuid() const;
85 QScriptEngine* engine;
87 virtual int supportedOperations();
89 private: //source privates
91 PropertyList mSupported;
92 std::list<AbstractPropertyType*> propertyValueCache;
97 QObject* subscribeTo(QString str);
98 QObject* subscribeTo(QString str, QString srcFilter);
100 QStringList sourcesForProperty(QString property);
102 QStringList supportedProperties();
104 bool authenticate(QString pass);
106 void loadConfig(QString str);
110 void writeProgram(QString program);
112 void log(QString str);
114 void getHistory(QStringList properties, QDateTime begin, QDateTime end, QScriptValue cbFunction);
116 void setSilentMode(bool m)
121 void createCustomProperty(QString name, QScriptValue defaultValue);
124 QStringList configsToLoad;
125 IrcCommunication* irc;
128 BluemonkeyAgent* agent;
133 #endif // BluemonkeySink_H