Remove obsolete plugin storage

Plugin storage was used before the value cache existed. With the
value cache this is no longer used and can be removed.

refs #660
This commit is contained in:
Roland Winklmeier
2016-05-24 16:45:14 +02:00
parent 2d8f56a598
commit 602beb0da2
18 changed files with 9 additions and 137 deletions

View File

@@ -342,7 +342,7 @@ namespace BlackCore
Q_ASSERT(this->getIContextNetwork()->isUsingImplementingObject());
IOwnAircraftProvider *ownAircraftProvider = this->getRuntime()->getCContextOwnAircraft();
IRemoteAircraftProvider *renderedAircraftProvider = this->getRuntime()->getCContextNetwork();
ISimulator *simulator = factory->create(simulatorInfo, ownAircraftProvider, renderedAircraftProvider, m_plugins, &m_weatherManager);
ISimulator *simulator = factory->create(simulatorInfo, ownAircraftProvider, renderedAircraftProvider, &m_weatherManager);
Q_ASSERT_X(simulator, Q_FUNC_INFO, "no simulator driver can be created");
bool c = connect(simulator, &ISimulator::simulatorStatusChanged, this, &CContextSimulator::ps_onSimulatorStatusChanged);

View File

@@ -27,38 +27,6 @@ namespace BlackCore
{
}
CVariant CPluginManagerSimulator::getPluginData(const QObject *obj, const QString &key) const
{
const QObject *p = obj;
while (p && !p->inherits("BlackCore::ISimulatorFactory"))
{
p = p->parent();
}
if (!p) return CVariant();
QString id = getIdByPlugin(p);
Q_ASSERT(!id.isEmpty());
const PluginExtended &pe = m_plugins[id];
return pe.storage.value(key);
}
void CPluginManagerSimulator::setPluginData(const QObject *obj, const QString &key, const CVariant &value)
{
const QObject *p = obj;
while (p && !p->inherits("BlackCore::ISimulatorFactory"))
{
p = p->parent();
}
if (!p) return;
QString id = getIdByPlugin(p);
Q_ASSERT(!id.isEmpty());
PluginExtended &pe = m_plugins[id];
pe.storage.insert(key, value);
}
ISimulatorFactory *CPluginManagerSimulator::getFactory(const QString &pluginId)
{
return getPluginById<ISimulatorFactory>(pluginId);

View File

@@ -14,7 +14,6 @@
#include "blackcore/blackcoreexport.h"
#include "blackcore/pluginmanager.h"
#include "blackmisc/pluginstorageprovider.h"
#include "blackmisc/sequence.h"
#include "blackmisc/simulation/simulatorplugininfo.h"
#include "blackmisc/simulation/simulatorplugininfolist.h"
@@ -34,8 +33,7 @@ namespace BlackCore
* Manages plugins for the simulator context.
*/
class BLACKCORE_EXPORT CPluginManagerSimulator :
public BlackCore::IPluginManager,
public BlackMisc::IPluginStorageProvider
public BlackCore::IPluginManager
{
Q_OBJECT
@@ -43,12 +41,6 @@ namespace BlackCore
//! Ctor
CPluginManagerSimulator(QObject *parent = nullptr);
//! \copydoc BlackMisc::IPluginStorageProvider::getPluginData
virtual BlackMisc::CVariant getPluginData(const QObject *obj, const QString &key) const override;
//! \copydoc BlackMisc::IPluginStorageProvider::setPluginData
virtual void setPluginData(const QObject *obj, const QString &key, const BlackMisc::CVariant &value) override;
//! Get simulator factory from the plugin
ISimulatorFactory *getFactory(const QString &pluginId);
@@ -81,7 +73,6 @@ namespace BlackCore
{
BlackMisc::Simulation::CSimulatorPluginInfo info;
ISimulatorListener *listener = nullptr;
QHash<QString, BlackMisc::CVariant> storage; //!< Permanent plugin storage - data stored here will be kept even when plugin is unloaded
};
QMap<QString, PluginExtended> m_plugins; //!< Id <-> extended data pairs

View File

@@ -62,7 +62,6 @@ namespace BlackCore
struct PluginExtended
{
BlackMisc::Weather::CWeatherDataPluginInfo info;
QHash<QString, BlackMisc::CVariant> storage; //!< Permanent plugin storage - data stored here will be kept even when plugin is unloaded
};
QMap<QString, PluginExtended> m_plugins; //!< Id <-> extended data pairs

View File

@@ -31,7 +31,6 @@
namespace BlackMisc
{
class IPluginStorageProvider;
namespace Aviation { class CCallsign; }
namespace Network { class CTextMessage; }
namespace Simulation
@@ -291,14 +290,12 @@ namespace BlackCore
//! \param info metadata about simulator
//! \param ownAircraftProvider in memory access to own aircraft data
//! \param remoteAircraftProvider in memory access to rendered aircraft data such as situation history and aircraft itself
//! \param pluginStorageProvider in memory access to persistent plugin data store
//! \param weatherGridProvider in memory access to weather grid data
//! \return driver instance
virtual ISimulator *create(
const BlackMisc::Simulation::CSimulatorPluginInfo &info,
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
BlackMisc::IPluginStorageProvider *pluginStorageProvider,
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider) = 0;
//! Simulator listener instance

View File

@@ -36,13 +36,11 @@ namespace BlackCore
CSimulatorCommon::CSimulatorCommon(const CSimulatorPluginInfo &info,
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
IPluginStorageProvider *pluginStorageProvider,
IWeatherGridProvider *weatherGridProvider,
QObject *parent)
: ISimulator(parent),
COwnAircraftAware(ownAircraftProvider),
CRemoteAircraftAware(remoteAircraftProvider),
CPluginStorageAware(pluginStorageProvider),
CWeatherGridAware(weatherGridProvider),
m_simulatorPluginInfo(info)
{

View File

@@ -21,7 +21,6 @@
#include "blackcore/simulator.h"
#include "blackmisc/aviation/callsignset.h"
#include "blackmisc/connectionguard.h"
#include "blackmisc/pluginstorageprovider.h"
#include "blackmisc/pq/length.h"
#include "blackmisc/pq/time.h"
#include "blackmisc/pq/units.h"
@@ -58,7 +57,6 @@ namespace BlackCore
public BlackCore::ISimulator,
public BlackMisc::Simulation::COwnAircraftAware, // gain access to in memory own aircraft data
public BlackMisc::Simulation::CRemoteAircraftAware, // gain access to in memory remote aircraft data
public BlackMisc::CPluginStorageAware, // gain access to in memory plugin storage
public BlackMisc::Weather::CWeatherGridAware // gain access to in memory weather grid
{
Q_OBJECT
@@ -110,7 +108,6 @@ namespace BlackCore
CSimulatorCommon(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
BlackMisc::IPluginStorageProvider *pluginStorageProvider,
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider,
QObject *parent);

View File

@@ -1,63 +0,0 @@
/* Copyright (C) 2015
* swift project Community / Contributors
*
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
* including this file, may be copied, modified, propagated, or distributed except according to the terms
* contained in the LICENSE file.
*/
//! \file
#ifndef BLACKMISC_PLUGINSTORAGEPROVIDER_H
#define BLACKMISC_PLUGINSTORAGEPROVIDER_H
#include "blackmisc/variant.h"
#include <QObject>
namespace BlackMisc
{
//! Interface for a plugin storage provider.
//! It allows plugins to store any arbitrary data which can be packed into a \sa CVariant
//! Every plugin shall have its own data area. This means multiple plugins can store
//! data under the same key without overwriting each other.
class IPluginStorageProvider
{
public:
//! Destructor
virtual ~IPluginStorageProvider() {}
//! Get plugin data stored for object and identified by key
virtual CVariant getPluginData(const QObject *obj, const QString &key) const = 0;
//! Store plugin data for object, identified by key and packed into value
virtual void setPluginData(const QObject *obj, const QString &key, const CVariant &value) = 0;
};
//! Delegating class which can be directly used to access an \sa IPluginStorageProvider instance
class CPluginStorageAware
{
protected:
//! \copydoc IPluginStorageProvider::getPluginData
virtual CVariant getPluginData(const QObject *obj, const QString &key) const
{
return m_pluginStorageProvider->getPluginData(obj, key);
}
//! \copydoc IPluginStorageProvider::setPluginData
virtual void setPluginData(const QObject *obj, const QString &key, const CVariant &value)
{
m_pluginStorageProvider->setPluginData(obj, key, value);
}
//! Constructor
CPluginStorageAware(IPluginStorageProvider *pluginStorageProvider) :
m_pluginStorageProvider(pluginStorageProvider)
{
Q_ASSERT(pluginStorageProvider);
}
IPluginStorageProvider *m_pluginStorageProvider = nullptr; //!< access to object
};
} // namespace
#endif

View File

@@ -99,10 +99,9 @@ namespace BlackSimPlugin
const QSharedPointer<CLobbyClient> &lobbyClient,
IOwnAircraftProvider *ownAircraftProvider,
IRemoteAircraftProvider *remoteAircraftProvider,
IPluginStorageProvider *pluginStorageProvider,
IWeatherGridProvider *weatherGridProvider,
QObject *parent) :
CSimulatorFsCommon(info, ownAircraftProvider, remoteAircraftProvider, pluginStorageProvider, weatherGridProvider, parent),
CSimulatorFsCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, parent),
m_fs9Host(fs9Host),
m_lobbyClient(lobbyClient)
{
@@ -450,10 +449,9 @@ namespace BlackSimPlugin
const CSimulatorPluginInfo &info,
IOwnAircraftProvider *ownAircraftProvider,
IRemoteAircraftProvider *remoteAircraftProvider,
IPluginStorageProvider *pluginStorageProvider,
IWeatherGridProvider *weatherGridProvider)
{
return new CSimulatorFs9(info, m_fs9Host, m_lobbyClient, ownAircraftProvider, remoteAircraftProvider, pluginStorageProvider, weatherGridProvider, this);
return new CSimulatorFs9(info, m_fs9Host, m_lobbyClient, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, this);
}
BlackCore::ISimulatorListener *CSimulatorFs9Factory::createListener(const CSimulatorPluginInfo &info)

View File

@@ -44,7 +44,6 @@ namespace BlackSimPlugin
const QSharedPointer<CLobbyClient> &lobbyClient,
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
BlackMisc::IPluginStorageProvider *pluginStorageProvider,
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider,
QObject *parent = nullptr);
@@ -167,7 +166,6 @@ namespace BlackSimPlugin
const BlackMisc::Simulation::CSimulatorPluginInfo &info,
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
BlackMisc::IPluginStorageProvider *pluginStorageProvider,
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider) override;
//! \copydoc BlackCore::ISimulatorFactory::createListener

View File

@@ -27,10 +27,9 @@ namespace BlackSimPlugin
const CSimulatorPluginInfo &info,
IOwnAircraftProvider *ownAircraftProvider,
IRemoteAircraftProvider *renderedAircraftProvider,
IPluginStorageProvider *pluginStorageProvider,
Weather::IWeatherGridProvider *weatherGridProvider,
QObject *parent) :
CSimulatorCommon(info, ownAircraftProvider, renderedAircraftProvider, pluginStorageProvider, weatherGridProvider, parent),
CSimulatorCommon(info, ownAircraftProvider, renderedAircraftProvider, weatherGridProvider, parent),
m_fsuipc(new CFsuipc())
{ }

