#include "drivingsafety.h"
#include "personalization.h"
-std::map<std::string, std::map<Zone::Type, bool> > getUniqueSourcesList(AbstractRoutingEngine *re, std::list<VehicleProperty::Property> implementedProperties)
+std::map<std::string, std::map<Zone::Type, bool> > getUniqueSourcesList(AbstractRoutingEngine *re, PropertyList implementedProperties)
{
std::map<std::string, std::map<Zone::Type, bool>> uniqueSourcesList;
/// check if we need more than one instance:
- std::list<VehicleProperty::Property> implementedProperties = t->wantsProperties();
+ PropertyList implementedProperties = t->wantsProperties();
std::map<std::string, std::map<Zone::Type, bool> > uniqueSourcesList = getUniqueSourcesList(re, implementedProperties);
/// check if we need more than one instance:
- std::list<VehicleProperty::Property> implementedProperties = t->wantsProperties();
+ PropertyList implementedProperties = t->wantsProperties();
std::map<std::string, std::map<Zone::Type, bool> > uniqueSourcesList = getUniqueSourcesList(re, implementedProperties);
{
startRegistration();
- for(PropertyDBusMap::iterator itr = propertyDBusMap.begin(); itr != propertyDBusMap.end(); itr++)
+ for(auto itr : propertyDBusMap)
{
- if(contains(supportedProperties, (*itr).first))
+ if(contains(supportedProperties, itr->ambPropertyName()))
{
- VariantType* prop = (*itr).second;
+ VariantType* prop = itr;
prop->setSourceFilter(mSourceFilter);
prop->setZoneFilter(zoneFilter);
prop->initialize();
- VehicleProperty::Property p = (*itr).first;
+ VehicleProperty::Property p = itr->ambPropertyName();
routingEngine->subscribeToProperty(p, mSourceFilter, this);
addProperty(prop);
supported = true;
VehicleProperty::Property property = value->name;
- if(propertyDBusMap.find(property) == propertyDBusMap.end() || value->zone != zoneFilter)
+ if( value->zone != zoneFilter)
return;
- AbstractProperty* prop = propertyDBusMap[property];
- mTime = value->timestamp;
- prop->updateValue(value->copy());
- updateValue(prop);
+ for(auto i : propertyDBusMap)
+ {
+ if(i->ambPropertyName() == property)
+ {
+ AbstractProperty* prop = i;
+ mTime = value->timestamp;
+ prop->updateValue(value->copy());
+ updateValue(prop);
+ }
+ }
}
const string DBusSink::uuid()
#include <map>
#include <type_traits>
-typedef std::unordered_map<VehicleProperty::Property, VariantType*> PropertyDBusMap;
+typedef std::vector<VariantType*> PropertyDBusMap;
+//typedef std::unordered_map<VehicleProperty::Property, VariantType*> PropertyDBusMap;
class DBusSink : public AbstractSink, public AbstractDBusInterface
{
public:
DBusSink(std::string objectName, AbstractRoutingEngine* engine, GDBusConnection* connection, map<string, string> config);
virtual ~DBusSink() {
- for(auto itr = propertyDBusMap.begin(); itr != propertyDBusMap.end(); ++itr)
+ for(auto i : propertyDBusMap)
{
- delete itr->second;
+ delete i;
}
}
virtual void supportedChanged(const PropertyList & supportedProperties);
virtual void propertyChanged(AbstractPropertyType *value);
virtual const std::string uuid();
- std::list<VehicleProperty::Property> wantsProperties()
+ PropertyList wantsProperties()
{
- std::list<VehicleProperty::Property> l;
- for(auto itr = propertyDBusMap.begin(); itr != propertyDBusMap.end(); itr++)
+ PropertyList l;
+ for(auto i : propertyDBusMap)
{
- l.push_back((*itr).first);
+ l.push_back(i->ambPropertyName());
}
return l;
template <typename T>
void wantProperty(VehicleProperty::Property property, std::string propertyName, std::string signature, AbstractProperty::Access access)
{
- propertyDBusMap[property] = new VariantType(routingEngine, signature, property, propertyName, access);
+ //propertyDBusMap[property] = new VariantType(routingEngine, signature, property, propertyName, access);
+ propertyDBusMap.push_back( new VariantType(routingEngine, signature, property, propertyName, access));
}
void wantPropertyString(VehicleProperty::Property property, std::string propertyName, std::string signature, AbstractProperty::Access access)
{
- propertyDBusMap[property] = new VariantType(routingEngine, signature, property, propertyName, access);
+ //propertyDBusMap[property] = new VariantType(routingEngine, signature, property, propertyName, access);
+ propertyDBusMap.push_back( new VariantType(routingEngine, signature, property, propertyName, access));
}
void wantPropertyVariant(VehicleProperty::Property ambProperty, std::string propertyName, std::string signature, AbstractProperty::Access access)
{
- propertyDBusMap[ambProperty] = new VariantType(routingEngine, signature, ambProperty, propertyName, access);
+ //propertyDBusMap[ambProperty] = new VariantType(routingEngine, signature, ambProperty, propertyName, access);
+ propertyDBusMap.push_back(new VariantType(routingEngine, signature, ambProperty, propertyName, access));
}
PropertyDBusMap propertyDBusMap;