MCPcopy Create free account
hub / github.com/analogdevicesinc/scopy / sort

Method sort

core/src/pluginmanager.cpp:82–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80}
81
82void PluginManager::sort(bool ascending)
83{
84 std::sort(m_plugins.begin(), m_plugins.end(), [ascending](const PluginInfo &p1, const PluginInfo &p2) {
85 if(!p1.isLoaded() && !p2.isLoaded()) {
86 return ascending ? p1.name() < p2.name() : p1.name() > p2.name();
87 }
88 if(!p1.isLoaded()) {
89 return !ascending;
90 }
91 if(!p2.isLoaded()) {
92 return ascending;
93 }
94 int priority1 = p1.pluginInstance()->metadata()["priority"].toInt();
95 int priority2 = p2.pluginInstance()->metadata()["priority"].toInt();
96 return ascending ? priority1 < priority2 : priority1 > priority2;
97 });
98
99 qDebug(CAT_PLUGINMANAGER) << "New plugin order:";
100 for(const PluginInfo &plugin : qAsConst(m_plugins)) {
101 qDebug(CAT_PLUGINMANAGER) << plugin.name();
102 }
103}
104
105void PluginManager::clear() { m_plugins.clear(); }
106

Callers 10

loadLibsMethod · 0.45
metadataOpsMethod · 0.45
exclusionMethod · 0.45
exclusionExceptMethod · 0.45
_initMethod · 0.45
getLanguagesMethod · 0.45

Calls 4

isLoadedMethod · 0.80
pluginInstanceMethod · 0.80
nameMethod · 0.45
metadataMethod · 0.45

Tested by 8

loadLibsMethod · 0.36
metadataOpsMethod · 0.36
exclusionMethod · 0.36
exclusionExceptMethod · 0.36