Skip to content

Commit

Permalink
Refining ToolsPlugin class.
Browse files Browse the repository at this point in the history
  • Loading branch information
arobenko committed Nov 4, 2024
1 parent 7a6d34a commit f7950ac
Show file tree
Hide file tree
Showing 20 changed files with 86 additions and 86 deletions.
2 changes: 1 addition & 1 deletion app/cc_view/src/GuiAppMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ bool GuiAppMgr::applyNewPlugins(const ListOfPluginInfos& plugins)

auto applyInfo = ApplyInfo();
for (auto& info : plugins) {
Plugin* plugin = pluginMgr.loadPlugin(*info);
auto* plugin = pluginMgr.loadPlugin(*info);
if (plugin == nullptr) {
[[maybe_unused]] static constexpr bool Failed_to_load_plugin = false;
assert(Failed_to_load_plugin);
Expand Down
2 changes: 1 addition & 1 deletion app/cc_view/src/widget/PluginConfigWrapsListWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class PluginConfigWrapsListWidget: public QWidget
using PluginConfigWrapWidgetPtr = std::unique_ptr<PluginConfigWrapWidget>;
using WrapWidgetsList = std::vector<PluginConfigWrapWidgetPtr>;
WrapWidgetsList m_widgets;
std::vector<Plugin*> m_loadedPlugins;
std::vector<ToolsPlugin*> m_loadedPlugins;
};

} // namespace cc_tools_qt
8 changes: 4 additions & 4 deletions demo/cc_plugin/DemoPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#pragma once

#include "cc_tools_qt/Plugin.h"
#include "cc_tools_qt/ToolsPlugin.h"

#include <QtCore/QObject>
#include <QtCore/QtPlugin>
Expand All @@ -29,13 +29,13 @@ namespace demo
namespace cc_plugin
{

class DemoPlugin : public cc_tools_qt::Plugin
class DemoPlugin : public cc_tools_qt::ToolsPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "cc.DemoProtocol" FILE "demo.json")
Q_INTERFACES(cc_tools_qt::Plugin)
Q_INTERFACES(cc_tools_qt::ToolsPlugin)

using Base = cc_tools_qt::Plugin;
using Base = cc_tools_qt::ToolsPlugin;

public:
DemoPlugin();
Expand Down
6 changes: 3 additions & 3 deletions lib/include/cc_tools_qt/PluginMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include <QtCore/QVariantMap>
#include <QtCore/QPluginLoader>

#include "Api.h"
#include "Plugin.h"
#include "cc_tools_qt/Api.h"
#include "cc_tools_qt/ToolsPlugin.h"

