Remove unused code from the Release 2 scope modules
Trim mostly-deletion changes (~700 lines) across the modules the Release 2 build compiles: unused telegrams and receiver/handler code in TrainingAreaBase (telegrams, recv_from_dds_aes/fts, ism/main/pdm/position handlers), dead members in SqlBrowser and ProjectDataManagement, unused LtsPluginManager loader paths, LtsSession unit-test, WlsTetra and DdsView cleanups, plus the stale include_directories removal in Lts/CMakeLists.txt. Continues the Release 2 source prune (keep only what the build compiles). Excluded from this commit by design: the machine-specific .envrc (MIGRATE_PIPELINE_ROOT path fix stays uncommitted) and the untracked qt5-before/ reference tree.
This commit is contained in:
1 parent
e60a860283
commit
84f8cfb41f
45 files changed
+30
-724
No files matched your search
@@ -11,20 +11,16 @@
|
||||
#include "lts_plugin_loader.h"
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
#include <LtsAppDescriptor/lts_app_descriptor.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDirIterator>
|
||||
#include <QFileInfo>
|
||||
#include <QJsonObject>
|
||||
#include <QPluginLoader>
|
||||
#include <QMutableListIterator>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
||||
namespace LtsPluginManager
|
||||
{
|
||||
|
||||
@@ -42,7 +38,6 @@ void LtsPluginLoaderHandler::cleanupPluginLoader()
|
||||
s_ltsPluginLoader->ltsPluginLoader.unloadAllPlugins();
|
||||
}
|
||||
|
||||
|
||||
LtsPluginLoader *LtsPluginLoader::getInstance()
|
||||
{
|
||||
if (!s_ltsPluginLoader.exists())
|
||||
@@ -50,7 +45,6 @@ LtsPluginLoader *LtsPluginLoader::getInstance()
|
||||
return &s_ltsPluginLoader->ltsPluginLoader;
|
||||
}
|
||||
|
||||
|
||||
LtsPluginLoader::~LtsPluginLoader()
|
||||
{
|
||||
unloadAllPlugins();
|
||||
@@ -72,7 +66,6 @@ void LtsPluginLoader::unloadAllPlugins()
|
||||
m_loadedPlugins.clear();
|
||||
}
|
||||
|
||||
|
||||
void LtsPluginLoader::checkPlugins(const QVector<LtsAppDescriptor::AppDescription> &appVector,
|
||||
QStringList &errors /* out */)
|
||||
{
|
||||
@@ -84,7 +77,6 @@ void LtsPluginLoader::checkPlugins(const QVector<LtsAppDescriptor::AppDescriptio
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
QVector<PluginInstance> dataPlugins;
|
||||
QVector<PluginInstance> guiPlugins;
|
||||
auto addDataPluginFn = [&](const PluginInstance &pi)
|
||||
@@ -110,8 +102,6 @@ void LtsPluginLoader::checkPlugins(const QVector<LtsAppDescriptor::AppDescriptio
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// check for duplicate iids per plugin type
|
||||
auto checkDuplicateIidsFn = [&](const QVector<PluginInstance> &plugins, const QString &pluginType)
|
||||
{
|
||||
@@ -133,18 +123,13 @@ void LtsPluginLoader::checkPlugins(const QVector<LtsAppDescriptor::AppDescriptio
|
||||
checkDuplicateIidsFn(dataPlugins, QStringLiteral("data"));
|
||||
checkDuplicateIidsFn(guiPlugins, QStringLiteral("gui"));
|
||||
|
||||
|
||||
|
||||
QVector<PluginInstance> plugins(dataPlugins + guiPlugins);
|
||||
|
||||
|
||||
// check if all in apps.json requested plugins are available
|
||||
for (auto i1 = appVector.constBegin(); i1 != appVector.constEnd(); ++i1) // Apps
|
||||
{
|
||||
const LtsAppDescriptor::AppDescription &app = *i1;
|
||||
|
||||
//WARNING_LOG(logger) << "Checking app '"<<app.appName<<"'";
|
||||
|
||||
const QVector<LtsAppDescriptor::PluginInfo> &piVector = app.pluginInfos;
|
||||
|
||||
for (auto i2 = piVector.constBegin(); i2 != piVector.constEnd(); i2++) // App's Required Plugins
|
||||
@@ -174,7 +159,6 @@ void LtsPluginLoader::checkPlugins(const QVector<LtsAppDescriptor::AppDescriptio
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
|
||||
const std::function<bool(const PluginInstance &)> &loadPlugin,
|
||||
const QStringList &requiredPlugins,
|
||||
@@ -211,30 +195,25 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
QMutableListIterator<QString> i1(optionalPluginsList); // delete all plugins from the to-load list that were cached
|
||||
|
||||
while (i1.hasNext())
|
||||
{
|
||||
const QString pluginName = i1.next().toLower();
|
||||
|
||||
QMap<PluginKey, PluginInstance>::iterator i2 = m_loadedPlugins.find(PluginKey(requestedPluginType, pluginName));
|
||||
|
||||
if (i2 != m_loadedPlugins.end())
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " already loaded, using that instance";
|
||||
|
||||
if (loadPlugin)
|
||||
loadPlugin(i2.value());
|
||||
|
||||
i1.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QFileInfo libPathInfo(QCoreApplication::applicationDirPath() + QStringLiteral("/../lib/"));
|
||||
QString libPath(libPathInfo.absolutePath());
|
||||
if (!libPathInfo.exists())
|
||||
@@ -272,7 +251,6 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
|
||||
continue;
|
||||
|
||||
const QString absoluteFilePath = pluginDir.filePath();
|
||||
|
||||
DEBUG_LOG(logger) << "File Path: " << absoluteFilePath;
|
||||
|
||||
// if (!filename.contains(type))
|
||||
@@ -284,7 +262,6 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
|
||||
|
||||
std::unique_ptr<QPluginLoader> pluginLoader(new QPluginLoader);
|
||||
pluginLoader->setFileName(absoluteFilePath);
|
||||
|
||||
const QJsonObject jObj = pluginLoader->metaData();
|
||||
QJsonObject::const_iterator iid = jObj.find(QStringLiteral("IID"));
|
||||
|
||||
@@ -297,7 +274,6 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
|
||||
const QString jsonIid = iid.value().toString().toLower(); // LOWERCASE ! (pun intended)
|
||||
// Use QStringView for efficient string operations
|
||||
const QList<QStringView> iidParameters = QStringView{jsonIid}.split(QLatin1Char(':'));
|
||||
|
||||
DEBUG_LOG(logger) << "Plugin " << absoluteFilePath << " provides iid '" << jsonIid;
|
||||
|
||||
if (iidParameters.count() != 3)
|
||||
@@ -316,7 +292,6 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
|
||||
}
|
||||
|
||||
PluginType pluginType = PluginType::UNKNOWN;
|
||||
|
||||
const QString pluginName = iidParameters.at(2).toString();
|
||||
const QString pluginTypeString = iidParameters.at(0).toString();
|
||||
switch (pluginTypes.indexOf(pluginTypeString))
|
||||
@@ -367,11 +342,9 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
|
||||
|
||||
{
|
||||
QMutableListIterator<QString> i (requiredPluginsList);
|
||||
|
||||
while (i.hasNext())
|
||||
{
|
||||
const QString requiredPlugin = i.next().toLower();
|
||||
|
||||
if (pluginName == requiredPlugin)
|
||||
{
|
||||
found = true;
|
||||
@@ -381,13 +354,11 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!found)
|
||||
{
|
||||
for (auto i = optionalPluginsList.constBegin(); i != optionalPluginsList.constEnd(); i++)
|
||||
{
|
||||
const QString optionalPlugin = (*i).toLower();
|
||||
|
||||
if (pluginName == optionalPlugin)
|
||||
{
|
||||
found = true;
|
||||
@@ -396,25 +367,19 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!found)
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " was not requested";
|
||||
continue; // plugin was not requested to be loaded
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// before we create a new instance of a plugin, which is not needed as one instance is perfectly fine to use for many apps, look it up in the loaded plugins list
|
||||
|
||||
if (loadPlugin && !m_loadedPlugins.isEmpty()) // only lookup if there is something to lookup TODO: faster to NOT do that check?
|
||||
{
|
||||
QMap<PluginKey, PluginInstance>::iterator i = m_loadedPlugins.find(PluginKey(requestedPluginType, pluginName));
|
||||
|
||||
if (i != m_loadedPlugins.end())
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " already loaded, using that instance ("<<i.value().plugin->metaObject()->className()<<")";
|
||||
|
||||
loadPlugin(i.value());
|
||||
continue; // found, next plugin!
|
||||
}
|
||||
@@ -422,7 +387,6 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
|
||||
|
||||
// plugin not already loaded:
|
||||
QObject *plugin = pluginLoader->instance();
|
||||
|
||||
if (!plugin)
|
||||
{
|
||||
ERROR_LOG(logger) << "Failed to load " << filename << " - " << pluginLoader->errorString();
|
||||
@@ -435,7 +399,6 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
|
||||
pi.fullFileName = absoluteFilePath;
|
||||
pi.plugin = plugin;
|
||||
pi.pluginLoader = pluginLoader.get();
|
||||
|
||||
if (loadPlugin && !loadPlugin(pi)) // does the dev want this plugin? if no, unload it! TODO: really unload? or still cache it??
|
||||
{
|
||||
DEBUG_LOG(logger) << "Plugin " << pluginName << " unloaded";
|
||||
@@ -444,7 +407,6 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
|
||||
continue; // next plugin
|
||||
}
|
||||
pi.pluginLoader = pluginLoader.release();
|
||||
|
||||
// the dev decided to use that plugin, so cache it
|
||||
m_loadedPlugins.insert(PluginKey(requestedPluginType, pluginName), pi);
|
||||
|
||||
@@ -454,13 +416,11 @@ bool LtsPluginLoader::loadPlugins(PluginType requestedPluginType,
|
||||
DEBUG_LOG(logger) << "Loaded " << jsonIid << " - File: " << filename;
|
||||
} // end of >> pluginDir.hasNext();
|
||||
|
||||
|
||||
if (checkPluginsLists && !requiredPluginsList.isEmpty())
|
||||
{
|
||||
WARNING_LOG(logger) << "These plugins could not be found for Plugin Type " << (int)requestedPluginType << ": " << requiredPluginsList.join(QStringLiteral(", "));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user