View File

@@ -74,7 +74,6 @@ namespace BlackSimPlugin
CSimulatorFsCommon(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
BlackMisc::Simulation::IRemoteAircraftProvider *renderedAircraftProvider,
BlackMisc::IPluginStorageProvider *pluginStorageProvider,
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider,
QObject *parent = nullptr);

View File

@@ -43,10 +43,9 @@ namespace BlackSimPlugin
CSimulatorFsx::CSimulatorFsx(const CSimulatorPluginInfo &info,
IOwnAircraftProvider *ownAircraftProvider,
IRemoteAircraftProvider *remoteAircraftProvider,
IPluginStorageProvider *pluginStorageProvider,
IWeatherGridProvider *weatherGridProvider,
QObject *parent) :
CSimulatorFsCommon(info, ownAircraftProvider, remoteAircraftProvider, pluginStorageProvider, weatherGridProvider, parent)
CSimulatorFsCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, parent)
{
Q_ASSERT_X(ownAircraftProvider, Q_FUNC_INFO, "Missing provider");
Q_ASSERT_X(remoteAircraftProvider, Q_FUNC_INFO, "Missing provider");

View File

@@ -78,7 +78,6 @@ namespace BlackSimPlugin
const BlackMisc::Simulation::CSimulatorPluginInfo &info,
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
BlackMisc::IPluginStorageProvider *pluginStorageProvider,
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider,
QObject *parent = nullptr);

