multiple dbus properties can support the same amb property submit/tizen_ivi/20140612.220211
authorKevron Rees <kevron.m.rees@intel.com>
Thu, 12 Jun 2014 18:29:41 +0000 (11:29 -0700)
committerKevron Rees <kevron.m.rees@intel.com>
Thu, 12 Jun 2014 18:29:41 +0000 (11:29 -0700)
plugins/dbus/custompropertyinterface.cpp
plugins/dbus/dbusinterfacemanager.cpp
plugins/dbus/dbusplugin.cpp
plugins/dbus/dbusplugin.h
plugins/dbus/uncategorizedproperty.cpp

index 1769a59..de688a5 100644 (file)
@@ -21,7 +21,7 @@ CustomPropertyInterface::CustomPropertyInterface(VehicleProperty::Property prop,
                std::string signature = g_variant_get_type_string(var);
                g_variant_unref(var);
 
-               propertyDBusMap[prop] = new VariantType(re, signature, prop, prop, VariantType::ReadWrite);
+               propertyDBusMap.push_back( new VariantType(re, signature, prop, prop, VariantType::ReadWrite));
 
                delete temp;
        }
index 968b74f..1357244 100644 (file)
@@ -36,7 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 #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;
 
@@ -84,7 +84,7 @@ void exportProperty(AbstractRoutingEngine *re, GDBusConnection *connection)
 
        /// 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);
 
@@ -122,7 +122,7 @@ void exportProperty(VehicleProperty::Property prop, AbstractRoutingEngine *re, G
 
        /// 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);
 
index 0dcf8bd..a5f12b3 100644 (file)
@@ -51,15 +51,15 @@ void DBusSink::supportedChanged(const PropertyList &supportedProperties)
 {
        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;
@@ -74,13 +74,19 @@ void DBusSink::propertyChanged(AbstractPropertyType *value)
 
        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()
index b7c4b21..23eb047 100644 (file)
@@ -27,7 +27,8 @@
 #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
 {
@@ -35,21 +36,21 @@ 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;
@@ -69,18 +70,21 @@ protected:
        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;
index 32d46e6..6351c23 100644 (file)
@@ -17,7 +17,7 @@ UncategorizedPropertyInterface::UncategorizedPropertyInterface(VehicleProperty::
        std::string signature = g_variant_get_type_string(var);
        g_variant_unref(var);
 
-       propertyDBusMap[prop] = new VariantType(re, signature, prop, prop, VariantType::ReadWrite);
+       propertyDBusMap.push_back( new VariantType(re, signature, prop, prop, VariantType::ReadWrite));
 
        delete temp;