Skip to content

Commit

Permalink
Eliminating plugin properties altogether.
Browse files Browse the repository at this point in the history
  • Loading branch information
arobenko committed Nov 4, 2024
1 parent 6ed27e7 commit 7a6d34a
Show file tree
Hide file tree
Showing 22 changed files with 42 additions and 244 deletions.
2 changes: 1 addition & 1 deletion app/cc_view/src/widget/PluginConfigWrapsListWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void PluginConfigWrapsListWidget::addPluginConfig(PluginInfoPtr pluginInfo)

m_loadedPlugins.push_back(plugin);

auto* configWidget = plugin->createConfiguarionWidget();
auto* configWidget = plugin->createConfigurationWidget();
if (configWidget == nullptr) {
return;
}
Expand Down
55 changes: 20 additions & 35 deletions lib/include/cc_tools_qt/Plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@

#pragma once

#include <string>
#include <cassert>
#include <memory>
#include "cc_tools_qt/Api.h"
#include "cc_tools_qt/Socket.h"
#include "cc_tools_qt/Filter.h"
#include "cc_tools_qt/ToolsProtocol.h"

#include <QtCore/QObject>
#include <QtCore/QList>
#include <QtCore/QtPlugin>
#include <QtCore/QVariantMap>

#include "Api.h"
#include "PluginProperties.h"

class QAction;
class QWidget;

namespace cc_tools_qt
Expand All @@ -47,11 +47,8 @@ class CC_API Plugin : public QObject
Type_NumOfValues
};

/// @brief Pointer to widget object
using WidgetPtr = std::unique_ptr<QWidget>;

/// @brief List of GUI action buttons
using ListOfGuiActions = PluginProperties::ListOfGuiActions;
using ListOfGuiActions = QList<QAction*>;

/// @brief Constructor
explicit Plugin(Type type);
Expand Down Expand Up @@ -97,16 +94,6 @@ class CC_API Plugin : public QObject
/// @return Allocated protocol object
ToolsProtocolPtr createProtocol();

/// @brief Create GUI actions relevant to the plugin.
/// @details This function will invoke the relevant callback function
/// assigned by the derived class to pluginProperties(). The callback
/// function is responsible to allocate and return a list of
/// @b QAction objects, which will appear to the main toolbar of the
/// GUI application. Note, that the main application will @b own the
/// allocated @b QAction objects and will delete them later. The plugin
/// doesn't need to do it explicityly.
/// @return List of GUI QAction objects.
ListOfGuiActions createGuiActions() const;

/// @brief Create a widget to perform plugin configuration in GUI application.
/// @details Sometimes there is a need to provide a way to configure the
Expand All @@ -116,13 +103,18 @@ class CC_API Plugin : public QObject
/// GUI application, i.e. the plugin doesn't need to perform any
/// delete operation on it.
/// @return Dynamically allocated widget object
QWidget* createConfiguarionWidget();
QWidget* createConfigurationWidget();

/// @brief Retrieve custom property assigned by the derived class.
/// @param[in] name Name of the property
/// @return Property value. The value needs to be converted to
/// proper type by the caller.
QVariant getCustomProperty(const QString& name);
/// @brief Create GUI actions relevant to the plugin.
/// @details This function will invoke the relevant callback function
/// assigned by the derived class to pluginProperties(). The callback
/// function is responsible to allocate and return a list of
/// @b QAction objects, which will appear to the main toolbar of the
/// GUI application. Note, that the main application will @b own the
/// allocated @b QAction objects and will delete them later. The plugin
/// doesn't need to do it explicityly.
/// @return List of GUI QAction objects.
ListOfGuiActions createGuiActions();

/// @brief Apply inter-plugin configuration.
/// @details Allows one plugin to influence the configuration of another.
Expand Down Expand Up @@ -164,14 +156,8 @@ class CC_API Plugin : public QObject
virtual SocketPtr createSocketImpl();
virtual FilterPtr createFilterImpl();
virtual ToolsProtocolPtr createProtocolImpl();
virtual QWidget* createConfiguarionWidgetImpl();

/// @brief Get access to plugin properties
/// @details Expected to be called by the derived class to get an access
/// to the properties accumulation objects and provide appropriate
/// callbacks and/or other custom properties.
/// @return Reference to plugin properties object
PluginProperties& pluginProperties();
virtual QWidget* createConfigurationWidgetImpl();
virtual ListOfGuiActions createGuiActionsImpl();

/// @brief Report inter-plugin configuration.
/// @details Sometimes configuration of one plugin may influence configuration of another.
Expand All @@ -183,7 +169,6 @@ class CC_API Plugin : public QObject

