2010-01-24 03:16:33 +03:00
|
|
|
//
|
|
|
|
// "$Id: Fl_Plugin.H 6995 2010-01-12 08:48:55Z matt $"
|
|
|
|
//
|
|
|
|
// A Plugin system for FLTK, implemented in Fl_Preferences.cxx.
|
|
|
|
//
|
|
|
|
// Copyright 2002-2010 by Matthias Melcher.
|
|
|
|
//
|
2011-07-19 08:49:30 +04:00
|
|
|
// This library is free software. Distribution and use rights are outlined in
|
|
|
|
// the file "COPYING" which should have been included with this file. If this
|
|
|
|
// file is missing or damaged, see the license at:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/COPYING.php
|
2010-01-24 03:16:33 +03:00
|
|
|
//
|
|
|
|
// Please report all bugs and problems on the following page:
|
|
|
|
//
|
|
|
|
// http://www.fltk.org/str.php
|
|
|
|
//
|
|
|
|
|
|
|
|
/* \file
|
|
|
|
Fl_Plugin class . */
|
|
|
|
|
|
|
|
#ifndef Fl_Plugin_H
|
|
|
|
# define Fl_Plugin_H
|
|
|
|
|
|
|
|
# include "Fl_Preferences.H"
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
\brief Fl_Plugin allows link-time and run-time integration of binary modules.
|
|
|
|
|
|
|
|
Fl_Plugin and Fl_Plugin_Manager provide a small and simple solution for
|
|
|
|
linking C++ classes at run-time, or optionally linking modules at compile
|
|
|
|
time without the need to change the main application.
|
|
|
|
|
|
|
|
Fl_Plugin_Manager uses static initialisation to create the plugin interface
|
|
|
|
early during startup. Plugins are stored in a temporary database, organized
|
|
|
|
in classes.
|
|
|
|
|
|
|
|
Plugins should derive a new class from Fl_Plugin as a base:
|
|
|
|
\code
|
|
|
|
class My_Plugin : public Fl_Plugin {
|
|
|
|
public:
|
|
|
|
My_Plugin() : Fl_Plugin("effects", "blur") { }
|
|
|
|
void do_something(...);
|
|
|
|
};
|
|
|
|
My_Plugin blur_plugin();
|
|
|
|
\endcode
|
|
|
|
|
2011-06-08 14:47:03 +04:00
|
|
|
Plugins can be put into modules and either linked before distribution, or loaded
|
2010-01-24 03:16:33 +03:00
|
|
|
from dynamically linkable files. An Fl_Plugin_Manager is used to list and
|
|
|
|
access all currently loaded plugins.
|
|
|
|
\code
|
|
|
|
Fl_Plugin_Manager mgr("effects");
|
|
|
|
int i, n = mgr.plugins();
|
|
|
|
for (i=0; i<n; i++) {
|
|
|
|
My_Plugin *pin = (My_Plugin*)mgr.plugin(i);
|
|
|
|
pin->do_something();
|
|
|
|
}
|
|
|
|
\endcode
|
|
|
|
*/
|
2011-01-24 20:04:22 +03:00
|
|
|
class FL_EXPORT Fl_Plugin {
|
2010-01-24 03:16:33 +03:00
|
|
|
Fl_Preferences::ID id;
|
|
|
|
public:
|
|
|
|
Fl_Plugin(const char *klass, const char *name);
|
|
|
|
virtual ~Fl_Plugin();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
\brief Fl_Plugin_Manager manages link-time and run-time plugin binaries.
|
|
|
|
\see Fl_Plugin
|
|
|
|
*/
|
2011-01-24 20:04:22 +03:00
|
|
|
class FL_EXPORT Fl_Plugin_Manager : public Fl_Preferences {
|
2010-01-24 03:16:33 +03:00
|
|
|
public:
|
|
|
|
Fl_Plugin_Manager(const char *klass);
|
|
|
|
~Fl_Plugin_Manager();
|
|
|
|
|
|
|
|
/** \brief Return the number of plugins in the klass.
|
|
|
|
*/
|
|
|
|
int plugins() { return groups(); }
|
|
|
|
Fl_Plugin *plugin(int index);
|
2010-02-28 01:38:25 +03:00
|
|
|
Fl_Plugin *plugin(const char *name);
|
2010-01-24 03:16:33 +03:00
|
|
|
Fl_Preferences::ID addPlugin(const char *name, Fl_Plugin *plugin);
|
|
|
|
|
|
|
|
static void removePlugin(Fl_Preferences::ID id);
|
|
|
|
static int load(const char *filename);
|
|
|
|
static int loadAll(const char *filepath, const char *pattern=0);
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // !Fl_Preferences_H
|
|
|
|
|
|
|
|
//
|
|
|
|
// End of "$Id: Fl_Preferences.H 6995 2010-01-12 08:48:55Z matt $".
|
|
|
|
//
|