namespace cc_tools_qt
{
Expand Down Expand Up @@ -98,7 +98,7 @@ class CC_API PluginMgr
ListOfPluginInfos loadPluginsFromConfig(const QVariantMap& config);
ListOfPluginInfos loadPluginsFromConfigFile(const QString& filename);
bool savePluginsToConfigFile(const ListOfPluginInfos& infos, const QString& filename);
Plugin* loadPlugin(const PluginInfo& info);
ToolsPlugin* loadPlugin(const PluginInfo& info);
bool hasAppliedPlugins() const;
bool needsReload(const ListOfPluginInfos& infos) const;
bool isProtocolChanging(const ListOfPluginInfos& infos) const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ namespace cc_tools_qt
{

/// @brief Interface class for plugin definition
/// @headerfile cc_tools_qt/Plugin.h
class CC_API Plugin : public QObject
/// @headerfile cc_tools_qt/ToolsPlugin.h
class CC_API ToolsPlugin : public QObject
{
public:
enum Type : unsigned
Expand All @@ -51,10 +51,10 @@ class CC_API Plugin : public QObject
using ListOfGuiActions = QList<QAction*>;

/// @brief Constructor
explicit Plugin(Type type);
explicit ToolsPlugin(Type type);

/// @brief Destructor
virtual ~Plugin() noexcept;
virtual ~ToolsPlugin() noexcept;

Type type() const;

Expand Down Expand Up @@ -175,6 +175,6 @@ class CC_API Plugin : public QObject

} // namespace cc_tools_qt

Q_DECLARE_INTERFACE(cc_tools_qt::Plugin, "cc.Plugin")
Q_DECLARE_INTERFACE(cc_tools_qt::ToolsPlugin, "cc.ToolsPlugin")


2 changes: 1 addition & 1 deletion lib/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ function (lib_tools)
Filter.cpp
Socket.cpp
MessageHandler.cpp
Plugin.cpp
DataInfo.cpp
ConfigMgr.cpp
PluginMgr.cpp
Expand All @@ -34,6 +33,7 @@ function (lib_tools)
ToolsFieldHandler.cpp
ToolsFrame.cpp
ToolsMsgFactory.cpp
ToolsPlugin.cpp
ToolsProtocol.cpp
property/message.cpp
)
Expand Down
2 changes: 1 addition & 1 deletion lib/src/PluginMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ bool PluginMgr::savePluginsToConfigFile(
return m_impl->savePluginsToConfigFile(infos, filename);
}

Plugin* PluginMgr::loadPlugin(const PluginInfo& info)
ToolsPlugin* PluginMgr::loadPlugin(const PluginInfo& info)
{
return m_impl->loadPlugin(info);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/src/PluginMgrImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <QtCore/QJsonArray>
#include <QtCore/QVariantList>

#include "cc_tools_qt/Plugin.h"
#include "cc_tools_qt/ToolsPlugin.h"

namespace cc_tools_qt
{
Expand All @@ -55,10 +55,10 @@ struct PluginLoaderDeleter
}
};

Plugin* getPlugin(QPluginLoader& loader)
ToolsPlugin* getPlugin(QPluginLoader& loader)
{
auto* inst = loader.instance();
auto* plugin = qobject_cast<Plugin*>(loader.instance());
auto* plugin = qobject_cast<ToolsPlugin*>(loader.instance());

do {
if (plugin != nullptr) {
Expand Down Expand Up @@ -229,7 +229,7 @@ bool PluginMgrImpl::savePluginsToConfigFile(
return m_configMgr.saveConfig(filename, config);
}

Plugin* PluginMgrImpl::loadPlugin(const PluginInfo& info)
ToolsPlugin* PluginMgrImpl::loadPlugin(const PluginInfo& info)
{
return getPlugin(*info.m_loader);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/PluginMgrImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <QtCore/QVariantMap>
#include <QtCore/QPluginLoader>

#include "cc_tools_qt/Plugin.h"
#include "cc_tools_qt/ToolsPlugin.h"
#include "cc_tools_qt/PluginMgr.h"
#include "cc_tools_qt/ConfigMgr.h"

Expand All @@ -54,7 +54,7 @@ class PluginMgrImpl
ListOfPluginInfos loadPluginsFromConfig(const QVariantMap& config);
ListOfPluginInfos loadPluginsFromConfigFile(const QString& filename);
bool savePluginsToConfigFile(const ListOfPluginInfos& infos, const QString& filename);
Plugin* loadPlugin(const PluginInfo& info);
ToolsPlugin* loadPlugin(const PluginInfo& info);
bool hasAppliedPlugins() const;
bool needsReload(const ListOfPluginInfos& infos) const;
bool isProtocolChanging(const ListOfPluginInfos& infos) const;
Expand Down
48 changes: 24 additions & 24 deletions lib/src/Plugin.cpp → lib/src/ToolsPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#include "cc_tools_qt/Plugin.h"
#include "cc_tools_qt/ToolsPlugin.h"

namespace cc_tools_qt
{
Expand All @@ -37,37 +37,37 @@ auto invokeCreationFunc(TFunc&& func) -> decltype(func())

} // namespace

Plugin::Plugin(Type type) :
ToolsPlugin::ToolsPlugin(Type type) :
m_type(type)
{
assert(type < Type_NumOfValues);
}

Plugin::~Plugin() noexcept = default;
ToolsPlugin::~ToolsPlugin() noexcept = default;

Plugin::Type Plugin::type() const
ToolsPlugin::Type ToolsPlugin::type() const
{
return m_type;
}

void Plugin::getCurrentConfig(QVariantMap& config)
void ToolsPlugin::getCurrentConfig(QVariantMap& config)
{
getCurrentConfigImpl(config);
}

QVariantMap Plugin::getCurrentConfig()
QVariantMap ToolsPlugin::getCurrentConfig()
{
QVariantMap config;
getCurrentConfig(config);
return config;
}

void Plugin::reconfigure(const QVariantMap& config)
void ToolsPlugin::reconfigure(const QVariantMap& config)
{
reconfigureImpl(config);
}

SocketPtr Plugin::createSocket()
SocketPtr ToolsPlugin::createSocket()
{
if (m_type != Type_Socket) {
return SocketPtr();
Expand All @@ -81,7 +81,7 @@ SocketPtr Plugin::createSocket()
return socketPtr;
}

FilterPtr Plugin::createFilter()
FilterPtr ToolsPlugin::createFilter()
{
if (m_type != Type_Filter) {
return FilterPtr();
Expand All @@ -95,7 +95,7 @@ FilterPtr Plugin::createFilter()
return filterPtr;
}

ToolsProtocolPtr Plugin::createProtocol()
ToolsProtocolPtr ToolsPlugin::createProtocol()
{
if (m_type != Type_Protocol) {
return ToolsProtocolPtr();
Expand All @@ -110,69 +110,69 @@ ToolsProtocolPtr Plugin::createProtocol()
return protocolPtr;
}

QWidget* Plugin::createConfigurationWidget()
QWidget* ToolsPlugin::createConfigurationWidget()
{
return createConfigurationWidgetImpl();
}

Plugin::ListOfGuiActions Plugin::createGuiActions()
ToolsPlugin::ListOfGuiActions ToolsPlugin::createGuiActions()
{
return createGuiActionsImpl();
}

void Plugin::applyInterPluginConfig(const QVariantMap& props)
void ToolsPlugin::applyInterPluginConfig(const QVariantMap& props)
{
applyInterPluginConfigImpl(props);
}

void Plugin::setInterPluginConfigReportCallback(InterPluginConfigReportCallback&& func)
void ToolsPlugin::setInterPluginConfigReportCallback(InterPluginConfigReportCallback&& func)
{
m_interPluginConfigReportCallback = std::move(func);
}

void Plugin::setDebugOutputLevel(unsigned level)
void ToolsPlugin::setDebugOutputLevel(unsigned level)
{
m_debugOutputLevel = level;
}

void Plugin::getCurrentConfigImpl([[maybe_unused]] QVariantMap& config)
void ToolsPlugin::getCurrentConfigImpl([[maybe_unused]] QVariantMap& config)
{
}

void Plugin::reconfigureImpl([[maybe_unused]] const QVariantMap& config)
void ToolsPlugin::reconfigureImpl([[maybe_unused]] const QVariantMap& config)
{
}

void Plugin::applyInterPluginConfigImpl([[maybe_unused]] const QVariantMap& props)
void ToolsPlugin::applyInterPluginConfigImpl([[maybe_unused]] const QVariantMap& props)
{
}

SocketPtr Plugin::createSocketImpl()
SocketPtr ToolsPlugin::createSocketImpl()
{
return SocketPtr();
}

FilterPtr Plugin::createFilterImpl()
FilterPtr ToolsPlugin::createFilterImpl()
{
return FilterPtr();
}

ToolsProtocolPtr Plugin::createProtocolImpl()
ToolsProtocolPtr ToolsPlugin::createProtocolImpl()
{
return ToolsProtocolPtr();
}

QWidget* Plugin::createConfigurationWidgetImpl()
QWidget* ToolsPlugin::createConfigurationWidgetImpl()
{
return nullptr;
}

Plugin::ListOfGuiActions Plugin::createGuiActionsImpl()
ToolsPlugin::ListOfGuiActions ToolsPlugin::createGuiActionsImpl()
{
return ListOfGuiActions();
}

void Plugin::reportInterPluginConfig(const QVariantMap& props)
void ToolsPlugin::reportInterPluginConfig(const QVariantMap& props)
{
if (m_interPluginConfigReportCallback) {
m_interPluginConfigReportCallback(props);
Expand Down
8 changes: 4 additions & 4 deletions plugin/echo_socket/EchoSocketPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <memory>

#include "cc_tools_qt/Plugin.h"
#include "cc_tools_qt/ToolsPlugin.h"
#include "cc_tools_qt/Socket.h"

namespace cc_tools_qt
Expand All @@ -29,13 +29,13 @@ namespace cc_tools_qt
namespace plugin
{

class EchoSocketPlugin : public cc_tools_qt::Plugin
class EchoSocketPlugin : public cc_tools_qt::ToolsPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "cc.EchoSocketPlugin" FILE "echo_socket.json")
Q_INTERFACES(cc_tools_qt::Plugin)
Q_INTERFACES(cc_tools_qt::ToolsPlugin)

using Base = cc_tools_qt::Plugin;
using Base = cc_tools_qt::ToolsPlugin;

public:
EchoSocketPlugin();
Expand Down
8 changes: 4 additions & 4 deletions plugin/null_socket/NullSocketPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include <memory>

#include "cc_tools_qt/Plugin.h"
#include "cc_tools_qt/ToolsPlugin.h"
#include "cc_tools_qt/Socket.h"

namespace cc_tools_qt
Expand All @@ -29,13 +29,13 @@ namespace cc_tools_qt
namespace plugin
{

class NullSocketPlugin : public cc_tools_qt::Plugin
class NullSocketPlugin : public cc_tools_qt::ToolsPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "cc.NullSocketPlugin" FILE "null_socket.json")
Q_INTERFACES(cc_tools_qt::Plugin)
Q_INTERFACES(cc_tools_qt::ToolsPlugin)

using Base = cc_tools_qt::Plugin;
using Base = cc_tools_qt::ToolsPlugin;

public:
NullSocketPlugin();
Expand Down
Loading

0 comments on commit f7950ac

Please sign in to comment.