2
// "$Id: Fl_Plugin.H 6995 2010-01-12 08:48:55Z matt $"
4
// A Plugin system for FLTK, implemented in Fl_Preferences.cxx.
6
// Copyright 2002-2010 by Matthias Melcher.
8
// This library is free software; you can redistribute it and/or
9
// modify it under the terms of the GNU Library General Public
10
// License as published by the Free Software Foundation; either
11
// version 2 of the License, or (at your option) any later version.
13
// This library is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
// Library General Public License for more details.
18
// You should have received a copy of the GNU Library General Public
19
// License along with this library; if not, write to the Free Software
20
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23
// Please report all bugs and problems on the following page:
25
// http://www.fltk.org/str.php
34
# include "Fl_Preferences.H"
38
\brief Fl_Plugin allows link-time and run-time integration of binary modules.
40
Fl_Plugin and Fl_Plugin_Manager provide a small and simple solution for
41
linking C++ classes at run-time, or optionally linking modules at compile
42
time without the need to change the main application.
44
Fl_Plugin_Manager uses static initialisation to create the plugin interface
45
early during startup. Plugins are stored in a temporary database, organized
48
Plugins should derive a new class from Fl_Plugin as a base:
50
class My_Plugin : public Fl_Plugin {
52
My_Plugin() : Fl_Plugin("effects", "blur") { }
53
void do_something(...);
55
My_Plugin blur_plugin();
58
Plugins can be put into modules and either linked before distribution, or loaded
59
from dynamically linkable files. An Fl_Plugin_Manager is used to list and
60
access all currently loaded plugins.
62
Fl_Plugin_Manager mgr("effects");
63
int i, n = mgr.plugins();
65
My_Plugin *pin = (My_Plugin*)mgr.plugin(i);
70
class FL_EXPORT Fl_Plugin {
71
Fl_Preferences::ID id;
73
Fl_Plugin(const char *klass, const char *name);
79
\brief Fl_Plugin_Manager manages link-time and run-time plugin binaries.
82
class FL_EXPORT Fl_Plugin_Manager : public Fl_Preferences {
84
Fl_Plugin_Manager(const char *klass);
87
/** \brief Return the number of plugins in the klass.
89
int plugins() { return groups(); }
90
Fl_Plugin *plugin(int index);
91
Fl_Plugin *plugin(const char *name);
92
Fl_Preferences::ID addPlugin(const char *name, Fl_Plugin *plugin);
94
static void removePlugin(Fl_Preferences::ID id);
95
static int load(const char *filename);
96
static int loadAll(const char *filepath, const char *pattern=0);
100
#endif // !Fl_Preferences_H
103
// End of "$Id: Fl_Preferences.H 6995 2010-01-12 08:48:55Z matt $".