Ref T566, added DBus streaming operators so the DECLARED enums can be used with DBus

This commit is contained in:
Klaus Basan
2019-04-09 01:38:22 +02:00
committed by Mat Sutcliffe
parent df119c6e98
commit 269bad3c42
5 changed files with 64 additions and 16 deletions

View File

@@ -14,6 +14,7 @@
#include "blackmisc/blackmiscexport.h"
#include <QStringList>
#include <QMetaType>
#include <QDBusArgument>
namespace BlackMisc
{
@@ -45,4 +46,28 @@ Q_DECLARE_METATYPE(BlackMisc::Simulation::MatchingLog)
Q_DECLARE_METATYPE(BlackMisc::Simulation::MatchingLogFlag)
Q_DECLARE_OPERATORS_FOR_FLAGS(BlackMisc::Simulation::MatchingLog)
/*!
* Operator for streaming enums to QDBusArgument.
*/
inline QDBusArgument &operator <<(QDBusArgument &arg, const BlackMisc::Simulation::MatchingLog &value)
{
arg.beginStructure();
arg << static_cast<int>(value);
arg.endStructure();
return arg;
}
/*!
* Operator for streaming enums from QDBusArgument.
*/
inline const QDBusArgument &operator >>(const QDBusArgument &arg, BlackMisc::Simulation::MatchingLog &value)
{
int temp;
arg.beginStructure();
arg >> temp;
arg.endStructure();
value = static_cast<BlackMisc::Simulation::MatchingLog>(temp);
return arg;
}
#endif // guard