mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-06 18:36:01 +08:00
refs #192, enable value objects for JSON:
* from/toJson methods * jsonMembers where applicable
This commit is contained in:
@@ -36,13 +36,13 @@ namespace BlackMisc
|
||||
TAF
|
||||
};
|
||||
|
||||
/*!
|
||||
* Default constructor.
|
||||
*/
|
||||
CInformationMessage(CInformationMessage::InformationType type = CInformationMessage::Unspecified)
|
||||
: m_type(type), m_receivedTimestamp(QDateTime::currentDateTimeUtc())
|
||||
//! \brief Default constructor.
|
||||
CInformationMessage() : m_type(CInformationMessage::Unspecified), m_receivedTimestamp(QDateTime::currentDateTimeUtc())
|
||||
{}
|
||||
|
||||
//! \brief Information message of type
|
||||
explicit CInformationMessage(InformationType type) : m_type(type) {}
|
||||
|
||||
/*!
|
||||
* \brief Information message of type
|
||||
* \param type
|
||||
@@ -52,138 +52,91 @@ namespace BlackMisc
|
||||
: m_type(type), m_message(message)
|
||||
{}
|
||||
|
||||
/*!
|
||||
* \copydoc CValueObject::toQVariant
|
||||
*/
|
||||
//! \copydoc CValueObject::toQVariant
|
||||
virtual QVariant toQVariant() const override
|
||||
{
|
||||
return QVariant::fromValue(*this);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Equal operator ==
|
||||
* \param other
|
||||
* @return
|
||||
*/
|
||||
//! \brief Equal operator ==
|
||||
bool operator ==(const CInformationMessage &other) const;
|
||||
|
||||
/*!
|
||||
* \brief operator !=
|
||||
* \param other
|
||||
* \return
|
||||
*/
|
||||
//! \brief operator !=
|
||||
bool operator !=(const CInformationMessage &other) const;
|
||||
|
||||
/*!
|
||||
* Get message.
|
||||
* \return
|
||||
*/
|
||||
//! \brief Get message.
|
||||
const QString &getMessage() const { return m_message; }
|
||||
|
||||
/*!
|
||||
* \brief Is a message available
|
||||
* \return
|
||||
*/
|
||||
//! \brief Is a message available
|
||||
bool hasMessage() const { return !m_message.isEmpty(); }
|
||||
|
||||
/*!
|
||||
* \brief Set message
|
||||
* \param message
|
||||
*/
|
||||
//! \brief Set message
|
||||
void setMessage(const QString &message)
|
||||
{
|
||||
this->m_receivedTimestamp = QDateTime::currentDateTimeUtc();
|
||||
this->m_message = message;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Append message part
|
||||
* \param messagePart
|
||||
*/
|
||||
//! \brief Append message part
|
||||
void appendMessage(const QString &messagePart)
|
||||
{
|
||||
this->m_receivedTimestamp = QDateTime::currentDateTimeUtc();
|
||||
this->m_message.append(messagePart);
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Type as string
|
||||
* \return
|
||||
*/
|
||||
//! \brief Type as string
|
||||
const QString &getTypeAsString() const;
|
||||
|
||||
/*!
|
||||
* \brief Type
|
||||
* \return
|
||||
*/
|
||||
//! \brief Type
|
||||
InformationType getType() const { return this->m_type; }
|
||||
|
||||
/*!
|
||||
* \brief Set type
|
||||
* \param type
|
||||
*/
|
||||
//! \brief Set type
|
||||
void setType(InformationType type) { this->m_type = type; }
|
||||
|
||||
/*!
|
||||
* \brief Timestamp
|
||||
* \return
|
||||
*/
|
||||
//! \brief Timestamp
|
||||
const QDateTime &getReceivedTimestamp() const { return this->m_receivedTimestamp; }
|
||||
|
||||
/*!
|
||||
* \brief Received before n ms
|
||||
* \return
|
||||
*/
|
||||
//! \brief Received before n ms
|
||||
qint64 timeDiffReceivedMs() const
|
||||
{
|
||||
return this->m_receivedTimestamp.msecsTo(QDateTime::currentDateTimeUtc());
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Is empty
|
||||
* \return
|
||||
*/
|
||||
//! \brief Is empty?
|
||||
bool isEmpty() const { return this->m_message.isEmpty(); }
|
||||
|
||||
/*!
|
||||
* \copydoc CValueObject::getValueHash
|
||||
*/
|
||||
//! \copydoc CValueObject::getValueHash
|
||||
virtual uint getValueHash() const override;
|
||||
|
||||
/*!
|
||||
* \brief Register metadata
|
||||
*/
|
||||
//! \copydoc CValueObject::toJson
|
||||
virtual QJsonObject toJson() const override;
|
||||
|
||||
//! \copydoc CValueObject::fromJson
|
||||
void fromJson(const QJsonObject &json) override;
|
||||
|
||||
//! \brief Register metadata
|
||||
static void registerMetadata();
|
||||
|
||||
//! \brief Members
|
||||
static const QStringList &jsonMembers();
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* \copydoc CValueObject::convertToQString
|
||||
*/
|
||||
//! \copydoc CValueObject::convertToQString
|
||||
virtual QString convertToQString(bool i18n = false) const override;
|
||||
|
||||
/*!
|
||||
* \copydoc CValueObject::getMetaTypeId
|
||||
*/
|
||||
//! \copydoc CValueObject::getMetaTypeId
|
||||
virtual int getMetaTypeId() const override;
|
||||
|
||||
/*!
|
||||
* \copydoc CValueObject::isA
|
||||
*/
|
||||
//! \copydoc CValueObject::isA
|
||||
virtual bool isA(int metaTypeId) const override;
|
||||
|
||||
/*!
|
||||
* \copydoc CValueObject::compareImpl
|
||||
*/
|
||||
//! \copydoc CValueObject::compareImpl
|
||||
virtual int compareImpl(const CValueObject &other) const override;
|
||||
|
||||
/*!
|
||||
* \copydoc CValueObject::marshallToDbus
|
||||
*/
|
||||
//! \copydoc CValueObject::marshallToDbus
|
||||
virtual void marshallToDbus(QDBusArgument &argument) const override;
|
||||
|
||||
/*!
|
||||
* \copydoc CValueObject::unmarshallFromDbus
|
||||
*/
|
||||
//! \copydoc CValueObject::unmarshallFromDbus
|
||||
virtual void unmarshallFromDbus(const QDBusArgument &argument) override;
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user