dbus plugin updates
[profile/ivi/automotive-message-broker.git] / plugins / dbus / abstractdbusinterface.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 ABSTRACTDBUSINTERFACE_H
20 #define ABSTRACTDBUSINTERFACE_H
21
22 #include <string>
23 #include <functional>
24 #include <unordered_map>
25 #include <gio/gio.h>
26 #include <boost/any.hpp>
27
28 class AbstractProperty;
29
30 using namespace std;
31
32 class AbstractDBusInterface
33 {
34
35 public:
36         AbstractDBusInterface(string interfaceName, string objectPath);
37
38         
39         void registerObject(GDBusConnection* connection);
40         
41         void addProperty(AbstractProperty* property);
42         virtual void updateValue(AbstractProperty* property);
43         
44 protected:
45         
46         static GVariant *getProperty(GDBusConnection * connection, const gchar * sender, const gchar *objectPath,
47                                                                  const gchar *interfaceName, const gchar * propertyName, GError** error,
48                                                                  gpointer userData);
49         static gboolean setProperty(GDBusConnection * connection, const gchar * sender, const gchar *objectPath,
50                                                                 const gchar *interfaceName, const gchar * propertyName, GVariant *value,
51                                                                 GError** error, gpointer userData);
52     
53         virtual void setProperty(string propertyName, GVariant * value) = 0;
54         virtual GVariant * getProperty(string propertyName) = 0;
55         
56         unordered_map<string, AbstractProperty*> properties;
57
58 private:
59         string mInterfaceName;
60         string mObjectPath;
61         string introspectionXml;
62         GDBusConnection * mConnection;
63         static unordered_map<string, AbstractDBusInterface*> interfaceMap;
64 };
65
66 #endif // ABSTRACTDBUSINTERFACE_H