Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / service / protocol-plugin / plugin-manager / src / PluginManager.h
1 //******************************************************************
2 //
3 // Copyright 2014 Samsung Electronics All Rights Reserved.
4 //
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 //
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
10 //
11 //      http://www.apache.org/licenses/LICENSE-2.0
12 //
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.
18 //
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 /// @file PluginManager.h
22
23 /// @brief
24
25 #ifndef __PLUGINMANAGER_H
26 #define __PLUGINMANAGER_H
27 #ifndef DLOPEN_POSIX
28 #define DLOPEN_POSIX
29 #endif
30
31 #include <vector>
32 #include <dirent.h>
33 #include <sys/stat.h>
34 #include <errno.h>
35 #include <dlfcn.h>
36 #include "PluginManagerImpl.h"
37 #include "Plugin.h"
38
39 namespace OIC
40 {
41
42     /**
43     * @brief    After installing a plug-in in a directory, each plug-ins can be managed by this class.
44     *
45     *
46     */
47     class PluginManager
48     {
49         public:
50             PluginManager();
51
52             /**
53             * Virtual destructor
54             */
55             ~PluginManager(void);
56
57             /**
58             * Start plugins by key-value pair.
59             *
60             * @param key-value pair string to be started.
61             * @return int, 1 is success, 0 is fail.
62             */
63             int startPlugins(const std::string key, const std::string value);
64
65             /**
66             * Stop plugins by key-value pair.
67             *
68             * @param key-value pair string to be stopped.
69             * @return int, 1 is success, 0 is fail.
70             */
71             int stopPlugins(const std::string key, const std::string value);
72
73             /**
74             * Rescan Plugin.
75             * This function will call rescan function of plugins in the configuration folder
76             *
77             * @param void.
78             * @return int, 1 is success, 0 is fail.
79             */
80             int rescanPlugin(void);
81
82             /**
83             * Get Plugin list.
84             *
85             * @param void.
86             * @return Plugin vector
87             */
88             std::vector<Plugin> getPlugins(void);
89
90             /**
91             * Get Plugin state.
92             *
93             * @param Plugin ID string.
94             * @return Plugin state string.
95             */
96             std::string getState(const std::string plugID);
97
98         private:
99             PluginManagerImpl *pluginManagerImpl;
100             void (*destroy)(PluginManagerImpl *);
101             void *handle;
102     };
103 }
104 #endif //__PLUGINMANAGER_H