1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

docs(interface): Add docs to interface macroses

This commit is contained in:
Diadlo 2017-09-28 22:44:28 +03:00
parent b057f5adc6
commit 6a87ff8853
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727

View File

@ -3,10 +3,43 @@
#include <functional> #include <functional>
/**
* @file interface.h
*
* Qt doesn't support QObject multiple inheritance. But for declaring signals
* in class, it should be inherit QObject. To avoid this issue, interface can
* provide some pure virtual methods, which allow to connect to some signal.
*
* This file provides macros to make signals declaring easly. With this macros
* signal-like method will be declared and implemented in one line each.
*
* @example
* class IExample {
* public:
* // Like signal: void valueChanged(int value) const;
* // Declare `connectTo_valueChanged` method.
* DECLARE_SIGNAL(valueChanged, int value);
* };
*
* class Example : public QObject, public IExample {
* public:
* // Declare real signal and implement `connectTo_valueChanged`
* SIGNAL_IMPL(Example, valueChanged, int value);
* };
*/
/**
* @def DECLARE_SIGNAL
* @brief Decalre signal-like method. Should be used in interface
*/
#define DECLARE_SIGNAL(name, ...) \ #define DECLARE_SIGNAL(name, ...) \
using Slot_##name = std::function<void (__VA_ARGS__)>; \ using Slot_##name = std::function<void (__VA_ARGS__)>; \
virtual void connectTo_##name(Slot_##name slot) const = 0 virtual void connectTo_##name(Slot_##name slot) const = 0
/**
* @def SIGNAL_IMPL
* @brief Declare signal and implement signal-like method.
*/
#define SIGNAL_IMPL(classname, name, ...) \ #define SIGNAL_IMPL(classname, name, ...) \
using Slot_##name = std::function<void (__VA_ARGS__)>; \ using Slot_##name = std::function<void (__VA_ARGS__)>; \
Q_SIGNAL void name(__VA_ARGS__); \ Q_SIGNAL void name(__VA_ARGS__); \