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 IPluginRegistry.h
18 * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
23 #ifndef _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_SIGNALS_SUPPORT_H_
24 #define _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_SIGNALS_SUPPORT_H_
28 #include "CallbackSupport.h"
30 #include "PluginSignals.h"
33 namespace WrtPluginsApi
39 virtual ~SignalsSupport() {}
42 void Connect(const std::string& libraryName, const typename T::Type& slot)
44 Tuple::get_by_type<CallbackSupport<T>>(m_slots).Connect(libraryName,
48 void Disconnect(const std::string& libraryName)
50 DisconnectGroup(m_slots, libraryName);
53 virtual void AddPlugin(const std::string& libraryName, Plugin& plugin) = 0;
56 template<typename T, typename ...Args>
57 void Invoke(const Args&... args)
59 Tuple::get_by_type<CallbackSupport<T>>(m_slots).Invoke(args...);
62 template<typename T, typename ...Args>
63 void InvokeGroup(const std::string& libraryName, const Args&... args)
65 Tuple::get_by_type<CallbackSupport<T>>(m_slots).InvokeGroup(libraryName,
70 template<int N, typename ...Args>
71 void DisconnectSlot(std::tuple<Args...>& slots,
72 const std::string& libraryName,
73 typename std::enable_if<(N >= 0)>::type* = NULL)
75 std::get<N>(slots).Disconnect(libraryName);
76 DisconnectSlot<N-1>(slots, libraryName);
79 template<int N, typename ...Args>
80 void DisconnectSlot(std::tuple<Args...>& slots,
81 const std::string& libraryName,
82 typename std::enable_if<(N == -1)>::type* = NULL)
86 template<typename ...Args>
87 void DisconnectGroup(std::tuple<Args...>& slots,
88 const std::string& libraryName)
90 DisconnectSlot<sizeof...(Args)-1>(slots, libraryName);
93 std::tuple<CallbackSupport<OnWidgetStart>,
94 CallbackSupport<OnWidgetStop>,
95 CallbackSupport<OnFrameLoad>,
96 CallbackSupport<OnFrameUnload>> m_slots;