iotivity 0.9.0
[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 #define DLOPEN_POSIX
28
29 #include <vector>
30 #include <dirent.h>
31 #include <sys/stat.h>
32 #include <errno.h>
33 #include <dlfcn.h>
34 #include "PluginManagerImpl.h"
35 #include "Plugin.h"
36
37 namespace OIC
38 {
39
40     /**
41     * @brief    After installing a plug-in in a directory, each plug-ins can be managed by this class.
42     *
43     *
44     */
45     class PluginManager
46     {
47         public:
48             PluginManager();
49
50             /**
51             * Virtual destructor
52             */
53             ~PluginManager(void);
54             /**
55             * Start  plugins by resource type
56             *
57             * @param type resouce type string to be started.
58             *
59             */
60             int startPlugins(const std::string key, const std::string value);
61
62             /**
63             * Stop  plugins by resource type
64             *
65             * @param type resouce type string to be started.
66             *
67             */
68             int stopPlugins(const std::string key, const std::string value);
69
70             /**
71             * Rescan Plugin.
72             * This function will call rescan function of plugins in the configuration folder
73             *
74             * @param Plugin
75             * @return int, 1 is success, 0 is fail.
76             */
77             int rescanPlugin();
78
79             /**
80             * Get Plugin list.
81             *
82             *
83             *
84             * @return
85             */
86             std::vector<Plugin> getPlugins(void);
87
88             /**
89             * Get Plugin state.
90             *
91             * @param Plugin ID
92             * @return Plugin state.
93             */
94             std::string getState(const std::string plugID);
95
96         private:
97             PluginManagerImpl *pluginManagerImpl;
98             void (*destroy)(PluginManagerImpl *);
99             void *handle;
100     };
101 }
102 #endif //__PLUGINMANAGER_H