plugin_bridge.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011, Dirk Thomas, TU Darmstadt
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following
13  * disclaimer in the documentation and/or other materials provided
14  * with the distribution.
15  * * Neither the name of the TU Darmstadt nor the names of its
16  * contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  */
32 
34 
35 #include <qt_gui_cpp/plugin.h>
38 
39 #include <QEvent>
40 
41 namespace qt_gui_cpp {
42 
44  : QObject()
45  , provider_(0)
46  , plugin_(0)
47 {
48  setObjectName("PluginBridge");
49 }
50 
51 bool PluginBridge::load_plugin(PluginProvider* provider, const QString& plugin_id, PluginContext* plugin_context)
52 {
53  qDebug("PluginBridge::load_plugin() %s", plugin_id.toStdString().c_str());
54  provider_ = provider;
55  plugin_ = provider_->load_plugin(plugin_id, plugin_context);
56  if (plugin_)
57  {
58  plugin_->installEventFilter(this);
59  }
60  return plugin_ != 0;
61 }
62 
64 {
65  qDebug("PluginBridge::unload_plugin()");
67  plugin_ = 0;
68 }
69 
71 {
72  if (plugin_)
73  {
74  return plugin_->hasConfiguration();
75  }
76  return false;
77 }
78 
80 {
81  if (plugin_)
82  {
84  }
85 }
86 
88 {
89  if (plugin_)
90  {
91  plugin_->removeEventFilter(this);
93  }
94 }
95 
96 void PluginBridge::save_settings(QObject* plugin_settings, QObject* instance_settings)
97 {
98  if (plugin_)
99  {
100  Settings plugin(plugin_settings);
101  Settings instance(instance_settings);
102  plugin_->saveSettings(plugin, instance);
103  }
104 }
105 
106 void PluginBridge::restore_settings(QObject* plugin_settings, QObject* instance_settings)
107 {
108  if (plugin_)
109  {
110  Settings plugin(plugin_settings);
111  Settings instance(instance_settings);
112  plugin_->restoreSettings(plugin, instance);
113  }
114 }
115 
116 } // namespace
plugin_provider.h
qt_gui_cpp::PluginBridge::load_plugin
virtual bool load_plugin(PluginProvider *provider, const QString &plugin_id, PluginContext *plugin_context)
Definition: plugin_bridge.cpp:51
qt_gui_cpp::PluginContext
Definition: plugin_context.h:61
qt_gui_cpp::PluginProvider::unload_plugin
virtual void unload_plugin(Plugin *plugin_instance)
Definition: plugin_provider.cpp:76
qt_gui_cpp::Plugin::restoreSettings
virtual void restoreSettings(const Settings &, const Settings &)
Definition: plugin.h:91
plugin.h
qt_gui_cpp::Plugin::shutdownPlugin
virtual void shutdownPlugin()
Definition: plugin.h:75
qt_gui_cpp::Settings
Definition: settings.h:53
qt_gui_cpp::Plugin::saveSettings
virtual void saveSettings(Settings &, Settings &) const
Definition: plugin.h:83
plugin_bridge.h
qt_gui_cpp::PluginBridge::save_settings
virtual void save_settings(QObject *plugin_settings, QObject *instance_settings)
Definition: plugin_bridge.cpp:96
qt_gui_cpp::PluginBridge::restore_settings
virtual void restore_settings(QObject *plugin_settings, QObject *instance_settings)
Definition: plugin_bridge.cpp:106
qt_gui_cpp::PluginBridge::unload_plugin
virtual void unload_plugin()
Definition: plugin_bridge.cpp:63
qt_gui_cpp::PluginBridge::has_configuration
virtual bool has_configuration() const
Definition: plugin_bridge.cpp:70
qt_gui_cpp::PluginProvider
Definition: plugin_provider.h:48
plugin_context.h
qt_gui_cpp::PluginProvider::load_plugin
virtual Plugin * load_plugin(const QString &plugin_id, PluginContext *plugin_context)
Definition: plugin_provider.cpp:68
qt_gui_cpp::Plugin::triggerConfiguration
virtual void triggerConfiguration()
Definition: plugin.h:107
qt_gui_cpp::PluginBridge::shutdown_plugin
virtual void shutdown_plugin()
Definition: plugin_bridge.cpp:87
qt_gui_cpp
Definition: composite_plugin_provider.h:44
qt_gui_cpp::PluginBridge::PluginBridge
PluginBridge()
Definition: plugin_bridge.cpp:43
qt_gui_cpp::Plugin::hasConfiguration
virtual bool hasConfiguration() const
Definition: plugin.h:98
qt_gui_cpp::PluginBridge::trigger_configuration
virtual void trigger_configuration()
Definition: plugin_bridge.cpp:79
qt_gui_cpp::PluginBridge::plugin_
Plugin * plugin_
Definition: plugin_bridge.h:77
qt_gui_cpp::PluginBridge::provider_
PluginProvider * provider_
Definition: plugin_bridge.h:75


qt_gui_cpp
Author(s): Dirk Thomas
autogenerated on Sat Jun 25 2022 02:15:07