mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
Operator function templates, using std::enable_if to match only classes
derived from CStreamable, for streaming to/from QtDBusArgument, avoiding the unrelated operator function template for streaming Container<T> defined by Qt, by being a better match in overload resolution.
This commit is contained in:
@@ -19,34 +19,6 @@ namespace Aviation
|
||||
*/
|
||||
template <class AVIO> class CModulator : public CAvionicsBase
|
||||
{
|
||||
/*!
|
||||
* \brief Unmarshalling operator >>, DBus to object
|
||||
* \param argument
|
||||
* \param uc
|
||||
* \return
|
||||
*/
|
||||
friend const QDBusArgument &operator>>(const QDBusArgument &argument, AVIO &uc)
|
||||
{
|
||||
// If I do not have the method here, DBus metasystem tries to stream against
|
||||
// a container: inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<T> &list)
|
||||
// Once someone solves this, this methods should go and the
|
||||
// CStreamable signature should be used
|
||||
CStreamable &sf = uc;
|
||||
return argument >> sf;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Marshalling operator <<, object to DBus
|
||||
* \param argument
|
||||
* \param pq
|
||||
* \return
|
||||
*/
|
||||
friend QDBusArgument &operator<<(QDBusArgument &argument, const AVIO &uc)
|
||||
{
|
||||
const CStreamable &sf = uc;
|
||||
return argument << sf;
|
||||
}
|
||||
|
||||
private:
|
||||
BlackMisc::PhysicalQuantities::CFrequency m_frequencyActive; //!< active frequency
|
||||
BlackMisc::PhysicalQuantities::CFrequency m_frequencyStandby; //!< standby frequency
|
||||
|
||||
@@ -16,34 +16,6 @@ namespace Geo
|
||||
*/
|
||||
template <class LATorLON> class CEarthAngle : public BlackMisc::PhysicalQuantities::CAngle
|
||||
{
|
||||
/*!
|
||||
* \brief Unmarshalling operator >>, DBus to object
|
||||
* \param argument
|
||||
* \param uc
|
||||
* \return
|
||||
*/
|
||||
friend const QDBusArgument &operator>>(const QDBusArgument &argument, LATorLON &uc)
|
||||
{
|
||||
// If I do not have the method here, DBus metasystem tries to stream against
|
||||
// a container: inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<T> &list)
|
||||
// Once someone solves this, this methods should go and the
|
||||
// CStreamable signature should be used
|
||||
CStreamable &sf = uc;
|
||||
return argument >> sf;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Marshalling operator <<, object to DBus
|
||||
* \param argument
|
||||
* \param pq
|
||||
* \return
|
||||
*/
|
||||
friend QDBusArgument &operator<<(QDBusArgument &argument, const LATorLON &uc)
|
||||
{
|
||||
const CStreamable &sf = uc;
|
||||
return argument << sf;
|
||||
}
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* \brief Default constructor
|
||||
|
||||
@@ -21,34 +21,6 @@ class CMatrix3x1;
|
||||
*/
|
||||
template <class ImplVector> class CVector3DBase : public CStreamable
|
||||
{
|
||||
/*!
|
||||
* \brief Unmarshalling operator >>, DBus to object
|
||||
* \param argument
|
||||
* \param uc
|
||||
* \return
|
||||
*/
|
||||
friend const QDBusArgument &operator>>(const QDBusArgument &argument, ImplVector &uc)
|
||||
{
|
||||
// If I do not have the method here, DBus metasystem tries to stream against
|
||||
// a container: inline const QDBusArgument &operator>>(const QDBusArgument &arg, Container<T> &list)
|
||||
// Once someone solves this, this methods should go and the
|
||||
// CStreamable signature should be used
|
||||
CStreamable &sf = uc;
|
||||
return argument >> sf;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Marshalling operator <<, object to DBus
|
||||
* \param argument
|
||||
* \param pq
|
||||
* \return
|
||||
*/
|
||||
friend QDBusArgument &operator<<(QDBusArgument &argument, const ImplVector &uc)
|
||||
{
|
||||
const CStreamable &sf = uc;
|
||||
return argument << sf;
|
||||
}
|
||||
|
||||
private:
|
||||
/*!
|
||||
* \brief Easy access to derived class (CRTP template parameter)
|
||||
|
||||
@@ -168,6 +168,34 @@ protected:
|
||||
virtual void unmarshallFromDbus(const QDBusArgument &) = 0;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Non-member non-friend operator for streaming T objects to QDBusArgument.
|
||||
* Needed because we can't rely on the friend operator in some cases due to
|
||||
* an unrelated template for streaming Container<T> in QtDBus/qdbusargument.h
|
||||
* which matches more types than it can actually handle.
|
||||
* \param argument
|
||||
* \param uc
|
||||
*/
|
||||
template <class T> typename std::enable_if<std::is_base_of<CStreamable, T>::value, QDBusArgument>::type const&
|
||||
operator>>(const QDBusArgument &argument, T &uc)
|
||||
{
|
||||
return argument >> static_cast<CStreamable&>(uc);
|
||||
}
|
||||
|
||||
/*!
|
||||
* 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
|
||||
* an unrelated template for streaming Container<T> in QtDBus/qdbusargument.h
|
||||
* which matches more types than it can actually handle.
|
||||
* \param argument
|
||||
* \param uc
|
||||
*/
|
||||
template <class T> typename std::enable_if<std::is_base_of<CStreamable, T>::value, QDBusArgument>::type&
|
||||
operator<<(QDBusArgument &argument, T &uc)
|
||||
{
|
||||
return argument << static_cast<CStreamable const&>(uc);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
|
||||
Reference in New Issue
Block a user