1 //******************************************************************
3 // Copyright 2014 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
21 /// @file PluginManagerImpl.h
23 /// @brief PluginManagerImple provides abstraction of the plugin manager interface
25 #ifndef __PLUGINMANAGERIMPL_H__
26 #define __PLUGINMANAGERIMPL_H__
29 #include "CpluffAdapter.h"
32 #include "FelixAdapter.h"
37 class PluginManagerImpl
42 * Constructor for PluginManagerImpl.
43 * During construction time, all plugins under the root plugin path will be loaded.
46 PluginManagerImpl(void *args);
51 virtual ~PluginManagerImpl(void);
55 * A function to register pluins in the path.
56 * This function will load plugins in plugin manager table.
58 * @param path plugin file path to be registered.
59 * @return int, 1 is success, 0 is fail.
64 int registerPlugin(std::string path);
68 * A function to register pluins in the path.
69 * This function will load plugins in plugin manager table.
71 * @param path plugin file path to be registered.
72 * recursive load plugins sub folders recursively.
73 * @return int, 1 is success, 0 is fail.
78 int registerAllPlugin(std::string path);
83 * @param plugin plugin object to be unregistered.
84 * @return int, 1 is success, 0 is fail.
86 int unregisterPlugin(std::string path);
89 * Unregister All plugin.
91 * @return int, 1 is success, 0 is fail.
93 int unregisterAllPlugin(void);
96 * find plugins which have the key and value
98 * @return vector of currently registered plugins
100 std::vector<Plugin> *findPlugins(const std::string key, const std::string value);
103 * Get plugin which has the id
105 * @param pluginID plugin id to find
106 * @return Plugin instance
108 Plugin *getPlugin(const std::string pluginID);
111 * Check whether the plugin started or not
113 * @param Plugin to identify the Starting.
114 * @return true if started, false is stop.
117 bool isStarted(Plugin *plugin);
123 * @return Plugin state.
125 virtual std::string getState(const std::string plugID);
128 * Start plugins by resource type
130 * @param type resouce type string to be started.
133 virtual int startPlugins(const std::string key, const std::string value);
136 * Stop plugins by resource type
138 * @param type resouce type string to be started.
141 virtual int stopPlugins(const std::string key, const std::string value);
145 * This function will load dynamic plugin library on memory and call start function of plugin to be initialized.
148 * @return int, 1 is success, 0 is fail.
150 int startPlugins(Plugin *const plugin);
155 * This function will call stop function of plugin and unload dynamic plugin library from memory.
158 * @return int, 1 is success, 0 is fail.
160 int stopPlugins(Plugin *const plugin);
164 * This function will call rescan function of plugins in the configuration folder
167 * @return int, 1 is success, 0 is fail.
169 virtual int rescanPlugin();
172 * get all plugins which currently registered.
174 * @return vector of currently registered plugins
177 virtual std::vector<Plugin> &getAllPlugins(void);
179 static PluginManagerImpl *Getinstance(void *args)
181 if (NULL == s_pinstance)
183 s_pinstance = new PluginManagerImpl(args);
194 FelixAdapter *javappm;
197 std::vector<Plugin> m_plugins;
198 static PluginManagerImpl *s_pinstance;
200 static void deleteinstance()
202 if (NULL != s_pinstance)
210 * refresh All Plugin information.
212 * @return vector<Plugin> is all Plugin.
214 std::vector<Plugin> refreshPluginInfo();
217 * Start plugin by platform.
218 * This function will load dynamic plugin library on memory and call start function of plugin to be initialized.
221 * @param Platform pointer.
222 * @return int, 1 is success, 0 is fail.
224 int startbyPlatform(Plugin *const plugin, void *const arg);
227 * Stop Plugin by platform.
228 * This function will call stop function of plugin and unload dynamic plugin library from memory.
231 * @return int, 1 is success, 0 is fail.
233 int stopbyPlatform(Plugin *const plugin);
237 #endif //__PLUGINMANAGERIMPL_H__