mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 21:15:33 +08:00
refs #345 First wave of value classes using the CValueObjectStdTuple CRTP class template.
This commit is contained in:
@@ -22,110 +22,6 @@ namespace BlackMisc
|
||||
return this->m_message;
|
||||
}
|
||||
|
||||
/*
|
||||
* metaTypeId
|
||||
*/
|
||||
int CInformationMessage::getMetaTypeId() const
|
||||
{
|
||||
return qMetaTypeId<CInformationMessage>();
|
||||
}
|
||||
|
||||
/*
|
||||
* is a
|
||||
*/
|
||||
bool CInformationMessage::isA(int metaTypeId) const
|
||||
{
|
||||
if (metaTypeId == qMetaTypeId<CInformationMessage>()) { return true; }
|
||||
|
||||
return this->CValueObject::isA(metaTypeId);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare
|
||||
*/
|
||||
int CInformationMessage::compareImpl(const CValueObject &otherBase) const
|
||||
{
|
||||
const auto &other = static_cast<const CInformationMessage &>(otherBase);
|
||||
|
||||
return compare(TupleConverter<CInformationMessage>::toTuple(*this), TupleConverter<CInformationMessage>::toTuple(other));
|
||||
}
|
||||
|
||||
/*
|
||||
* Marshall to DBus
|
||||
*/
|
||||
void CInformationMessage::marshallToDbus(QDBusArgument &argument) const
|
||||
{
|
||||
argument << TupleConverter<CInformationMessage>::toTuple(*this);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unmarshall from DBus
|
||||
*/
|
||||
void CInformationMessage::unmarshallFromDbus(const QDBusArgument &argument)
|
||||
{
|
||||
argument >> TupleConverter<CInformationMessage>::toTuple(*this);
|
||||
}
|
||||
|
||||
/*
|
||||
* Equal?
|
||||
*/
|
||||
bool CInformationMessage::operator ==(const CInformationMessage &other) const
|
||||
{
|
||||
if (this == &other) return true;
|
||||
return TupleConverter<CInformationMessage>::toTuple(*this) == TupleConverter<CInformationMessage>::toTuple(other);
|
||||
}
|
||||
|
||||
/*
|
||||
* Unequal?
|
||||
*/
|
||||
bool CInformationMessage::operator !=(const CInformationMessage &other) const
|
||||
{
|
||||
return !((*this) == other);
|
||||
}
|
||||
|
||||
/*
|
||||
* Hash
|
||||
*/
|
||||
uint CInformationMessage::getValueHash() const
|
||||
{
|
||||
return qHash(TupleConverter<CInformationMessage>::toTuple(*this));
|
||||
}
|
||||
|
||||
/*
|
||||
* Register metadata
|
||||
*/
|
||||
void CInformationMessage::registerMetadata()
|
||||
{
|
||||
qRegisterMetaType<CInformationMessage>();
|
||||
qDBusRegisterMetaType<CInformationMessage>();
|
||||
}
|
||||
|
||||
/*
|
||||
* JSON members
|
||||
*/
|
||||
const QStringList &CInformationMessage::jsonMembers()
|
||||
{
|
||||
return TupleConverter<CInformationMessage>::jsonMembers();
|
||||
}
|
||||
|
||||
/*
|
||||
* To JSON
|
||||
*/
|
||||
QJsonObject CInformationMessage::toJson() const
|
||||
{
|
||||
return BlackMisc::serializeJson(CInformationMessage::jsonMembers(), TupleConverter<CInformationMessage>::toTuple(*this));
|
||||
}
|
||||
|
||||
/*
|
||||
* To JSON
|
||||
*/
|
||||
void CInformationMessage::convertFromJson(const QJsonObject &json)
|
||||
{
|
||||
this->m_message = json.value("m_message").toString();
|
||||
this->m_type = static_cast<CInformationMessage::InformationType>(qRound(json.value("m_type").toDouble()));
|
||||
this->m_receivedTimestamp = QDateTime::fromString(json.value("m_receivedTimestamp").toString());
|
||||
}
|
||||
|
||||
/*
|
||||
* Type as string
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user