View File

@@ -19,11 +19,10 @@ namespace BlackSimPlugin
BlackCore::ISimulator *CSimulatorFsxFactory::create(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
BlackMisc::IPluginStorageProvider *pluginStorageProvider,
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider)
{
Q_ASSERT(ownAircraftProvider);
return new CSimulatorFsx(info, ownAircraftProvider, remoteAircraftProvider, pluginStorageProvider, weatherGridProvider, this);
return new CSimulatorFsx(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, this);
}
BlackCore::ISimulatorListener *CSimulatorFsxFactory::createListener(const BlackMisc::Simulation::CSimulatorPluginInfo &info)

View File

@@ -37,7 +37,6 @@ namespace BlackSimPlugin
virtual BlackCore::ISimulator *create(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
BlackMisc::IPluginStorageProvider *pluginStorageProvider,
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider) override;
//! \copydoc BlackCore::ISimulatorFactory::createListener

View File

@@ -83,10 +83,9 @@ namespace BlackSimPlugin
CSimulatorXPlane::CSimulatorXPlane(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
IOwnAircraftProvider *ownAircraftProvider,
IRemoteAircraftProvider *remoteAircraftProvider,
IPluginStorageProvider *pluginStorageProvider,
IWeatherGridProvider *weatherGridProvider,
QObject *parent) :
CSimulatorCommon(info, ownAircraftProvider, remoteAircraftProvider, pluginStorageProvider, weatherGridProvider, parent)
CSimulatorCommon(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, parent)
{
m_watcher = new QDBusServiceWatcher(this);
m_watcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration);
@@ -640,10 +639,9 @@ namespace BlackSimPlugin
BlackCore::ISimulator *CSimulatorXPlaneFactory::create(const CSimulatorPluginInfo &info,
IOwnAircraftProvider *ownAircraftProvider,
IRemoteAircraftProvider *remoteAircraftProvider,
IPluginStorageProvider *pluginStorageProvider,
IWeatherGridProvider *weatherGridProvider)
{
return new CSimulatorXPlane(info, ownAircraftProvider, remoteAircraftProvider, pluginStorageProvider, weatherGridProvider, this);
return new CSimulatorXPlane(info, ownAircraftProvider, remoteAircraftProvider, weatherGridProvider, this);
}
CSimulatorXPlaneListener::CSimulatorXPlaneListener(const CSimulatorPluginInfo &info): ISimulatorListener(info)

View File

@@ -39,7 +39,6 @@ class QTimer;
namespace BlackMisc
{
class IPluginStorageProvider;
namespace Aviation
{
class CAircraftParts;
@@ -75,7 +74,6 @@ namespace BlackSimPlugin
CSimulatorXPlane(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
BlackMisc::IPluginStorageProvider *pluginStorageProvider,
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider,
QObject *parent = nullptr);
@@ -234,7 +232,6 @@ namespace BlackSimPlugin
virtual BlackCore::ISimulator *create(const BlackMisc::Simulation::CSimulatorPluginInfo &info,
BlackMisc::Simulation::IOwnAircraftProvider *ownAircraftProvider,
BlackMisc::Simulation::IRemoteAircraftProvider *remoteAircraftProvider,
BlackMisc::IPluginStorageProvider *pluginStorageProvider,
BlackMisc::Weather::IWeatherGridProvider *weatherGridProvider) override;
//! \copydoc BlackCore::ISimulatorFactory::createListener