reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
Plugin.hxx
Go to the documentation of this file.
1#ifndef PLUGIN_HXX
2#define PLUGIN_HXX
3
4#include "rutil/ResipAssert.h"
5
7
8/* plugin DSO support
9 *
10 * This is a new feature for v1.9. Developers can create plugins as
11 * standalone shared object files and load them at runtime.
12 *
13 * This makes it easy to create new functionality without recompiling.
14 * It also makes it easy to distribute third-party plugins as
15 * standalone packages.
16 *
17 * IMPORTANT NOTE:
18 * The plugin API is not guaranteed to remain absolutely constant between
19 * releases of reSIProcate. The version check mechanism will simply reject
20 * plugins compiled for a newer or older version of the API.
21 * In this first release of DSO support, we have provided a very simple
22 * set of functions so that if a future version of this API is very
23 * different, developers using the current API will not need to change too
24 * much to adapt their code.
25 *
26 * GETTING STARTED
27 * See the example plugin in repro/plugins/example
28 * It should be fairly easy to copy the Makefile.am and ExamplePlugin.cxx,
29 * add your own configure.ac and build your own standalone project outside the
30 * reSIProcate source tree. Naturally, you will need to include the
31 * reSIProcate headers on your build path somewhere.
32 */
33
34namespace resip
35{
36
37class Plugin
38{
39 public:
40 Plugin(){};
41 virtual ~Plugin(){};
42
43 /* called when a reload signal (HUP) is received */
44 virtual void onReload() = 0;
45
46};
47}
48
49extern "C" {
50typedef std::shared_ptr<resip::Plugin> (*PluginCreationFunc)();
56};
57
58namespace resip
59{
60
62{
63 public:
64 PluginManager(const ConfigParse& configParse,
65 const Data& defaultDirectory,
66 const Data& symbolName,
67 const int pluginApiVersion);
68 virtual ~PluginManager();
69
70 virtual bool loadPlugins(const std::vector<Data>& pluginNames);
71
72 /* called when a reload signal (HUP) is received */
73 virtual void onReload();
74
75 protected:
76 virtual bool onPluginLoaded(std::shared_ptr<Plugin> plugin) = 0;
77
78 virtual std::vector<std::shared_ptr<Plugin> > getPlugins() { return mPlugins; };
79
80 private:
81 const ConfigParse& mConfigParse;
82 const Data mDefaultDirectory;
83 const Data mSymbolName;
84 const int mPluginApiVersion;
85 std::vector<std::shared_ptr<Plugin> > mPlugins;
86};
87}
88
89
90
91#endif
92
93/* ====================================================================
94
95 Copyright (c) 2022, Software Freedom Institute https://softwarefreedom.institute
96 Copyright (c) 2022, Daniel Pocock https://danielpocock.com
97 All rights reserved.
98
99 Redistribution and use in source and binary forms, with or without
100 modification, are permitted provided that the following conditions are
101 met:
102
103 1. Redistributions of source code must retain the above copyright
104 notice, this list of conditions and the following disclaimer.
105
106 2. Redistributions in binary form must reproduce the above copyright
107 notice, this list of conditions and the following disclaimer in the
108 documentation and/or other materials provided with the distribution.
109
110 3. Neither the name of Plantronics nor the names of its contributors
111 may be used to endorse or promote products derived from this
112 software without specific prior written permission.
113
114 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
115 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
116 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
117 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
118 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
119 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
120 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
121 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
122 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
123 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
124 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
125
126 ==================================================================== */
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
virtual bool onPluginLoaded(std::shared_ptr< Plugin > plugin)=0
virtual ~PluginManager()
Definition Plugin.cxx:34
virtual std::vector< std::shared_ptr< Plugin > > getPlugins()
Definition Plugin.hxx:78
virtual void onReload()
Definition Plugin.cxx:104
virtual bool loadPlugins(const std::vector< Data > &pluginNames)
Definition Plugin.cxx:39
virtual ~Plugin()
Definition Plugin.hxx:41
virtual void onReload()=0
dcm! – add UnusedChecking(_enum) below;
std::shared_ptr< resip::Plugin >(* PluginCreationFunc)()
Definition Plugin.hxx:50
PluginCreationFunc creationFunc
Definition Plugin.hxx:54
int mPluginApiVersion
Definition Plugin.hxx:53