Skip to content

Commit

Permalink
Add common linters and make them happy to qt_gui_cpp (#295)
Browse files Browse the repository at this point in the history
Signed-off-by: Alejandro Hernández Cordero <[email protected]>
  • Loading branch information
ahcorde authored Jul 10, 2024
1 parent 93dc7e3 commit 99a8976
Show file tree
Hide file tree
Showing 37 changed files with 587 additions and 527 deletions.
3 changes: 3 additions & 0 deletions qt_gui_cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin)

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()

find_package(ament_cmake_pytest REQUIRED)

if(TARGET qt_gui_cpp_shiboken)
Expand Down
28 changes: 28 additions & 0 deletions qt_gui_cpp/cmake/qt_gui_cpp-extras.cmake
Original file line number Diff line number Diff line change
@@ -1 +1,29 @@
# Copyright (c) 2024, Open Source Robotics Foundation, Inc.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# * Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

set(qt_gui_cpp_USE_QT_MAJOR_VERSION 5)
6 changes: 3 additions & 3 deletions qt_gui_cpp/include/qt_gui_cpp/composite_plugin_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef qt_gui_cpp__CompositePluginProvider_H
#define qt_gui_cpp__CompositePluginProvider_H
#ifndef QT_GUI_CPP__COMPOSITE_PLUGIN_PROVIDER_H_
#define QT_GUI_CPP__COMPOSITE_PLUGIN_PROVIDER_H_

// *INDENT-OFF* (prevent uncrustify from adding indention below)
#warning Including header <qt_gui_cpp/composite_plugin_provider.h> is deprecated, \
include <qt_gui_cpp/composite_plugin_provider.hpp> instead.
// *INDENT-ON*
#include "./composite_plugin_provider.hpp"

#endif // qt_gui_cpp__CompositePluginProvider_H
#endif // QT_GUI_CPP__COMPOSITE_PLUGIN_PROVIDER_H_
37 changes: 17 additions & 20 deletions qt_gui_cpp/include/qt_gui_cpp/composite_plugin_provider.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,55 +30,52 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef qt_gui_cpp__CompositePluginProvider_HPP
#define qt_gui_cpp__CompositePluginProvider_HPP

#include "plugin_descriptor.hpp"
#include "plugin_provider.hpp"
#ifndef QT_GUI_CPP__COMPOSITE_PLUGIN_PROVIDER_HPP_
#define QT_GUI_CPP__COMPOSITE_PLUGIN_PROVIDER_HPP_

#include <QList>
#include <QMap>
#include <QSet>
#include <QString>

#include "plugin_descriptor.hpp"
#include "plugin_provider.hpp"

namespace qt_gui_cpp
{

class CompositePluginProvider
: public PluginProvider
{

public:

CompositePluginProvider(const QList<PluginProvider*>& plugin_providers = QList<PluginProvider*>());
CompositePluginProvider(
const QList<PluginProvider *> & plugin_providers = QList<PluginProvider *>());

virtual ~CompositePluginProvider();

/**
* @note The ownership of the plugin providers is transferred to the callee.
*/
virtual void set_plugin_providers(const QList<PluginProvider*>& plugin_providers);
virtual void set_plugin_providers(const QList<PluginProvider *> & plugin_providers);

virtual QList<PluginDescriptor*> discover_descriptors(QObject* discovery_data);
virtual QList<PluginDescriptor *> discover_descriptors(QObject * discovery_data);

virtual void* load(const QString& plugin_id, PluginContext* plugin_context);
virtual void * load(const QString & plugin_id, PluginContext * plugin_context);

virtual Plugin* load_plugin(const QString& plugin_id, PluginContext* plugin_context);
virtual Plugin * load_plugin(const QString & plugin_id, PluginContext * plugin_context);

virtual void unload(void* plugin_instance);
virtual void unload(void * plugin_instance);

virtual void shutdown();

private:
QList<PluginProvider *> plugin_providers_;

QList<PluginProvider*> plugin_providers_;

QMap<PluginProvider*, QSet<QString> > discovered_plugins_;

QMap<void*, PluginProvider*> running_plugins_;
QMap<PluginProvider *, QSet<QString>> discovered_plugins_;

QMap<void *, PluginProvider *> running_plugins_;
};

} // namespace
} // namespace qt_gui_cpp

#endif // qt_gui_cpp__CompositePluginProvider_HPP
#endif // QT_GUI_CPP__COMPOSITE_PLUGIN_PROVIDER_HPP_
6 changes: 3 additions & 3 deletions qt_gui_cpp/include/qt_gui_cpp/generic_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef qt_gui_cpp__GenericProxy_H
#define qt_gui_cpp__GenericProxy_H
#ifndef QT_GUI_CPP__GENERIC_PROXY_H_
#define QT_GUI_CPP__GENERIC_PROXY_H_

