refs #345 First wave of value classes using the CValueObjectStdTuple CRTP class template.

This commit is contained in:
Mathew Sutcliffe
2014-10-30 22:08:22 +00:00
parent ecf8e6aafb
commit 4c8148acf1
68 changed files with 34 additions and 4499 deletions

View File

@@ -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
*/