plugin_bridge.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2011, Dirk Thomas, TU Darmstadt
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  *
00009  *   * Redistributions of source code must retain the above copyright
00010  *     notice, this list of conditions and the following disclaimer.
00011  *   * Redistributions in binary form must reproduce the above
00012  *     copyright notice, this list of conditions and the following
00013  *     disclaimer in the documentation and/or other materials provided
00014  *     with the distribution.
00015  *   * Neither the name of the TU Darmstadt nor the names of its
00016  *     contributors may be used to endorse or promote products derived
00017  *     from this software without specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00020  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00021  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00022  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00023  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00024  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00025  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00026  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00027  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00028  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00029  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00030  * POSSIBILITY OF SUCH DAMAGE.
00031  */
00032 
00033 #include <qt_gui_cpp/plugin_bridge.h>
00034 
00035 #include <qt_gui_cpp/plugin.h>
00036 #include <qt_gui_cpp/plugin_context.h>
00037 #include <qt_gui_cpp/plugin_provider.h>
00038 
00039 #include <QEvent>
00040 
00041 namespace qt_gui_cpp {
00042 
00043 PluginBridge::PluginBridge()
00044   : QObject()
00045   , provider_(0)
00046   , plugin_(0)
00047 {
00048   setObjectName("PluginBridge");
00049 }
00050 
00051 bool PluginBridge::load_plugin(PluginProvider* provider, const QString& plugin_id, PluginContext* plugin_context)
00052 {
00053   qDebug("PluginBridge::load_plugin() %s", plugin_id.toStdString().c_str());
00054   provider_ = provider;
00055   plugin_ = provider_->load_plugin(plugin_id, plugin_context);
00056   if (plugin_)
00057   {
00058     plugin_->installEventFilter(this);
00059   }
00060   return plugin_ != 0;
00061 }
00062 
00063 void PluginBridge::unload_plugin()
00064 {
00065   qDebug("PluginBridge::unload_plugin()");
00066   provider_->unload_plugin(plugin_);
00067   plugin_ = 0;
00068 }
00069 
00070 bool PluginBridge::has_configuration() const
00071 {
00072   if (plugin_)
00073   {
00074     return plugin_->hasConfiguration();
00075   }
00076   return false;
00077 }
00078 
00079 void PluginBridge::trigger_configuration()
00080 {
00081   if (plugin_)
00082   {
00083     plugin_->triggerConfiguration();
00084   }
00085 }
00086 
00087 void PluginBridge::shutdown_plugin()
00088 {
00089   if (plugin_)
00090   {
00091     plugin_->removeEventFilter(this);
00092     plugin_->shutdownPlugin();
00093   }
00094 }
00095 
00096 void PluginBridge::save_settings(QObject* plugin_settings, QObject* instance_settings)
00097 {
00098   if (plugin_)
00099   {
00100     Settings plugin(plugin_settings);
00101     Settings instance(instance_settings);
00102     plugin_->saveSettings(plugin, instance);
00103   }
00104 }
00105 
00106 void PluginBridge::restore_settings(QObject* plugin_settings, QObject* instance_settings)
00107 {
00108   if (plugin_)
00109   {
00110     Settings plugin(plugin_settings);
00111     Settings instance(instance_settings);
00112     plugin_->restoreSettings(plugin, instance);
00113   }
00114 }
00115 
00116 } // namespace


qt_gui_cpp
Author(s): Dirk Thomas
autogenerated on Thu Jun 6 2019 18:07:36