2 #include <score/plugins/Addon.hpp>
3 #include <score/plugins/qt_interfaces/GUIApplicationPlugin_QtInterface.hpp>
4 #include <score/plugins/qt_interfaces/PluginRequirements_QtInterface.hpp>
5 #include <score/tools/std/HashMap.hpp>
7 #include <ossia/detail/pod_vector.hpp>
9 #include <boost/graph/adjacency_list.hpp>
10 #include <boost/graph/topological_sort.hpp>
44 = boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS, GraphVertex>;
52 score::hash_map<PluginKey, int64_t> keys;
53 std::vector<const score::Addon*> not_loaded;
58 auto vx = boost::add_vertex(
GraphVertex{&addon}, m_graph);
65 auto addon_k = keys[addon.key];
66 for(
const auto& k : addon.plugin->required())
68 auto it = keys.find(k);
71 boost::add_edge(addon_k, it->second, m_graph);
75 boost::clear_vertex(addon_k, m_graph);
76 boost::remove_vertex(addon_k, m_graph);
77 not_loaded.push_back(&addon);
83 if(!not_loaded.empty())
84 qDebug() << not_loaded.size()
85 <<
"plugins were not loaded due to a dependency problem.";
89 ossia::int_vector topo_order;
90 topo_order.reserve(addons.size() - not_loaded.size());
94 boost::topological_sort(m_graph, std::back_inserter(topo_order));
95 for(
auto e : topo_order)
98 m_sorted.push_back(*m_graph[e].addon);
101 catch(
const std::exception& e)
103 qDebug() <<
"Invalid plug-in graph: " << e.what();
108 auto& sortedAddons()
const {
return m_sorted; }
112 std::vector<score::Addon> m_sorted;
Classes and functions used at the plug-in loading step.
Definition: PluginManager.hpp:26
Base toolkit upon which the software is built.
Definition: Application.cpp:90
The Addon struct.
Definition: Addon.hpp:16
Definition: PluginDependencyGraph.hpp:31
Allows to load plug-ins in the order they all require each other.
Definition: PluginDependencyGraph.hpp:29