refs #356 Update remaining CValueObject derived classes to use CValueObjectStdTuple instead.

This commit is contained in:
Mathew Sutcliffe
2015-03-16 18:38:03 +00:00
parent 2a3e0acf23
commit a5e6b31c0f
7 changed files with 61 additions and 235 deletions

View File

@@ -23,84 +23,6 @@ namespace BlackMisc
return s;
}
/*
* metaTypeId
*/
int CTestValueObject::getMetaTypeId() const
{
return qMetaTypeId<CTestValueObject>();
}
/*
* is a
*/
bool CTestValueObject::isA(int metaTypeId) const
{
if (metaTypeId == qMetaTypeId<CTestValueObject>()) { return true; }
return this->CValueObject::isA(metaTypeId);
}
/*
* Compare
*/
int CTestValueObject::compareImpl(const CValueObject &otherBase) const
{
const auto &other = static_cast<const CTestValueObject &>(otherBase);
return compare(TupleConverter<CTestValueObject>::toTuple(*this), TupleConverter<CTestValueObject>::toTuple(other));
}
/*
* Marshall to DBus
*/
void CTestValueObject::marshallToDbus(QDBusArgument &argument) const
{
argument << TupleConverter<CTestValueObject>::toTuple(*this);
}
/*
* Unmarshall from DBus
*/
void CTestValueObject::unmarshallFromDbus(const QDBusArgument &argument)
{
argument >> TupleConverter<CTestValueObject>::toTuple(*this);
}
/*
* Equal?
*/
bool CTestValueObject::operator ==(const CTestValueObject &other) const
{
if (this == &other) return true;
return TupleConverter<CTestValueObject>::toTuple(*this) == TupleConverter<CTestValueObject>::toTuple(other);
}
/*
* Unequal?
*/
bool CTestValueObject::operator !=(const CTestValueObject &other) const
{
return !((*this) == other);
}
/*
* Less than?
*/
bool CTestValueObject::operator <(const CTestValueObject &other) const
{
if (this == &other) return false;
return TupleConverter<CTestValueObject>::toTuple(*this) < TupleConverter<CTestValueObject>::toTuple(other);
}
/*
* Hash
*/
uint CTestValueObject::getValueHash() const
{
return qHash(TupleConverter<CTestValueObject>::toTuple(*this));
}
/*
* Property by index
*/
@@ -115,7 +37,7 @@ namespace BlackMisc
case IndexName:
return CVariant::fromValue(this->m_name);
default:
return CValueObject::propertyByIndex(index);
return CValueObjectStdTuple::propertyByIndex(index);
}
}
@@ -139,42 +61,9 @@ namespace BlackMisc
this->setName(variant.value<QString>());
break;
default:
CValueObject::setPropertyByIndex(variant, index);
CValueObjectStdTuple::setPropertyByIndex(variant, index);
break;
}
}
/*
* Register metadata
*/
void CTestValueObject::registerMetadata()
{
qRegisterMetaType<CTestValueObject>();
qDBusRegisterMetaType<CTestValueObject>();
}
/*
* Members
*/
const QStringList &CTestValueObject::jsonMembers()
{
return TupleConverter<CTestValueObject>::jsonMembers();
}
/*
* To JSON
*/
QJsonObject CTestValueObject::toJson() const
{
return BlackMisc::serializeJson(CTestValueObject::jsonMembers(), TupleConverter<CTestValueObject>::toTuple(*this));
}
/*
* From Json
*/
void CTestValueObject::convertFromJson(const QJsonObject &json)
{
BlackMisc::deserializeJson(json, CTestValueObject::jsonMembers(), TupleConverter<CTestValueObject>::toTuple(*this));
}
} // namespace