// *INDENT-OFF* (prevent uncrustify from adding indention below)
#warning Including header <qt_gui_cpp/generic_proxy.h> is deprecated, \
Expand All @@ -40,4 +40,4 @@ include <qt_gui_cpp/generic_proxy.hpp> instead.

#include "./generic_proxy.hpp"

#endif // qt_gui_cpp__GenericProxy_H
#endif // QT_GUI_CPP__GENERIC_PROXY_H_
38 changes: 23 additions & 15 deletions qt_gui_cpp/include/qt_gui_cpp/generic_proxy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef qt_gui_cpp__GenericProxy_HPP
#define qt_gui_cpp__GenericProxy_HPP
#ifndef QT_GUI_CPP__GENERIC_PROXY_HPP_
#define QT_GUI_CPP__GENERIC_PROXY_HPP_

#include <QObject>

Expand All @@ -40,25 +40,33 @@ namespace qt_gui_cpp

class GenericProxy
{

public:
explicit GenericProxy(QObject * obj = 0);

GenericProxy(QObject* obj = 0);

QObject* proxiedObject();
QObject * proxiedObject();

void setProxiedObject(QObject* obj);
void setProxiedObject(QObject * obj);

bool invokeMethod(const char* member, QGenericArgument val0 = QGenericArgument(), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), QGenericArgument val4 = QGenericArgument(), QGenericArgument val5 = QGenericArgument(), QGenericArgument val6 = QGenericArgument(), QGenericArgument val7 = QGenericArgument(), QGenericArgument val8 = QGenericArgument(), QGenericArgument val9 = QGenericArgument());
bool invokeMethod(
const char * member, QGenericArgument val0 = QGenericArgument(),
QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(),
QGenericArgument val3 = QGenericArgument(), QGenericArgument val4 = QGenericArgument(),
QGenericArgument val5 = QGenericArgument(), QGenericArgument val6 = QGenericArgument(),
QGenericArgument val7 = QGenericArgument(), QGenericArgument val8 = QGenericArgument(),
QGenericArgument val9 = QGenericArgument());

bool invokeMethodWithReturn(const char* member, QGenericReturnArgument ret = QGenericReturnArgument(0, 0), QGenericArgument val0 = QGenericArgument(), QGenericArgument val1 = QGenericArgument(), QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(), QGenericArgument val4 = QGenericArgument(), QGenericArgument val5 = QGenericArgument(), QGenericArgument val6 = QGenericArgument(), QGenericArgument val7 = QGenericArgument(), QGenericArgument val8 = QGenericArgument(), QGenericArgument val9 = QGenericArgument());
bool invokeMethodWithReturn(
const char * member,
QGenericReturnArgument ret = QGenericReturnArgument(0, 0),
QGenericArgument val0 = QGenericArgument(), QGenericArgument val1 = QGenericArgument(),
QGenericArgument val2 = QGenericArgument(), QGenericArgument val3 = QGenericArgument(),
QGenericArgument val4 = QGenericArgument(), QGenericArgument val5 = QGenericArgument(),
QGenericArgument val6 = QGenericArgument(), QGenericArgument val7 = QGenericArgument(),
QGenericArgument val8 = QGenericArgument(), QGenericArgument val9 = QGenericArgument());

private:

QObject* object_;

QObject * object_;
};
} // namespace qt_gui_cpp

} // namespace

#endif // qt_gui_cpp__GenericProxy_HPP
#endif // QT_GUI_CPP__GENERIC_PROXY_HPP_
6 changes: 3 additions & 3 deletions qt_gui_cpp/include/qt_gui_cpp/plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef qt_gui_cpp__Plugin_H
#define qt_gui_cpp__Plugin_H
#ifndef QT_GUI_CPP__PLUGIN_H_
#define QT_GUI_CPP__PLUGIN_H_

// *INDENT-OFF* (prevent uncrustify from adding indention below)
#warning Including header <qt_gui_cpp/plugin.h> is deprecated, \
Expand All @@ -40,4 +40,4 @@ include <qt_gui_cpp/plugin.hpp> instead.

#include "./plugin.hpp"

#endif // qt_gui_cpp__Plugin_H
#endif // QT_GUI_CPP__PLUGIN_H_
26 changes: 12 additions & 14 deletions qt_gui_cpp/include/qt_gui_cpp/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef qt_gui_cpp__Plugin_HPP
#define qt_gui_cpp__Plugin_HPP
#ifndef QT_GUI_CPP__PLUGIN_HPP_
#define QT_GUI_CPP__PLUGIN_HPP_

#include <QObject>

#include "plugin_bridge.hpp"
#include "plugin_context.hpp"
#include "settings.hpp"

#include <QObject>

