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
virtual void save_settings(QObject *plugin_settings, QObject *instance_settings)
virtual void triggerConfiguration()
Definition: plugin.h:107
virtual bool hasConfiguration() const
Definition: plugin.h:98
virtual void unload_plugin()
virtual bool has_configuration() const
virtual bool load_plugin(PluginProvider *provider, const QString &plugin_id, PluginContext *plugin_context)
virtual void restore_settings(QObject *plugin_settings, QObject *instance_settings)
virtual void shutdown_plugin()
virtual void restoreSettings(const Settings &, const Settings &)
Definition: plugin.h:91
virtual void saveSettings(Settings &, Settings &) const
Definition: plugin.h:83
PluginProvider * provider_
Definition: plugin_bridge.h:75
virtual void shutdownPlugin()
Definition: plugin.h:75
virtual void trigger_configuration()
virtual void unload_plugin(Plugin *plugin_instance)


qt_gui_cpp
Author(s): Dirk Thomas
autogenerated on Fri Jun 24 2022 02:42:39