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 PluginRegistry.h
18 * @author Grzegorz Krawczyk (g.krawczyk@samgsung.com)
22 #ifndef _WRT_PLUGINS_COMMON_PLUGIN_LOADING_PLUGIN_REGISTRY_H_
23 #define _WRT_PLUGINS_COMMON_PLUGIN_LOADING_PLUGIN_REGISTRY_H_
27 #include "SignalsSupport.h"
29 #include <dpl/exception.h>
31 namespace WrtPluginsApi {
32 typedef std::list<Plugin*> PluginsList;
33 typedef std::shared_ptr<PluginsList> PluginsListPtr;
34 typedef std::map< std::string, PluginsListPtr> PluginsSet;
36 class PluginRegistry : public SignalsSupport
39 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
40 DECLARE_EXCEPTION_TYPE(Base, PluginNotFound)
42 template <typename T, typename ... Args>
43 void Call(Args ... args)
48 template <typename T, typename ... Args>
49 void CallGroup(const typename CallbackSupport<T>::GroupType& type,
52 InvokeGroup<T>(type, args ...);
55 void AddPlugin(const std::string& libraryName, Plugin& plugin);
58 * @throw PluginNotFound
60 Plugin* GetPlugin(const std::string& libraryName);
62 void RemovePlugin(const std::string& libraryName, Plugin& plugin);
69 bool LoadFromFile(const std::string& libraryName);
73 std::map<std::string, Plugin*> m_plugins;
74 std::map<std::string, void*> m_libraries;
77 typedef std::shared_ptr<PluginRegistry> PluginRegistryPtr;