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 #include <dpl/dbus/dbus_client.h>
38 #include <dpl/log/log.h>
39 #include <dpl/scoped_ptr.h>
40 #include "SecuritySocketClient.h"
45 namespace WrtSecurity {
46 namespace Communication {
53 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
54 DECLARE_EXCEPTION_TYPE(Base, SecurityCommunicationClientException)
57 explicit Client(const std::string &intefaceName);
61 template<typename ... Args>
62 void call(const char* methodName, const Args& ... args)
67 #ifdef DBUS_CONNECTION
68 m_dbusClient->call(methodName, args...);
69 } Catch (DPL::DBus::Client::Exception::DBusClientException){
70 #endif //DBUS_CONNECTION
71 #ifdef SOCKET_CONNECTION
72 m_socketClient->call(methodName, args...);
73 } Catch (SecuritySocketClient::Exception::SecuritySocketClientException){
74 #endif //SOCKET_CONNECTION
75 LogError("Error getting response");
77 ReThrowMsg(Exception::SecurityCommunicationClientException,
78 "Error getting response");
80 LogInfo("Call served");
84 template<typename ...Args>
85 void call(std::string methodName, const Args&... args)
87 call(methodName.c_str(), args...);
96 std::string m_interfaceName;
97 #ifdef DBUS_CONNECTION
98 std::unique_ptr<DPL::DBus::Client> m_dbusClient;
101 #ifdef SOCKET_CONNECTION
102 std::unique_ptr<SecuritySocketClient> m_socketClient;
105 } // namespace Communication
106 } // namespace WrtSecurity
108 #endif /* SECURITYCOMMUNICATIONCLIENT_H_ */