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
25 #ifndef __PLUGINMANAGERIMPL_H__
26 #define __PLUGINMANAGERIMPL_H__
29 #include "CpluffAdapter.h"
30 #include "FelixAdapter.h"
34 class PluginManagerImpl
39 * Constructor for PluginManagerImpl.
40 * During construction time, all plugins under the root plugin path will be loaded.
48 virtual ~PluginManagerImpl(void);
52 * A function to register pluins in the path.
53 * This function will load plugins in plugin manager table.
55 * @param path plugin file path to be registered.
56 * @return int, 1 is success, 0 is fail.
61 int registerPlugin(std::string path);
66 * A function to register pluins in the path.
67 * This function will load plugins in plugin manager table.
69 * @param path plugin file path to be registered.
70 * recursive load plugins sub folders recursively.
71 * @return int, 1 is success, 0 is fail.
76 int registerAllPlugin(std::string path);
81 * @param plugin plugin object to be unregistered.
82 * @return int, 1 is success, 0 is fail.
84 int unregisterPlugin(std::string path);
87 * Unregister All plugin.
89 * @return int, 1 is success, 0 is fail.
91 int unregisterAllPlugin(void);
94 * find plugins which have the key and value
96 * @return vector of currently registered plugins
98 std::vector<Plugin> *findPlugins(const std::string key, const std::string value);
101 * Get plugin which has the id
103 * @param pluginID plugin id to find
104 * @return Plugin instance
106 Plugin *getPlugin(const std::string pluginID);
109 * Check whether the plugin started or not
111 * @param Plugin to identify the Starting.
112 * @return true if started, false is stop.
115 bool isStarted(Plugin *plugin);
121 * @return Plugin state.
123 virtual std::string getState(const std::string plugID);
126 * Start plugins by resource type
128 * @param type resouce type string to be started.
131 virtual int startPlugins(const std::string key, const std::string value);
134 * Stop plugins by resource type
136 * @param type resouce type string to be started.
139 virtual int stopPlugins(const std::string key, const std::string value);
143 * This function will load dynamic plugin library on memory and call start function of plugin to be initialized.
146 * @return int, 1 is success, 0 is fail.
148 int startPlugins(Plugin *const plugin);
153 * This function will call stop function of plugin and unload dynamic plugin library from memory.
156 * @return int, 1 is success, 0 is fail.
158 int stopPlugins(Plugin *const plugin);
162 * This function will call rescan function of plugins in the configuration folder
165 * @return int, 1 is success, 0 is fail.
167 virtual int rescanPlugin();
170 * get all plugins which currently registered.
172 * @return vector of currently registered plugins
175 virtual std::vector<Plugin> &getAllPlugins(void);
177 static PluginManagerImpl *Getinstance()
179 if (NULL == s_pinstance)
181 s_pinstance = new PluginManagerImpl();
190 FelixAdapter *javappm;
192 std::vector<Plugin> m_plugins;
193 static PluginManagerImpl *s_pinstance;
195 static void deleteinstance()
197 if (NULL != s_pinstance)
205 * refresh All Plugin information.
207 * @return vector<Plugin> is all Plugin.
209 std::vector<Plugin> refreshPluginInfo();
212 * Start plugin by platform.
213 * This function will load dynamic plugin library on memory and call start function of plugin to be initialized.
216 * @param Platform pointer.
217 * @return int, 1 is success, 0 is fail.
219 int startbyPlatform(Plugin *const plugin, void *const arg);
222 * Stop Plugin by platform.
223 * This function will call stop function of plugin and unload dynamic plugin library from memory.
226 * @return int, 1 is success, 0 is fail.
228 int stopbyPlatform(Plugin *const plugin);
232 #endif //__PLUGINMANAGERIMPL_H__