mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T529, added order for CStatusMessage
This commit is contained in:
committed by
Mat Sutcliffe
parent
aa47d7bb03
commit
3ba88c7c2f
@@ -53,6 +53,9 @@ namespace BlackMisc
|
||||
//! Constructor
|
||||
IOrderable(int order);
|
||||
|
||||
//! Constructor
|
||||
IOrderable(const IOrderable &orderable) : IOrderable(orderable.m_order) {}
|
||||
|
||||
//! \copydoc BlackMisc::Mixin::Index::propertyByIndex
|
||||
CVariant propertyByIndex(const CPropertyIndex &index) const;
|
||||
|
||||
|
||||
@@ -89,7 +89,8 @@ namespace BlackMisc
|
||||
CStatusMessage::CStatusMessage(const CStatusMessage &other) :
|
||||
CValueObject(other),
|
||||
CMessageBase(other),
|
||||
ITimestampBased(other)
|
||||
ITimestampBased(other),
|
||||
IOrderable(other)
|
||||
{
|
||||
QReadLocker lock(&other.m_lock);
|
||||
m_handledByObjects = other.m_handledByObjects;
|
||||
@@ -103,13 +104,15 @@ namespace BlackMisc
|
||||
static_cast<CMessageBase &>(*this) = other;
|
||||
|
||||
QReadLocker readLock(&other.m_lock);
|
||||
auto handledBy = other.m_handledByObjects;
|
||||
qint64 ts = other.m_timestampMSecsSinceEpoch;
|
||||
const auto handledBy = other.m_handledByObjects;
|
||||
const qint64 ts = other.m_timestampMSecsSinceEpoch;
|
||||
const int order = other.m_order;
|
||||
readLock.unlock(); // avoid deadlock
|
||||
|
||||
QWriteLocker writeLock(&m_lock);
|
||||
m_handledByObjects = handledBy;
|
||||
m_timestampMSecsSinceEpoch = ts;
|
||||
m_order = order;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -420,6 +423,7 @@ namespace BlackMisc
|
||||
{
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::propertyByIndex(index); }
|
||||
if (IOrderable::canHandleIndex(index)) { return IOrderable::propertyByIndex(index); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
@@ -438,6 +442,7 @@ namespace BlackMisc
|
||||
{
|
||||
if (index.isMyself()) { (*this) = variant.to<CStatusMessage>(); return; }
|
||||
if (ITimestampBased::canHandleIndex(index)) { ITimestampBased::setPropertyByIndex(index, variant); return; }
|
||||
if (IOrderable::canHandleIndex(index)) { IOrderable::setPropertyByIndex(index, variant); return; }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
@@ -455,6 +460,7 @@ namespace BlackMisc
|
||||
{
|
||||
if (index.isMyself()) { return Compare::compare(this->getSeverity(), compareValue.getSeverity()); }
|
||||
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::comparePropertyByIndex(index, compareValue); }
|
||||
if (IOrderable::canHandleIndex(index)) { return IOrderable::comparePropertyByIndex(index, compareValue); }
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
switch (i)
|
||||
{
|
||||
|
||||
@@ -294,7 +294,8 @@ namespace BlackMisc
|
||||
class BLACKMISC_EXPORT CStatusMessage :
|
||||
public CValueObject<CStatusMessage>,
|
||||
public CMessageBase<CStatusMessage>,
|
||||
public ITimestampBased
|
||||
public ITimestampBased,
|
||||
public IOrderable
|
||||
{
|
||||
public:
|
||||
//! \copydoc BlackMisc::StatusSeverity
|
||||
@@ -518,12 +519,14 @@ namespace BlackMisc
|
||||
mutable QVector<quintptr> m_handledByObjects;
|
||||
mutable QReadWriteLock m_lock; //!< lock (because of mutable members)
|
||||
|
||||
//! \fixme KB 2019-01 order and timestamp "disabled" for Ref T184 token bucket. Would it be better to enable those and use a special comparison function for that (e.g. "equalMessageAndSeverity")?
|
||||
BLACK_METACLASS(
|
||||
CStatusMessage,
|
||||
BLACK_METAMEMBER(categories),
|
||||
BLACK_METAMEMBER(severity),
|
||||
BLACK_METAMEMBER(message),
|
||||
BLACK_METAMEMBER(args),
|
||||
BLACK_METAMEMBER(order, 0, DisabledForHashing | DisabledForComparison),
|
||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch, 0, DisabledForHashing | DisabledForComparison)
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user