Modifying version number for building on tizen 3.0
[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     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     free(handle);
48 }
49
50 int PluginManager::startPlugins(const std::string key, const std::string value)
51 {
52     return pluginManagerImpl->startPlugins(key, value);
53 }
54
55 int PluginManager::stopPlugins(const std::string key, const std::string value)
56 {
57     return pluginManagerImpl->stopPlugins(key, value);
58 }
59
60 int PluginManager::rescanPlugin()
61 {
62     return pluginManagerImpl->rescanPlugin();
63 }
64
65 std::vector<Plugin> PluginManager::getPlugins(void)
66 {
67     return pluginManagerImpl->getAllPlugins();
68 }
69
70 std::string PluginManager::getState(const std::string plugID)
71 {
72     return pluginManagerImpl->getState(plugID);
73 }