fixed frequency option in dbus plugin
[profile/ivi/automotive-message-broker.git] / plugins / dbus / dbusplugin.h
1 /*
2         Copyright (C) 2012  Intel Corporation
3
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.
8
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.
13
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
17 */
18
19 #ifndef DBUSSINK_H_
20 #define DBUSSINK_H_
21
22 #include "abstractsink.h"
23 #include "abstractproperty.h"
24 #include "abstractdbusinterface.h"
25 #include "varianttype.h"
26
27 #include <map>
28 #include <type_traits>
29
30 typedef std::vector<VariantType*> PropertyDBusMap;
31 //typedef std::unordered_map<VehicleProperty::Property, VariantType*> PropertyDBusMap;
32
33 class DBusSink : public AbstractSink, public AbstractDBusInterface
34 {
35
36 public:
37         DBusSink(std::string objectName, AbstractRoutingEngine* engine, GDBusConnection* connection, map<string, string> config);
38         virtual ~DBusSink()
39         {
40                 for(auto i : propertyDBusMap)
41                 {
42                         delete i;
43                 }
44         }
45         virtual void supportedChanged(const PropertyList & supportedProperties);
46         virtual void propertyChanged(AbstractPropertyType *value);
47         virtual const std::string uuid();
48
49         static std::map<std::string, std::string> dbusConfig;
50
51         PropertyList wantsProperties()
52         {
53                 PropertyList l;
54                 for(auto i : propertyDBusMap)
55                 {
56                         l.push_back(i->ambPropertyName());
57                 }
58
59                 return l;
60         }
61
62         void setSourceFilter(std::string sourceFilter)
63         {
64                 mSourceFilter = sourceFilter;
65         }
66
67         void setZoneFilter(Zone::Type zone)
68         {
69                 zoneFilter = zone;
70         }
71
72 protected:
73         template <typename T>
74         void wantProperty(VehicleProperty::Property property, std::string propertyName, std::string signature, AbstractProperty::Access access)
75         {
76                 //propertyDBusMap[property] = new VariantType(routingEngine, signature, property, propertyName, access);
77                 propertyDBusMap.push_back( new VariantType(routingEngine, signature, property, propertyName, access));
78         }
79
80
81         void wantPropertyString(VehicleProperty::Property property, std::string propertyName, std::string signature, AbstractProperty::Access access)
82         {
83                 //propertyDBusMap[property] = new VariantType(routingEngine, signature, property, propertyName, access);
84                 propertyDBusMap.push_back( new VariantType(routingEngine, signature, property, propertyName, access));
85         }
86
87         void wantPropertyVariant(VehicleProperty::Property ambProperty, std::string propertyName, std::string signature, AbstractProperty::Access access)
88         {
89                 //propertyDBusMap[ambProperty] = new VariantType(routingEngine, signature, ambProperty, propertyName, access);
90                 propertyDBusMap.push_back(new VariantType(routingEngine, signature, ambProperty, propertyName, access));
91         }
92
93         PropertyDBusMap propertyDBusMap;
94
95
96
97 };
98
99 class DBusInterfaceManager;
100 class DBusSinkManager: public AbstractSinkManager
101 {
102         DBusInterfaceManager* manager;
103 public:
104         DBusSinkManager(AbstractRoutingEngine* engine, map<string, string> config);
105         ~DBusSinkManager();
106 };
107
108 #endif