mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 11:05:33 +08:00
refs #140, removed MACRO DBUS_ENUM_MARSHALLING, changed to template
discussed in https://dev.vatsim-germany.org/issues/140#change-864
This commit is contained in:
@@ -28,7 +28,7 @@ namespace BlackMisc
|
||||
public:
|
||||
|
||||
//! \brief Type
|
||||
enum DeviceType
|
||||
enum DeviceType : uint
|
||||
{
|
||||
InputDevice,
|
||||
OutputDevice,
|
||||
@@ -135,10 +135,9 @@ namespace BlackMisc
|
||||
static QString hostName();
|
||||
};
|
||||
|
||||
} // Voice
|
||||
} // Audio
|
||||
} // BlackMisc
|
||||
|
||||
BLACK_DBUS_ENUM_MARSHALLING(BlackMisc::Audio::CAudioDevice::DeviceType)
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Audio::CAudioDevice, (o.m_type, o.m_deviceIndex, o.m_deviceName, o.m_hostName))
|
||||
Q_DECLARE_METATYPE(BlackMisc::Audio::CAudioDevice)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "blackmiscfreefunctions.h"
|
||||
#include "avheading.h"
|
||||
|
||||
using BlackMisc::PhysicalQuantities::CAngle;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#ifndef BLACKMISC_AVHEADING_H
|
||||
#define BLACKMISC_AVHEADING_H
|
||||
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/pqangle.h"
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -93,7 +92,6 @@ namespace BlackMisc
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
BLACK_DBUS_ENUM_MARSHALLING(BlackMisc::Aviation::CHeading::ReferenceNorth)
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CHeading, (o.m_north))
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CHeading)
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#ifndef BLACKMISC_INFORMATIONMESSAGE_H
|
||||
#define BLACKMISC_INFORMATIONMESSAGE_H
|
||||
|
||||
#include "blackmiscfreefunctions.h"
|
||||
#include "valueobject.h"
|
||||
#include <QString>
|
||||
#include <QDateTime>
|
||||
@@ -196,7 +195,6 @@ namespace BlackMisc
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
BLACK_DBUS_ENUM_MARSHALLING(BlackMisc::Aviation::CInformationMessage::InformationType)
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CInformationMessage, (o.m_type, o.m_message, o.m_receivedTimestamp))
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CInformationMessage)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/aviocomsystem.h"
|
||||
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#ifndef BLACKMISC_AVIOCOMSYSTEM_H
|
||||
#define BLACKMISC_AVIOCOMSYSTEM_H
|
||||
#include "blackmisc/aviomodulator.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -359,7 +358,6 @@ namespace BlackMisc
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
BLACK_DBUS_ENUM_MARSHALLING(BlackMisc::Aviation::CComSystem::ChannelSpacing)
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CComSystem, (o.m_channelSpacing))
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CComSystem)
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#ifndef BLACKMISC_AVIOTRANSPONDER_H
|
||||
#define BLACKMISC_AVIOTRANSPONDER_H
|
||||
#include "blackmisc/aviobase.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include <stdexcept>
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -390,7 +389,6 @@ namespace BlackMisc
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
BLACK_DBUS_ENUM_MARSHALLING(BlackMisc::Aviation::CTransponder::TransponderMode)
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CTransponder, (o.m_transponderCode))
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CTransponder)
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "blackmiscfreefunctions.h"
|
||||
#include "avtrack.h"
|
||||
|
||||
using BlackMisc::PhysicalQuantities::CAngle;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#ifndef BLACKMISC_AVTRACK_H
|
||||
#define BLACKMISC_AVTRACK_H
|
||||
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/pqangle.h"
|
||||
|
||||
namespace BlackMisc
|
||||
@@ -108,7 +107,6 @@ namespace BlackMisc
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
BLACK_DBUS_ENUM_MARSHALLING(BlackMisc::Aviation::CTrack::ReferenceNorth)
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Aviation::CTrack, (o.m_north))
|
||||
Q_DECLARE_METATYPE(BlackMisc::Aviation::CTrack)
|
||||
|
||||
|
||||
@@ -198,23 +198,4 @@ namespace BlackMisc
|
||||
|
||||
} // BlackMisc
|
||||
|
||||
/*!
|
||||
* \brief Macro to make a ENUMs DBus streamable.
|
||||
* \details Put this macro outside of any namespace, in the same header as the class defining the enumeration.
|
||||
* \param ENUM The fully qualified name of the enumeration.
|
||||
* \hideinitializer
|
||||
* \ingroup Tuples
|
||||
*/
|
||||
#define BLACK_DBUS_ENUM_MARSHALLING(ENUM) \
|
||||
namespace BlackMisc \
|
||||
{ \
|
||||
inline const QDBusArgument &operator >>(const QDBusArgument &arg, ENUM &enumType) \
|
||||
{ \
|
||||
uint e; \
|
||||
arg >> e; \
|
||||
enumType = static_cast<ENUM>(e); \
|
||||
return arg; \
|
||||
}; \
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#ifndef BLACKMISC_KEYBOARDKEY_H
|
||||
#define BLACKMISC_KEYBOARDKEY_H
|
||||
|
||||
#include "blackmiscfreefunctions.h"
|
||||
#include "valueobject.h"
|
||||
#include <QStringList>
|
||||
#include <QKeySequence>
|
||||
@@ -257,8 +256,6 @@ namespace BlackMisc
|
||||
} // class
|
||||
} // BlackMisc
|
||||
|
||||
BLACK_DBUS_ENUM_MARSHALLING(BlackMisc::Hardware::CKeyboardKey::Modifier)
|
||||
BLACK_DBUS_ENUM_MARSHALLING(BlackMisc::Hardware::CKeyboardKey::HotkeyFunction)
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Hardware::CKeyboardKey, (o.m_qtKey, o.m_nativeScanCode, o.m_nativeVirtualKey, o.m_modifier1, o.m_modifier2, o.m_function, o.m_pressed))
|
||||
Q_DECLARE_METATYPE(BlackMisc::Hardware::CKeyboardKey)
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
#ifndef BLACKMISC_STATUSMESSAGE_H
|
||||
#define BLACKMISC_STATUSMESSAGE_H
|
||||
|
||||
#include "blackmiscfreefunctions.h"
|
||||
#include "valueobject.h"
|
||||
#include <QDateTime>
|
||||
|
||||
@@ -150,8 +149,6 @@ namespace BlackMisc
|
||||
};
|
||||
}
|
||||
|
||||
BLACK_DBUS_ENUM_MARSHALLING(BlackMisc::CStatusMessage::StatusSeverity)
|
||||
BLACK_DBUS_ENUM_MARSHALLING(BlackMisc::CStatusMessage::StatusType)
|
||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::CStatusMessage, (o.m_type, o.m_severity, o.m_message, o.m_timestamp))
|
||||
Q_DECLARE_METATYPE(BlackMisc::CStatusMessage)
|
||||
|
||||
|
||||
@@ -297,6 +297,22 @@ namespace BlackMisc
|
||||
return argument >> static_cast<CValueObject &>(valueObject);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Non-member non-friend operator for streaming enums to QDBusArgument.
|
||||
*
|
||||
* \param argument
|
||||
* \param enumType
|
||||
* \return
|
||||
*/
|
||||
template <class ENUM> typename std::enable_if<std::is_enum<ENUM>::value, QDBusArgument>::type const &
|
||||
operator>>(const QDBusArgument &argument, ENUM &enumType)
|
||||
{
|
||||
uint e;
|
||||
argument>> e;
|
||||
enumType = static_cast<ENUM>(e);
|
||||
return argument;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Non-member non-friend operator for streaming T objects from QDBusArgument.
|
||||
* Needed because we can't rely on the friend operator in some cases due to
|
||||
|
||||
Reference in New Issue
Block a user