recursive_plugin_provider.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 <stdexcept>
36 
37 namespace qt_gui_cpp {
38 
41  , plugin_provider_(plugin_provider)
42 {}
43 
45 {
46  delete plugin_provider_;
47 }
48 
49 QMap<QString, QString> RecursivePluginProvider::discover(QObject* discovery_data)
50 {
51  // discover plugins, which are providers themselves
52  QList<PluginDescriptor*> descriptors = plugin_provider_->discover_descriptors(discovery_data);
53  QList<QString> plugin_ids;
54  for (QList<PluginDescriptor*>::iterator it = descriptors.begin(); it != descriptors.end(); it++)
55  {
56  PluginDescriptor* descriptor = *it;
57  plugin_ids.append(descriptor->pluginId());
58  delete descriptor;
59  }
60 
61  // instantiate plugins
62  QList<PluginProvider*> providers;
63  for (QList<QString>::iterator it = plugin_ids.begin(); it != plugin_ids.end(); it++)
64  {
65  try
66  {
67  // pass NULL as PluginContext for PluginProviders
69  if (instance == 0)
70  {
71  throw std::runtime_error("load returned None");
72  }
73  providers.append(instance);
74  }
75  catch (...)
76  {
77  qCritical("RecursivePluginProvider.discover() loading plugin '%s' failed", it->toStdString().c_str());
78  }
79  }
80 
81  // delegate discovery through instantiated plugin providers to base class
82  set_plugin_providers(providers);
83  return CompositePluginProvider::discover(discovery_data);
84 }
85 
86 } // namespace
virtual T * load_explicit_type(const QString &plugin_id, PluginContext *plugin_context)
virtual void set_plugin_providers(const QList< PluginProvider *> &plugin_providers)
virtual QMap< QString, QString > discover(QObject *discovery_data)
const QString & pluginId() const
RosPluginlibPluginProvider_ForPluginProviders * plugin_provider_
virtual QList< PluginDescriptor * > discover_descriptors(QObject *discovery_data)
RecursivePluginProvider(RosPluginlibPluginProvider_ForPluginProviders *plugin_provider)
virtual QMap< QString, QString > discover(QObject *discovery_data)


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