mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
refs #345 Second wave of value classes using the CValueObjectStdTuple CRTP class template, with inheritance.
This commit is contained in:
@@ -31,31 +31,6 @@ namespace BlackMisc
|
||||
this->m_frequencyStandby = a;
|
||||
}
|
||||
|
||||
/*
|
||||
* Register metadata
|
||||
*/
|
||||
template <class AVIO> void CModulator<AVIO>::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<AVIO>();
|
||||
qDBusRegisterMetaType<AVIO>();
|
||||
}
|
||||
|
||||
/*
|
||||
* To JSON
|
||||
*/
|
||||
template <class AVIO> QJsonObject CModulator<AVIO>::toJson() const
|
||||
{
|
||||
return BlackMisc::serializeJson(CModulator::jsonMembers(), TupleConverter<CModulator>::toTuple(*this));
|
||||
}
|
||||
|
||||
/*
|
||||
* To JSON
|
||||
*/
|
||||
template <class AVIO> void CModulator<AVIO>::convertFromJson(const QJsonObject &json)
|
||||
{
|
||||
BlackMisc::deserializeJson(json, CModulator::jsonMembers(), TupleConverter<CModulator>::toTuple(*this));
|
||||
}
|
||||
|
||||
/*
|
||||
* Property by index
|
||||
*/
|
||||
@@ -114,71 +89,6 @@ namespace BlackMisc
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Members
|
||||
*/
|
||||
template <class AVIO> const QStringList &CModulator<AVIO>::jsonMembers()
|
||||
{
|
||||
return TupleConverter<CModulator>::jsonMembers();
|
||||
}
|
||||
|
||||
/*
|
||||
* Equal operator ==
|
||||
*/
|
||||
template <class AVIO> bool CModulator<AVIO>::operator ==(const CModulator<AVIO> &other) const
|
||||
{
|
||||
if (this == &other) return true;
|
||||
if (!CAvionicsBase::operator ==(other)) return false;
|
||||
return TupleConverter<CModulator>::toTuple(*this) == TupleConverter<CModulator>::toTuple(other);
|
||||
}
|
||||
|
||||
/*
|
||||
* Equal operator !=
|
||||
*/
|
||||
template <class AVIO> bool CModulator<AVIO>::operator !=(const CModulator<AVIO> &other) const
|
||||
{
|
||||
return !(other == (*this));
|
||||
}
|
||||
|
||||
/*
|
||||
* To DBus
|
||||
*/
|
||||
template <class AVIO> void CModulator<AVIO>::marshallToDbus(QDBusArgument &argument) const
|
||||
{
|
||||
CAvionicsBase::marshallToDbus(argument);
|
||||
argument << TupleConverter<CModulator>::toTuple(*this);
|
||||
}
|
||||
|
||||
/*
|
||||
* From DBus
|
||||
*/
|
||||
template <class AVIO> void CModulator<AVIO>::unmarshallFromDbus(const QDBusArgument &argument)
|
||||
{
|
||||
CAvionicsBase::unmarshallFromDbus(argument);
|
||||
argument >> TupleConverter<CModulator>::toTuple(*this);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare
|
||||
*/
|
||||
template <class AVIO> int CModulator<AVIO>::compareImpl(const CValueObject &otherBase) const
|
||||
{
|
||||
const auto &other = static_cast<const CModulator &>(otherBase);
|
||||
int result = compare(TupleConverter<CModulator>::toTuple(*this), TupleConverter<CModulator>::toTuple(other));
|
||||
return result == 0 ? CAvionicsBase::compareImpl(otherBase) : result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Value hash
|
||||
*/
|
||||
template <class AVIO> uint CModulator<AVIO>::getValueHash() const
|
||||
{
|
||||
QList<uint> hashs;
|
||||
hashs << CAvionicsBase::getValueHash();
|
||||
hashs << qHash(TupleConverter<CModulator>::toTuple(*this));
|
||||
return BlackMisc::calculateHash(hashs, "CModulator");
|
||||
}
|
||||
|
||||
// see here for the reason of thess forward instantiations
|
||||
// http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html
|
||||
template class CModulator<CComSystem>;
|
||||
|
||||
Reference in New Issue
Block a user