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 FelixAdapter.h
25 #ifndef __FELIXADAPTER_H__
26 #define __FELIXADAPTER_H__
35 #include <sys/types.h>
37 #include <boost/thread.hpp>
38 #include <boost/bind.hpp>
45 #define BUF_LEN (int)( 1024 * ( EVENT_SIZE + 16 ) )
50 * @brief After installing a plug-in in a directory, each plug-ins can be managed by this class.
58 * A function to register pluins in the path.
59 * This function will load plugins in plugin manager table.
61 * @param path plugin file path to be registered.
62 * @return int, 1 is success, 0 is fail.
67 int registerPlugin(const std::string path);
71 * A function to register pluins in the path.
72 * This function will load plugins in plugin manager table.
74 * @param path plugin file path to be registered.
75 * recursive load plugins sub folders recursively.
76 * @return int, 1 is success, 0 is fail.
81 int registerAllPlugin(const std::string path);
87 * @param plugin plugin object to be unregistered.
88 * @return int, 1 is success, 0 is fail.
90 int unregisterPlugin(Plugin *const plugin);
94 * Unregister All plugin.
96 * @return int, 1 is success, 0 is fail.
98 int unregisterAllPlugin(void);
102 * get all plugins which currently registered.
104 * @return vector of currently registered plugins
107 std::vector<Plugin> &getAllPlugins(void);
111 * find plugins which have the key and value
113 * @return vector of currently registered plugins
115 std::vector<Plugin> *findPlugins(const std::string key, const std::string value);
119 * Get plugin which has the id
121 * @param pluginID plugin id to find
122 * @return Plugin instance
124 //Plugin *getPlugin(const std::string pluginID);
128 * This function will load dynamic plugin library on memory and call start function of plugin to be initialized.
131 * @param Platform pointer.
132 * @return int, 1 is success, 0 is fail.
134 int start(Plugin *const plugin, void *const arg);
139 * This function will call stop function of plugin and unload dynamic plugin library from memory.
142 * @return int, 1 is success, 0 is fail.
144 int stop(Plugin *const plugin);
148 * Check whether the plugin started or not
150 * @param Plugin to identify the Starting.
151 * @return true if started, false is stop.
154 bool isStarted(Plugin *plugin);
161 * @return Plugin state.
163 const std::string getState(const std::string plugID);
168 * new Singleton pattern instance.
170 * @return OICPluginManager pointer Address.
172 static FelixAdapter *Getinstance(void *args = NULL)
174 if (NULL == s_pinstance)
176 s_pinstance = new FelixAdapter((JavaVM *)args);
187 typedef std::map<std::string, bool> File_list;
188 std::vector<Plugin> m_plugins;
189 boost::thread m_file_detect_thread;
191 static FelixAdapter *s_pinstance;
194 * Constructor for FelixAdapter.
195 * During construction time, all plugins under the root plugin path will be loaded.
198 FelixAdapter(JavaVM *);
203 virtual ~FelixAdapter(void);
206 * delete Singleton pattern instance.
208 static void deleteinstance()
210 if (NULL != s_pinstance)
218 * detect plugins(add, delete, move)
220 * @param plugin file path.
223 //void observePluginPath(void *);
226 * Get whole "SO" file list.
228 * @param OUT, SO file list.
230 * @return true or false.
232 bool getFileList(File_list &list, const std::string strDir);
235 * print whole plugin info.
237 * @param Felix plugins
239 void printPluginList(cp_plugin_info_t **plugins);
242 * install plugin using c-pluff.
245 * @return int, 1 is success, 0 is fail.
247 int installPlugin(const std::string path);
251 * find Plugin and install plugin.(Recursive)
254 * @return int, 1 is success, 0 is fail.
256 int findPluginRecursive(const std::string path);
259 * load Plugin information to PluginManager table.
261 * @param path to observe
262 * @return int, 1 is success, 0 is fail.
264 int loadPluginInfoToManager(const std::string path);
268 #endif //__FELIXADAPTER_H__