kwave
18.07.70
|
#include <PluginManager.h>
Classes | |
struct | PluginModule |
Public Slots | |
void | signalClosed () |
void | setSignalName (const QString &name) |
Signals | |
void | sigCommand (const QString &command) |
void | sigClosed () |
void | sigSignalNameChanged (const QString &name) |
void | sigProgress (const QString &message) |
Private Types | |
typedef QPointer< Kwave::Plugin > | KwavePluginPointer |
typedef QList< KwavePluginPointer > | PluginList |
typedef QMutableListIterator< KwavePluginPointer > | PluginListMutableIterator |
typedef QListIterator< KwavePluginPointer > | PluginListIterator |
Private Slots | |
void | pluginClosed (Kwave::Plugin *p) |
void | pluginStarted (Kwave::Plugin *p) |
void | pluginDone (Kwave::Plugin *p) |
Private Member Functions | |
Kwave::Plugin * | createPluginInstance (const QString &name) |
void | savePluginDefaults (const QString &name, QStringList ¶ms) |
void | connectPlugin (Kwave::Plugin *plugin) |
void | disconnectPlugin (Kwave::Plugin *plugin) |
Private Attributes | |
PluginList | m_plugin_instances |
PluginList | m_running_plugins |
QPointer< QWidget > | m_parent_widget |
Kwave::SignalManager & | m_signal_manager |
ViewManager * | m_view_manager |
Static Private Attributes | |
static Kwave::PluginManager * | m_active_instance = Q_NULLPTR |
static QMap< QString, PluginModule > | m_plugin_modules |
Manages the loading, initializing, starting, running and closing of the plugins of kwave. Each instance of a TopWidget creates a new instance of the PluginManager to be independent from other toplevel widgets.
Definition at line 59 of file PluginManager.h.
|
private |
typedef: QPointer to a Kwave::Plugin
Definition at line 319 of file PluginManager.h.
|
private |
typedef: list of pointers to kwave plugins
Definition at line 322 of file PluginManager.h.
|
private |
typedef: const iterator for PluginList
Definition at line 330 of file PluginManager.h.
|
private |
typedef: mutable iterator for PluginList
Definition at line 326 of file PluginManager.h.
Kwave::PluginManager::PluginManager | ( | QWidget * | parent, |
Kwave::SignalManager & | signal_manager | ||
) |
Constructor.
parent | reference to the toplevel widget (our parent) |
signal_manager | reference to a SignalManager |
Definition at line 63 of file PluginManager.cpp.
|
virtual |
Default destructor
Definition at line 74 of file PluginManager.cpp.
References m_active_instance, Kwave::PluginManager::PluginModule::m_factory, m_plugin_instances, m_plugin_modules, Kwave::PluginManager::PluginModule::m_use_count, name, sigClosed(), and sync().
bool Kwave::PluginManager::canClose | ( | ) |
Returns true if there is no running plugin that blocks a "close" operation.
Definition at line 288 of file PluginManager.cpp.
References m_plugin_instances.
|
private |
connects all signals of and for a plugin
Definition at line 557 of file PluginManager.cpp.
References Kwave::connect(), pluginClosed(), pluginDone(), pluginStarted(), and sigClosed().
Referenced by createPluginInstance(), and migratePluginToActiveContext().
|
private |
Creates an instance of a plugin.
name | the name of the plugin (filename) |
Definition at line 173 of file PluginManager.cpp.
References connectPlugin(), DBG, Kwave::MessageBox::error(), Kwave::PluginManager::PluginModule::m_description, Kwave::PluginManager::PluginModule::m_factory, Kwave::PluginManager::PluginModule::m_name, m_parent_widget, m_plugin_instances, m_plugin_modules, and name.
Referenced by executePlugin(), loadAllPlugins(), and setupPlugin().
QStringList Kwave::PluginManager::defaultParams | ( | const QString & | name | ) |
loads a plugin's default parameters from the user's configuration file. If nothing is found in the config file, the return value will be 0. If the current version number of the plugin does not match the version number in the config file, the return value will also be 0.
name | the name of the plugin |
Definition at line 363 of file PluginManager.cpp.
References _, DBG, m_plugin_modules, Kwave::PluginManager::PluginModule::m_version, and name.
Referenced by executePlugin(), loadAllPlugins(), Kwave::RecordPlugin::setup(), and setupPlugin().
|
private |
connects all signals from and to a plugin
Definition at line 579 of file PluginManager.cpp.
References pluginClosed(), pluginDone(), pluginStarted(), and sigClosed().
Referenced by migratePluginToActiveContext(), and pluginClosed().
void Kwave::PluginManager::enqueueCommand | ( | const QString & | command | ) |
Enqueues a command that will be processed threadsafe in the X11 thread.
Definition at line 494 of file PluginManager.cpp.
References sigCommand().
Referenced by Kwave::Plugin::emitCommand(), and Kwave::UndoReverseAction::undo().
int Kwave::PluginManager::executePlugin | ( | const QString & | name, |
QStringList * | params | ||
) |
Executes a plugin in the context of a given parent widget.
name | the name of the plugin |
params | pointer to a parameter list or null if defaults should be used |
Definition at line 216 of file PluginManager.cpp.
References _, createPluginInstance(), defaultParams(), m_plugin_instances, name, savePluginDefaults(), sigCommand(), and sync().
Referenced by Kwave::K3BExportPlugin::saveBlocks().
void Kwave::PluginManager::insertView | ( | Kwave::SignalView * | view, |
QWidget * | controls | ||
) |
Insert a new signal view into this widget (or the upper/lower dock area.
view | the signal view, must not be a null pointer |
controls | a widget with controls, optionally, can be null |
Definition at line 480 of file PluginManager.cpp.
References Kwave::ViewManager::insertView(), and m_view_manager.
bool Kwave::PluginManager::loadAllPlugins | ( | ) |
Tries to load all plugins. If a pesistent plugin is found, it will stay loaded in memory, all other (non-persistent) plugins will be unloaded afterwards. This also filters out all plugins that do not correctly load.
used once by each toplevel window at startup
Definition at line 123 of file PluginManager.cpp.
References createPluginInstance(), DBG, defaultParams(), m_plugin_modules, and name.
void Kwave::PluginManager::migratePluginToActiveContext | ( | Kwave::Plugin * | plugin | ) |
Migrate a plugin to the currently active file context (which might be different from the one that is currently executing the plugin). The plugin will be removed from our lists and inserted into the currently active plugin manager instance.
plugin | the plugin to migrate |
Definition at line 685 of file PluginManager.cpp.
References connectPlugin(), disconnectPlugin(), m_active_instance, m_plugin_instances, m_running_plugins, and Kwave::Plugin::setPluginManager().
Referenced by Kwave::Plugin::migrateToActiveContext().
bool Kwave::PluginManager::onePluginRunning | ( | ) |
Returns true if at least one plugin is currently running
Definition at line 302 of file PluginManager.cpp.
References m_plugin_instances.
Referenced by sync().
Kwave::SampleSink * Kwave::PluginManager::openMultiTrackPlayback | ( | unsigned int | tracks, |
const Kwave::PlayBackParam * | playback_params = Q_NULLPTR |
||
) |
Opens a Kwave::MultiTrackSink for playback purposes.
tracks | number of tracks |
playback_params | points to a class that holds all playback parameters. If null, the default parameters of the current signal will be used |
Definition at line 457 of file PluginManager.cpp.
References m_signal_manager, Kwave::PlaybackController::openDevice(), and Kwave::SignalManager::playbackController().
Referenced by Kwave::FilterPlugin::startPreListen(), and Kwave::PlayBackPlugin::testPlayBack().
|
inline |
returns a pointer to the parent widget
Definition at line 198 of file PluginManager.h.
Referenced by Kwave::Plugin::parentWidget(), and Kwave::Plugin::setPluginManager().
Kwave::PlaybackController & Kwave::PluginManager::playbackController | ( | ) |
Returns a reference to the current playback controller. This is only needed for plugins doing playback.
Definition at line 474 of file PluginManager.cpp.
References m_signal_manager, and Kwave::SignalManager::playbackController().
|
privateslot |
Will be connected to the plugin's "closed" signal.
p | pointer to the plugin to be closed |
Definition at line 506 of file PluginManager.cpp.
References disconnectPlugin(), and m_plugin_instances.
Referenced by connectPlugin(), and disconnectPlugin().
|
privateslot |
called when a plugin has finished it's worker thread
Definition at line 540 of file PluginManager.cpp.
References m_running_plugins, and Kwave::Plugin::release().
Referenced by connectPlugin(), and disconnectPlugin().
const QList< Kwave::PluginManager::PluginModule > Kwave::PluginManager::pluginInfoList | ( | ) | const |
returns a list with info of all known plugins
Definition at line 679 of file PluginManager.cpp.
References m_plugin_modules.
|
privateslot |
called when a plugin has started (running) it's worker thread
Definition at line 526 of file PluginManager.cpp.
References m_running_plugins, and Kwave::Plugin::use().
Referenced by connectPlugin(), and disconnectPlugin().
void Kwave::PluginManager::registerViewManager | ( | Kwave::ViewManager * | view_manager | ) |
registers a view manager, must only be called once!
Definition at line 487 of file PluginManager.cpp.
References m_view_manager.
Referenced by Kwave::MainWidget::MainWidget(), and Kwave::MainWidget::~MainWidget().
|
private |
Saves a plugin's default parameters to the user's configuration file. The whole section in the configuration file will be deleted before saving the new settings in order to wipe out invalid entries and settings that belong to an older version.
name | the name of the plugin |
params | a list of configuration strings |
Definition at line 403 of file PluginManager.cpp.
References _, m_plugin_modules, Kwave::PluginManager::PluginModule::m_version, and name.
Referenced by executePlugin(), and setupPlugin().
void Kwave::PluginManager::searchPluginModules | ( | ) |
Searches the standard KDE data directories for plugins (through the KDE's standard search algorithm) and creates a map of plugin names and file names. First it collects a list of filenames and then filters it to sort out invalid entries.
Definition at line 605 of file PluginManager.cpp.
References _, DBG, Kwave::PluginManager::PluginModule::m_author, Kwave::PluginManager::PluginModule::m_description, Kwave::PluginManager::PluginModule::m_factory, Kwave::PluginManager::PluginModule::m_name, m_plugin_modules, Kwave::PluginManager::PluginModule::m_use_count, Kwave::PluginManager::PluginModule::m_version, name, and sigProgress().
sample_index_t Kwave::PluginManager::selectionEnd | ( | ) |
Returns the end of the selection. If nothing is currently selected this will be the last sample (length-1).
Definition at line 444 of file PluginManager.cpp.
References Kwave::Selection::last(), m_signal_manager, and Kwave::SignalManager::selection().
Referenced by Kwave::Plugin::selection().
sample_index_t Kwave::PluginManager::selectionStart | ( | ) |
Returns the start of the selection. If nothing is currently selected this will be the first sample (0).
Definition at line 438 of file PluginManager.cpp.
References Kwave::Selection::first(), m_signal_manager, and Kwave::SignalManager::selection().
Referenced by Kwave::Plugin::selection(), and Kwave::SelectRangePlugin::setup().
void Kwave::PluginManager::selectRange | ( | sample_index_t | offset, |
sample_index_t | length | ||
) |
Sets the current start and length of the selection to new values.
offset | index of the first sample |
length | number of samples |
Definition at line 450 of file PluginManager.cpp.
References m_signal_manager, and Kwave::SignalManager::selectRange().
Referenced by Kwave::Plugin::selectRange().
|
inline |
Let this instance be the active one
Definition at line 262 of file PluginManager.h.
|
inline |
assigns a new parent widget, to be used for messages
new_parent | pointer to a QWidget |
Definition at line 193 of file PluginManager.h.
|
slot |
Called if the name of the current signal has changed. This will be forwarded to all plugins by emitting the signal sigSignalNameChanged.
Definition at line 599 of file PluginManager.cpp.
References sigSignalNameChanged().
int Kwave::PluginManager::setupPlugin | ( | const QString & | name, |
const QStringList & | params | ||
) |
Loads a plugin, calls it's setup function and then closes it again. The parameters will be loaded before the setup and saved if the setup has not been aborted.
name | the name of the plugin |
params | pointer to a parameter list or null if defaults should be used |
0 | if succeeded and accepted |
1 | if canceled |
-1 | if failed |
Definition at line 335 of file PluginManager.cpp.
References createPluginInstance(), defaultParams(), Kwave::Plugin::release(), savePluginDefaults(), and Kwave::Plugin::setup().
|
signal |
Informs all plugins and client windows that we close down
Referenced by connectPlugin(), disconnectPlugin(), signalClosed(), and ~PluginManager().
|
signal |
Forwards commands to the parent TopWidget execute a command
Referenced by enqueueCommand(), and executePlugin().
|
slot |
Notify all plugins that the signal or file is to be closed
Definition at line 500 of file PluginManager.cpp.
References sigClosed().
sample_index_t Kwave::PluginManager::signalLength | ( | ) |
Returns the length of the current signal in samples. If no signal is present the return value will be 0.
Definition at line 426 of file PluginManager.cpp.
References Kwave::SignalManager::length(), and m_signal_manager.
Referenced by Kwave::Plugin::selection(), and Kwave::Plugin::signalLength().
|
inline |
returns a reference to our signal manager
Definition at line 204 of file PluginManager.h.
Referenced by Kwave::NoisePlugin::createDialog(), Kwave::RecordPlugin::resetRecording(), Kwave::VolumePlugin::setup(), and Kwave::Plugin::signalManager().
double Kwave::PluginManager::signalRate | ( | ) |
Returns the current sample rate in samples per second. If no signal is present the return value will be 0.
Definition at line 432 of file PluginManager.cpp.
References m_signal_manager, and Kwave::SignalManager::rate().
Referenced by Kwave::Plugin::signalRate().
|
signal |
informs about progress, e.g. for showing a message in a splash screen or status bar.
Referenced by searchPluginModules().
|
signal |
Informs the plugins that the name of the signal has changed. This might be used to update the caption of a window.
Referenced by setSignalName().
void Kwave::PluginManager::stopAllPlugins | ( | ) |
Stops all currently running plugins
Definition at line 158 of file PluginManager.cpp.
References m_plugin_instances, and sync().
void Kwave::PluginManager::sync | ( | ) |
Waits until all currently running actions have completed.
Definition at line 316 of file PluginManager.cpp.
References onePluginRunning(), and Kwave::yield().
Referenced by executePlugin(), Kwave::TopWidget::forwardCommand(), stopAllPlugins(), and ~PluginManager().
|
staticprivate |
pointer to the currently active instance
Definition at line 362 of file PluginManager.h.
Referenced by migratePluginToActiveContext(), and ~PluginManager().
|
private |
reference to our parent toplevel widget
Definition at line 377 of file PluginManager.h.
Referenced by createPluginInstance().
|
private |
list of all plugins that were loaded by this instance
Definition at line 371 of file PluginManager.h.
Referenced by canClose(), createPluginInstance(), executePlugin(), migratePluginToActiveContext(), onePluginRunning(), pluginClosed(), stopAllPlugins(), and ~PluginManager().
|
staticprivate |
map with plugin information: key = short name of the plugin, data = plugin info (description, author, version etc...)
Definition at line 368 of file PluginManager.h.
Referenced by createPluginInstance(), defaultParams(), loadAllPlugins(), pluginInfoList(), savePluginDefaults(), searchPluginModules(), and ~PluginManager().
|
private |
list of currently running plugins
Definition at line 374 of file PluginManager.h.
Referenced by migratePluginToActiveContext(), pluginDone(), and pluginStarted().
|
private |
reference to our signal manager
Definition at line 380 of file PluginManager.h.
Referenced by openMultiTrackPlayback(), playbackController(), selectionEnd(), selectionStart(), selectRange(), signalLength(), and signalRate().
|
private |
interface for registering a SignalView
Definition at line 383 of file PluginManager.h.
Referenced by insertView(), and registerViewManager().