2 * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 * @author Grzegorz Krawczyk (g.krawczyk@samsung.com)
23 #ifndef _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_EXPORTED_API_H_
24 #define _WRT_PLUGINS_COMMON_PLUGIN_API_SUPPORT_EXPORTED_API_H_
26 #include <PluginRegistration.h>
29 * This file provides definition of entry point to the plugin's shared library
32 * Each plugin have to provide 1 symbol which is get by dlsym.
33 * The name of required symbol is specified by 'GetExportedSymbolName' function
34 * The type of this symbol is pointer to ExportedApi struct
36 * To allow access to your plugin, you have to:
38 * 1)define 3 functions:
41 * - GetProvidedFeatures
42 * (names are not important)
44 * 2)define global struct named "dll_api" and initialize it with above functions
46 * ExportedApi dll_api = {Register, Unregister, GetProvidedFeatures};
49 * Detailed Example how the file with api may looks like file:
51 * #include <Commons/Exception.h>
52 * #include <Commons/WrtAccess/WrtAccess.h>
55 * #include <ObjectFactory.h>
56 * #include <PluginRegistration.h>
57 * #include <ExportedApi.h>
60 * #include "plugin_config.h"
62 * #define OBJECT_WIDGET "widget"
63 * #define OBJECT_TEST "__test"
65 * using namespace WrtPlugins::W3C;
66 * using namespace WrtDeviceApis;
67 * using namespace WrtDeviceApis::Commons;
68 * using namespace WrtPluginsApi;
73 * void on_widget_start_callback(int widgetId)
78 * void on_widget_stop_callback(int widgetId)
84 * void Register(PluginRegistration& r)
86 * Plugin* plugin = new Plugin();
88 * auto test = ObjectFactory::createMainObject(
90 * WrtPlugins::W3C::JSTest::getClassRef,
93 * plugin->AddObject(test);
95 * r.Connect<OnWidgetStart>(W3CTest::on_widget_start_callback);
97 * r.Connect<OnWidgetStop>(W3CTest::on_widget_stop_callback);
99 * r.AddPlugin(*plugin);
102 * void Unregister(PluginRegistration& r, Plugin* plugin)
108 * void GetProvidedFeatures(feature_mapping_interface_t *mapping)
110 * WrtPlugins::W3C::WidgetTestDeclarations::getMappingInterface(mapping);
113 * ExportedApi dll_api={Register, Unregister, GetProvidedFeatures};
115 * #undef OBJECT_WIDGET
121 //forward declaration
122 struct feature_mapping_interface_s;
123 typedef struct feature_mapping_interface_s feature_mapping_interface_t;
125 class WrtPluginsApi::Plugin;
127 extern "C" struct ExportedApi
130 * This function is invoked when library is loaded
132 void (*Register)(WrtPluginsApi::PluginRegistration&);
135 * This function is invoked when library is unloaded
137 void (*Unregister)(WrtPluginsApi::PluginRegistration&,
138 WrtPluginsApi::Plugin* plugin);
141 * This function is invoked by wrt-plugins-installer to obtain
142 * info about features,functions,objects provided by plugin
144 void (*GetProvidedFeatures)(feature_mapping_interface_t*);
147 constexpr const char* GetExportedSymbolName()