private:
Type m_type = Type_NumOfValues;
PluginProperties m_props;
InterPluginConfigReportCallback m_interPluginConfigReportCallback;
unsigned m_debugOutputLevel = 0U;
};
Expand Down
1 change: 0 additions & 1 deletion lib/include/cc_tools_qt/PluginMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class CC_API PluginMgr

typedef std::shared_ptr<PluginInfo> PluginInfoPtr;
typedef std::list<PluginInfoPtr> ListOfPluginInfos;
typedef Plugin::WidgetPtr WidgetPtr;

PluginMgr();
~PluginMgr() noexcept;
Expand Down
85 changes: 0 additions & 85 deletions lib/include/cc_tools_qt/PluginProperties.h

This file was deleted.

1 change: 0 additions & 1 deletion lib/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ function (lib_tools)
MessageHandler.cpp
Plugin.cpp
DataInfo.cpp
PluginProperties.cpp
ConfigMgr.cpp
PluginMgr.cpp
PluginMgrImpl.cpp
Expand Down
19 changes: 7 additions & 12 deletions lib/src/Plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,14 @@ ToolsProtocolPtr Plugin::createProtocol()
return protocolPtr;
}

Plugin::ListOfGuiActions Plugin::createGuiActions() const
QWidget* Plugin::createConfigurationWidget()
{
return invokeCreationFunc(m_props.getGuiActionsCreateFunc());
return createConfigurationWidgetImpl();
}

QWidget* Plugin::createConfiguarionWidget()
Plugin::ListOfGuiActions Plugin::createGuiActions()
{
return createConfiguarionWidgetImpl();
}

QVariant Plugin::getCustomProperty(const QString& name)
{
return m_props.getCustomProperty(name);
return createGuiActionsImpl();
}

void Plugin::applyInterPluginConfig(const QVariantMap& props)
Expand Down Expand Up @@ -167,14 +162,14 @@ ToolsProtocolPtr Plugin::createProtocolImpl()
return ToolsProtocolPtr();
}

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

PluginProperties& Plugin::pluginProperties()
Plugin::ListOfGuiActions Plugin::createGuiActionsImpl()
{
return m_props;
return ListOfGuiActions();
}

void Plugin::reportInterPluginConfig(const QVariantMap& props)
Expand Down
1 change: 0 additions & 1 deletion lib/src/PluginMgrImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class PluginMgrImpl
typedef PluginMgr::PluginInfo PluginInfo;
typedef PluginMgr::PluginInfoPtr PluginInfoPtr;
typedef PluginMgr::ListOfPluginInfos ListOfPluginInfos;
typedef Plugin::WidgetPtr WidgetPtr;

PluginMgrImpl();
~PluginMgrImpl() noexcept;
Expand Down
94 changes: 0 additions & 94 deletions lib/src/PluginProperties.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion plugin/serial_socket/SerialSocketPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ SocketPtr SerialSocketPlugin::createSocketImpl()
return m_socket;
}

QWidget* SerialSocketPlugin::createConfiguarionWidgetImpl()
QWidget* SerialSocketPlugin::createConfigurationWidgetImpl()
{
createSocketIfNeeded();
return new SerialSocketConfigWidget(*m_socket);
Expand Down
2 changes: 1 addition & 1 deletion plugin/serial_socket/SerialSocketPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SerialSocketPlugin : public cc_tools_qt::Plugin
virtual void getCurrentConfigImpl(QVariantMap& config) override;
virtual void reconfigureImpl(const QVariantMap& config) override;
virtual SocketPtr createSocketImpl() override;
virtual QWidget* createConfiguarionWidgetImpl() override;
virtual QWidget* createConfigurationWidgetImpl() override;
private:

void createSocketIfNeeded();
Expand Down
2 changes: 1 addition & 1 deletion plugin/ssl_socket/client/SslClientSocketPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ SocketPtr SslClientSocketPlugin::createSocketImpl()
return m_socket;
}

QWidget* SslClientSocketPlugin::createConfiguarionWidgetImpl()
QWidget* SslClientSocketPlugin::createConfigurationWidgetImpl()
{
createSocketIfNeeded();
return new SslClientSocketConfigWidget(*m_socket);
Expand Down
2 changes: 1 addition & 1 deletion plugin/ssl_socket/client/SslClientSocketPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SslClientSocketPlugin : public cc_tools_qt::Plugin
virtual void reconfigureImpl(const QVariantMap& config) override;
virtual void applyInterPluginConfigImpl(const QVariantMap& props) override;
virtual SocketPtr createSocketImpl() override;
virtual QWidget* createConfiguarionWidgetImpl() override;
virtual QWidget* createConfigurationWidgetImpl() override;

private:

Expand Down
Loading

0 comments on commit 7a6d34a

Please sign in to comment.