Added Plugin Manager Configuration Feature
[platform/upstream/iotivity.git] / service / protocol-plugin / plugin-manager / src / PluginManager.cpp
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.cpp
22
23 /// @brief
24
25
26 #include "PluginManager.h"
27
28 using namespace OIC;
29
30 PluginManager::PluginManager()
31 {
32     void *handle = dlopen("./libpmimpl.so", RTLD_LAZY);
33     if (!handle)
34     {
35         fprintf(stderr, "%s\n", dlerror());
36         exit(EXIT_FAILURE);
37     }
38     PluginManagerImpl* (*create)();
39     create = (PluginManagerImpl * (*)())dlsym(handle, "create_object");
40     destroy = (void (*)(PluginManagerImpl *))dlsym(handle, "destroy_object");
41     pluginManagerImpl = (PluginManagerImpl *)create();
42 }
43
44 PluginManager::~PluginManager(void)
45 {
46     destroy(pluginManagerImpl);
47 }
48
49 int PluginManager::startPlugins(const std::string key, const std::string value)
50 {
51     return pluginManagerImpl->startPlugins(key, value);
52 }
53
54 int PluginManager::stopPlugins(const std::string key, const std::string value)
55 {
56     return pluginManagerImpl->stopPlugins(key, value);
57 }
58
59 int PluginManager::rescanPlugin()
60 {
61     return pluginManagerImpl->rescanPlugin();
62 }
63
64 std::vector<Plugin> PluginManager::getPlugins(void)
65 {
66     return pluginManagerImpl->getAllPlugins();
67 }
68
69 std::string PluginManager::getState(const std::string plugID)
70 {
71     return pluginManagerImpl->getState(plugID);
72 }