2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 * @file SecurityCommunicationClient.h
18 * @author Zofia Abramowska (z.abramowska@samsung.com)
20 * @brief This is header of class used by IPC client with implemented templates
25 * This class hides implementation of specific communication types
26 * and enables switching between them by #defined macros.
28 * supported types : DBUS_CONNECTION
30 * IMPORTANT : Exactly ONE type MUST be defined.
34 #ifndef SECURITYCOMMUNICATIONCLIENT_H_
35 #define SECURITYCOMMUNICATIONCLIENT_H_
37 #ifdef DBUS_CONNECTION
38 #include <dpl/dbus/dbus_client.h>
40 #include <dpl/log/log.h>
41 #include "SecuritySocketClient.h"
46 namespace WrtSecurity {
47 namespace Communication {
54 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
55 DECLARE_EXCEPTION_TYPE(Base, SecurityCommunicationClientException)
58 explicit Client(const std::string &intefaceName);
62 template<typename ... Args>
63 void call(const char* methodName, const Args& ... args)
68 #ifdef DBUS_CONNECTION
69 m_dbusClient->call(methodName, args...);
70 } Catch (DPL::DBus::Client::Exception::DBusClientException){
71 #endif //DBUS_CONNECTION
72 #ifdef SOCKET_CONNECTION
73 m_socketClient->call(methodName, args...);
74 } Catch (SecuritySocketClient::Exception::SecuritySocketClientException){
75 #endif //SOCKET_CONNECTION
76 LogError("Error getting response");
78 ReThrowMsg(Exception::SecurityCommunicationClientException,
79 "Error getting response");
81 LogInfo("Call served");
85 template<typename ...Args>
86 void call(std::string methodName, const Args&... args)
88 call(methodName.c_str(), args...);
97 std::string m_interfaceName;
98 #ifdef DBUS_CONNECTION
99 std::unique_ptr<DPL::DBus::Client> m_dbusClient;
102 #ifdef SOCKET_CONNECTION
103 std::unique_ptr<SecuritySocketClient> m_socketClient;
106 } // namespace Communication
107 } // namespace WrtSecurity
109 #endif /* SECURITYCOMMUNICATIONCLIENT_H_ */