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 {
37 virtual ~SignalsSupport() {}
40 void Connect(const std::string& libraryName, const typename T::Type& slot)
42 Tuple::get_by_type<CallbackSupport<T> >(m_slots).Connect(libraryName,
46 void Disconnect(const std::string& libraryName)
48 DisconnectGroup(m_slots, libraryName);
51 virtual void AddPlugin(const std::string& libraryName, Plugin& plugin) = 0;
54 template<typename T, typename ... Args>
55 void Invoke(const Args& ... args)
57 Tuple::get_by_type<CallbackSupport<T> >(m_slots).Invoke(args ...);
60 template<typename T, typename ... Args>
61 void InvokeGroup(const std::string& libraryName, const Args& ... args)
63 Tuple::get_by_type<CallbackSupport<T> >(m_slots).InvokeGroup(
69 template<int N, typename ... Args>
70 void DisconnectSlot(std::tuple<Args ...>& slots,
71 const std::string& libraryName,
72 typename std::enable_if<(N >= 0)>::type* = NULL)
74 std::get<N>(slots).Disconnect(libraryName);
75 DisconnectSlot<N - 1>(slots, libraryName);
78 template<int N, typename ... Args>
79 void DisconnectSlot(std::tuple<Args ...>& /*slots*/,
80 const std::string& /*libraryName*/,
81 typename std::enable_if<(N == -1)>::type* = NULL)
84 template<typename ... Args>
85 void DisconnectGroup(std::tuple<Args ...>& slots,
86 const std::string& libraryName)
88 DisconnectSlot<sizeof ... (Args)-1>(slots, libraryName);
91 std::tuple<CallbackSupport<OnWidgetStart>,
92 CallbackSupport<OnWidgetStop>,
93 CallbackSupport<OnFrameLoad>,
94 CallbackSupport<OnFrameUnload> > m_slots;