Initial import to Git
[profile/ivi/common-api-dbus-runtime.git] / src / CommonAPI / DBus / DBusStubAdapter.h
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this
3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 #ifndef COMMONAPI_DBUS_DBUS_STUB_ADAPTER_H_
5 #define COMMONAPI_DBUS_DBUS_STUB_ADAPTER_H_
6
7 #include "DBusConnection.h"
8
9 #include <CommonAPI/Stub.h>
10 #include <CommonAPI/DBus/DBusMessage.h>
11
12 #include <string>
13 #include <memory>
14
15 namespace CommonAPI {
16 namespace DBus {
17
18 class DBusStubAdapter: virtual public CommonAPI::StubAdapter {
19  public:
20     DBusStubAdapter(const std::string& dbusBusName,
21                     const std::string& dbusObjectPath,
22                     const std::string& interfaceName,
23                     const std::shared_ptr<DBusProxyConnection>& dbusConnection);
24
25     virtual ~DBusStubAdapter();
26
27     virtual void init();
28
29     virtual const std::string getAddress() const;
30     virtual const std::string& getDomain() const;
31     virtual const std::string& getServiceId() const;
32     virtual const std::string& getInstanceId() const;
33
34     inline const std::string& getObjectPath() const;
35
36     inline const std::shared_ptr<DBusProxyConnection>& getDBusConnection() const;
37
38  protected:
39     virtual const char* getMethodsDBusIntrospectionXmlData() const = 0;
40     virtual bool onInterfaceDBusMessage(const DBusMessage& dbusMessage) = 0;
41
42  private:
43     bool onIntrospectionInterfaceDBusMessage(const DBusMessage& dbusMessage);
44
45     const std::string dbusBusName_;
46     const std::string dbusObjectPath_;
47     const std::string interfaceName_;
48     const std::shared_ptr<DBusProxyConnection> dbusConnection_;
49
50     bool isInitialized_;
51
52     DBusInterfaceHandlerToken dbusIntrospectionInterfaceHandlerToken_;
53     DBusInterfaceHandlerToken dbusInterfaceHandlerToken_;
54
55     static const std::string domain_;
56 };
57
58 const std::string& DBusStubAdapter::getObjectPath() const {
59     return dbusObjectPath_;
60 }
61
62 const std::shared_ptr<DBusProxyConnection>& DBusStubAdapter::getDBusConnection() const {
63     return dbusConnection_;
64 }
65
66 } // namespace dbus
67 } // namespace CommonAPI
68
69 #endif // COMMONAPI_DBUS_DBUS_STUB_ADAPTER_H_