added overload for subscribe that includes a zone filter. it is unimplemented in...
authorKevron Rees <tripzero.kev@gmail.com>
Fri, 12 Jul 2013 06:44:22 +0000 (23:44 -0700)
committerKevron Rees <tripzero.kev@gmail.com>
Fri, 12 Jul 2013 06:44:22 +0000 (23:44 -0700)
ambd/core.cpp
ambd/core.h
lib/abstractroutingengine.h
plugins/bluemonkey/bluemonkey.cpp
plugins/bluemonkey/bluemonkey.h
plugins/obd2plugin/obd2source.cpp

index 83622ea..8e96bb5 100644 (file)
@@ -319,6 +319,11 @@ void Core::subscribeToProperty(VehicleProperty::Property property, string source
        subscribeToProperty(property,sink);
 }
 
+void Core::subscribeToProperty(VehicleProperty::Property, string sourceUuidFilter, Zone::Type zoneFilter, AbstractSink *self)
+{
+
+}
+
 void Core::unsubscribeToProperty(VehicleProperty::Property property, AbstractSink* self)
 {
        if(propertySinkMap.find(property) == propertySinkMap.end())
index b8aa5be..8d3ff65 100644 (file)
@@ -49,6 +49,7 @@ public:
        AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request);
        void subscribeToProperty(VehicleProperty::Property, AbstractSink* self);
        void subscribeToProperty(VehicleProperty::Property, std::string sourceUuidFilter, AbstractSink *self);
+       void subscribeToProperty(VehicleProperty::Property, std::string sourceUuidFilter, Zone::Type zoneFilter, AbstractSink *self);
        void unsubscribeToProperty(VehicleProperty::Property, AbstractSink* self);
        PropertyList supported() { return mMasterPropertyList; }
 
index 47eeec4..e3439ed 100644 (file)
@@ -236,6 +236,7 @@ public:
        virtual AsyncPropertyReply * setProperty(AsyncSetPropertyRequest request) = 0;
        virtual void subscribeToProperty(VehicleProperty::Property, AbstractSink* self) = 0;
        virtual void subscribeToProperty(VehicleProperty::Property, std::string sourceUuidFilter, AbstractSink *self) = 0;
+       virtual void subscribeToProperty(VehicleProperty::Property, std::string sourceUuidFilter, Zone::Type zoneFilter, AbstractSink *self) = 0;
        virtual void unsubscribeToProperty(VehicleProperty::Property, AbstractSink* self) = 0;
 
        virtual PropertyInfo getPropertyInfo(VehicleProperty::Property, std::string sourceUuid) = 0;
index e04c4f5..4ab6af8 100644 (file)
@@ -152,9 +152,27 @@ std::string BluemonkeySink::uuid()
 
 QObject *BluemonkeySink::subscribeTo(QString str)
 {
-       return new Property(str.toStdString(), routingEngine, this);
+       return new Property(str.toStdString(), "", routingEngine, this);
 }
 
+QObject *BluemonkeySink::subscribeTo(QString str, QString srcFilter)
+{
+       return new Property(str.toStdString(), srcFilter, routingEngine, this);
+}
+
+QStringList BluemonkeySink::sourcesForProperty(QString property)
+{
+       std::list<std::string> list = routingEngine->sourcesForProperty(property.toStdString());
+       QStringList strList;
+       for(auto itr = list.begin(); itr != list.end(); itr++)
+       {
+               strList<<(*itr).c_str();
+       }
+
+       return strList;
+}
+
+
 bool BluemonkeySink::authenticate(QString pass)
 {
 
@@ -269,7 +287,7 @@ void Property::setValue(QVariant v)
        routingEngine->setProperty(request);
 }
 
-Property::Property(VehicleProperty::Property prop, AbstractRoutingEngine* re, QObject *parent)
+Property::Property(VehicleProperty::Property prop, QString srcFilter, AbstractRoutingEngine* re, QObject *parent)
        :QObject(parent), AbstractSink(re, std::map<std::string,std::string>()),mValue(nullptr)
 {
        setType(prop.c_str());
@@ -304,6 +322,10 @@ void Property::setType(QString t)
 
 void Property::propertyChanged(VehicleProperty::Property property, AbstractPropertyType *value, string uuid)
 {
+       if(mValue)
+       {
+               delete mValue;
+       }
        mValue = value->copy();
 
        changed(gvariantToQVariant(mValue->toVariant()));
index e82ac73..4f63c20 100644 (file)
@@ -38,12 +38,12 @@ class Property: public QObject, public AbstractSink
        Q_PROPERTY(QVariant value READ value WRITE setValue)
 
 public:
-       Property(VehicleProperty::Property, AbstractRoutingEngine* re, QObject *parent = 0);
+       Property(VehicleProperty::Property, QString srcFilter, AbstractRoutingEngine* re, QObject *parent = 0);
 
        QString type();
        void setType(QString t);
 
-       virtual PropertyList subscriptions() { PropertyList list; list.push_back(type().toStdString()); return list; }
+       virtual PropertyList subscriptions() { return PropertyList(); }
        virtual void supportedChanged(PropertyList ){   }
 
        virtual void propertyChanged(VehicleProperty::Property property, AbstractPropertyType* value, std::string uuid);
@@ -75,6 +75,9 @@ public:
 public Q_SLOTS:
 
        QObject* subscribeTo(QString str);
+       QObject* subscribeTo(QString str, QString srcFilter);
+
+       QStringList sourcesForProperty(QString property);
 
        bool authenticate(QString pass);
 
index ba24f26..b27e0ca 100644 (file)
@@ -488,7 +488,13 @@ void OBD2Source::updateProperty(VehicleProperty::Property property,AbstractPrope
        {
                propertyReplyMap[property]->value = value;
                propertyReplyMap[property]->success = true;
-               propertyReplyMap[property]->completed(propertyReplyMap[property]);
+               try {
+                       propertyReplyMap[property]->completed(propertyReplyMap[property]);
+               }catch(...)
+               {
+                       DebugOut(DebugOut::Error)<<"failed to call reply completed callback"<<endl;
+               }
+
                propertyReplyMap.erase(property);
        }
        else