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
34 typedef std::list<Plugin*> PluginsList;
35 typedef std::shared_ptr<PluginsList> PluginsListPtr;
36 typedef std::map< std::string, PluginsListPtr> PluginsSet;
38 class PluginRegistry : public SignalsSupport
41 DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
42 DECLARE_EXCEPTION_TYPE(Base, PluginNotFound)
44 template <typename T, typename ...Args>
45 void Call(Args... args)
50 template <typename T, typename ...Args>
51 void CallGroup(const typename CallbackSupport<T>::GroupType& type,
54 InvokeGroup<T>(type, args...);
57 void AddPlugin(const std::string& libraryName, Plugin& plugin);
60 * @throw PluginNotFound
62 Plugin* GetPlugin(const std::string& libraryName);
64 void RemovePlugin(const std::string& libraryName, Plugin& plugin);
70 bool LoadFromFile(const std::string& libraryName);
74 std::map<std::string, Plugin*> m_plugins;
75 std::map<std::string, void*> m_libraries;
78 typedef std::shared_ptr<PluginRegistry> PluginRegistryPtr;