namespace qt_gui_cpp
{

Expand All @@ -48,24 +48,22 @@ namespace qt_gui_cpp
class Plugin
: public QObject
{

Q_OBJECT

public:

/**
* Construct the plugin.
* All initialization should be performed in initPlugin().
*/
Plugin()
: QObject()
: QObject()
{}

/**
* Instantiate the plugin.
* @param the plugin context
*/
virtual void initPlugin(PluginContext& /*context*/)
virtual void initPlugin(PluginContext & /*context*/)
{}

/**
Expand All @@ -79,15 +77,17 @@ class Plugin
* @param the plugin-specific settings
* @param the instance-specific settings
*/
virtual void saveSettings(Settings& /*plugin_settings*/, Settings& /*instance_settings*/) const
virtual void saveSettings(Settings & /*plugin_settings*/, Settings & /*instance_settings*/) const
{}

/**
* Restore the intrinsic state of the plugin from the plugin-specific or instance-specific settings.
* @param the plugin-specific settings
* @param the instance-specific settings
*/
virtual void restoreSettings(const Settings& /*plugin_settings*/, const Settings& /*instance_settings*/)
virtual void restoreSettings(
const Settings & /*plugin_settings*/,
const Settings & /*instance_settings*/)
{}

/**
Expand All @@ -105,9 +105,7 @@ class Plugin
*/
virtual void triggerConfiguration()
{}

};
} // namespace qt_gui_cpp

} // namespace

#endif // qt_gui_cpp__Plugin_HPP
#endif // QT_GUI_CPP__PLUGIN_HPP_
6 changes: 3 additions & 3 deletions qt_gui_cpp/include/qt_gui_cpp/plugin_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef qt_gui_cpp__PluginBridge_H
#define qt_gui_cpp__PluginBridge_H
#ifndef QT_GUI_CPP__PLUGIN_BRIDGE_H_
#define QT_GUI_CPP__PLUGIN_BRIDGE_H_

// *INDENT-OFF* (prevent uncrustify from adding indention below)
#warning Including header <qt_gui_cpp/plugin_bridge.h> is deprecated, \
Expand All @@ -40,4 +40,4 @@ include <qt_gui_cpp/plugin_bridge.hpp> instead.

#include "./plugin_bridge.hpp"

#endif // qt_gui_cpp__PluginBridge_H
#endif // QT_GUI_CPP__PLUGIN_BRIDGE_H_
26 changes: 11 additions & 15 deletions qt_gui_cpp/include/qt_gui_cpp/plugin_bridge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef qt_gui_cpp__PluginBridge_HPP
#define qt_gui_cpp__PluginBridge_HPP
#ifndef QT_GUI_CPP__PLUGIN_BRIDGE_HPP_
#define QT_GUI_CPP__PLUGIN_BRIDGE_HPP_

#include <QObject>

Expand All @@ -45,14 +45,14 @@ class PluginProvider;
class PluginBridge
: public QObject
{

Q_OBJECT

public:

PluginBridge();

virtual bool load_plugin(PluginProvider* provider, const QString& plugin_id, PluginContext* plugin_context);
virtual bool load_plugin(
PluginProvider * provider, const QString & plugin_id,
PluginContext * plugin_context);

virtual void unload_plugin();

Expand All @@ -61,21 +61,17 @@ class PluginBridge
virtual void trigger_configuration();

public slots:

virtual void shutdown_plugin();

virtual void save_settings(QObject* plugin_settings, QObject* instance_settings);
virtual void save_settings(QObject * plugin_settings, QObject * instance_settings);

virtual void restore_settings(QObject* plugin_settings, QObject* instance_settings);
virtual void restore_settings(QObject * plugin_settings, QObject * instance_settings);

private:
PluginProvider * provider_;

PluginProvider* provider_;

Plugin* plugin_;

Plugin * plugin_;
};
} // namespace qt_gui_cpp

} // namespace

#endif // qt_gui_cpp__PluginBridge_HPP
#endif // QT_GUI_CPP__PLUGIN_BRIDGE_HPP_
7 changes: 3 additions & 4 deletions qt_gui_cpp/include/qt_gui_cpp/plugin_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef qt_gui_cpp__PluginContext_H
#define qt_gui_cpp__PluginContext_H
#ifndef QT_GUI_CPP__PLUGIN_CONTEXT_H_
#define QT_GUI_CPP__PLUGIN_CONTEXT_H_

// *INDENT-OFF* (prevent uncrustify from adding indention below)
#warning Including header <qt_gui_cpp/plugin_context.h> is deprecated, \
Expand All @@ -40,5 +40,4 @@ include <qt_gui_cpp/plugin_context.hpp> instead.

#include "./plugin_context.hpp"


#endif // qt_gui_cpp__PluginContext_H
#endif // QT_GUI_CPP__PLUGIN_CONTEXT_H_
Loading

0 comments on commit 99a8976

Please sign in to comment.