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
19 #include <boost/lexical_cast.hpp>
21 #include "dbusplugin.h"
22 #include "abstractroutingengine.h"
23 #include "dbusinterfacemanager.h"
25 #include "listplusplus.h"
27 extern "C" AbstractSinkManager * create(AbstractRoutingEngine* routingengine, map<string, string> config)
29 return new DBusSinkManager(routingengine, config);
32 std::map<std::string, std::string> DBusSink::dbusConfig;
34 DBusSink::DBusSink(string propertyName, AbstractRoutingEngine* engine, GDBusConnection* connection, map<string, string> config = map<string, string>())
35 :AbstractDBusInterface("org.automotive."+propertyName, propertyName, connection),
36 AbstractSink(engine, dbusConfig)
38 AbstractDBusInterface::re = engine;
42 if(configuration.find("frequency") != configuration.end())
44 int t = boost::lexical_cast<int>(configuration["frequency"]);
52 void DBusSink::supportedChanged(const PropertyList &supportedProperties)
56 for(auto itr : propertyDBusMap)
58 if(contains(supportedProperties, itr->ambPropertyName()))
60 PropertyInfo info = re->getPropertyInfo(itr->ambPropertyName(), mSourceFilter);
62 if (!info.isValid() || !contains(info.zones(), zoneFilter))
67 VariantType* prop = itr;
68 prop->setSourceFilter(mSourceFilter);
69 prop->setZoneFilter(zoneFilter);
71 VehicleProperty::Property p = itr->ambPropertyName();
72 routingEngine->subscribeToProperty(p, mSourceFilter, this);
75 mTime = amb::currentTime();
80 void DBusSink::propertyChanged(AbstractPropertyType *value)
82 VehicleProperty::Property property = value->name;
84 if( value->zone != zoneFilter)
87 for(auto i : propertyDBusMap)
89 if(i->ambPropertyName() == property)
91 AbstractProperty* prop = i;
92 mTime = value->timestamp;
93 prop->updateValue(value);
99 const string DBusSink::uuid()
101 return "c2e6cafa-eef5-4b8a-99a0-0f2c9be1057d";
104 DBusSinkManager::DBusSinkManager(AbstractRoutingEngine *engine, map<string, string> config) :
105 AbstractSinkManager(engine, config),
108 manager = new DBusInterfaceManager(engine, config);
111 DBusSinkManager::~DBusSinkManager()
114 // delete manager; <-- currently AbstractSink* instances are deleted in Core::~Core()