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"
33 #include "FelixAdapter.h"
38 class PluginManagerImpl
43 * Constructor for PluginManagerImpl.
44 * During construction time, all plugins under the root plugin path will be loaded.
47 PluginManagerImpl(void *args);
52 virtual ~PluginManagerImpl(void);
56 * A function to register pluins in the path.
57 * This function will load plugins in plugin manager table.
59 * @param path plugin file path to be registered.
60 * @return int, 1 is success, 0 is fail.
65 int registerPlugin(std::string path);
69 * A function to register pluins in the path.
70 * This function will load plugins in plugin manager table.
72 * @param path plugin file path to be registered.
73 * recursive load plugins sub folders recursively.
74 * @return int, 1 is success, 0 is fail.
79 int registerAllPlugin(std::string path);
84 * @param plugin plugin object to be unregistered.
85 * @return int, 1 is success, 0 is fail.
87 int unregisterPlugin(std::string path);
90 * Unregister All plugin.
92 * @return int, 1 is success, 0 is fail.
94 int unregisterAllPlugin(void);
97 * find plugins which have the key and value
99 * @return vector of currently registered plugins
101 std::vector<Plugin> *findPlugins(const std::string key, const std::string value);
104 * Get plugin which has the id
106 * @param pluginID plugin id to find
107 * @return Plugin instance
109 Plugin *getPlugin(const std::string pluginID);
112 * Check whether the plugin started or not
114 * @param Plugin to identify the Starting.
115 * @return true if started, false is stop.
118 bool isStarted(Plugin *plugin);
124 * @return Plugin state.
126 virtual std::string getState(const std::string plugID);
129 * Start plugins by resource type
131 * @param type resouce type string to be started.
134 virtual int startPlugins(const std::string key, const std::string value);
137 * Stop plugins by resource type
139 * @param type resouce type string to be started.
142 virtual int stopPlugins(const std::string key, const std::string value);
146 * This function will load dynamic plugin library on memory and call start function of plugin to be initialized.
149 * @return int, 1 is success, 0 is fail.
151 int startPlugins(Plugin *const plugin);
156 * This function will call stop function of plugin and unload dynamic plugin library from memory.
159 * @return int, 1 is success, 0 is fail.
161 int stopPlugins(Plugin *const plugin);
165 * This function will call rescan function of plugins in the configuration folder
168 * @return int, 1 is success, 0 is fail.
170 virtual int rescanPlugin();
173 * get all plugins which currently registered.
175 * @return vector of currently registered plugins
178 virtual std::vector<Plugin> &getAllPlugins(void);
180 static PluginManagerImpl *Getinstance(void *args)
182 if (NULL == s_pinstance)
184 s_pinstance = new PluginManagerImpl(args);
195 FelixAdapter *javappm;
198 std::vector<Plugin> m_plugins;
199 static PluginManagerImpl *s_pinstance;
201 static void deleteinstance()
203 if (NULL != s_pinstance)
211 * refresh All Plugin information.
213 * @return vector<Plugin> is all Plugin.
215 std::vector<Plugin> refreshPluginInfo();
218 * Start plugin by platform.
219 * This function will load dynamic plugin library on memory and call start function of plugin to be initialized.
222 * @param Platform pointer.
223 * @return int, 1 is success, 0 is fail.
225 int startbyPlatform(Plugin *const plugin, void *const arg);
228 * Stop Plugin by platform.
229 * This function will call stop function of plugin and unload dynamic plugin library from memory.
232 * @return int, 1 is success, 0 is fail.
234 int stopbyPlatform(Plugin *const plugin);
238 #endif //__PLUGINMANAGERIMPL_H__