mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 16:56:53 +08:00
Issue #77 Break dependency of worker on identifiable
This commit is contained in:
@@ -10,13 +10,6 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
CIdentifier CIdentifiable::getCurrentTimestampIdentifier() const
|
||||
{
|
||||
CIdentifier o(m_identifier);
|
||||
o.setCurrentUtcTime();
|
||||
return o;
|
||||
}
|
||||
|
||||
CIdentifiable::CIdentifiable(QObject *object) : m_identifier(object->objectName())
|
||||
{
|
||||
// if the object name changes we update our originator
|
||||
|
||||
@@ -34,9 +34,6 @@ namespace BlackMisc
|
||||
//! Set identifier, allows to set an external identifier
|
||||
void setIdentifier(const CIdentifier &identifier) { m_identifier = identifier; }
|
||||
|
||||
//! Identifier with current timestamp
|
||||
CIdentifier getCurrentTimestampIdentifier() const;
|
||||
|
||||
//! My identifier?
|
||||
bool isMyIdentifier(const CIdentifier &otherIdentifier) const { return m_identifier == otherIdentifier; }
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "blackmisc/identifier.h"
|
||||
#include "blackmisc/comparefunctions.h"
|
||||
#include "blackmisc/stringutils.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QHostInfo>
|
||||
@@ -108,8 +109,7 @@ QByteArray cachedMachineUniqueId()
|
||||
namespace BlackMisc
|
||||
{
|
||||
CIdentifier::CIdentifier(const QString &name)
|
||||
: ITimestampBased(QDateTime::currentMSecsSinceEpoch()),
|
||||
m_name(name.trimmed()),
|
||||
: m_name(name.trimmed()),
|
||||
m_machineIdBase64(cachedMachineUniqueId().toBase64(QByteArray::OmitTrailingEquals)),
|
||||
m_machineName(cachedLocalHostName()),
|
||||
m_processName(cachedEscapedApplicationName()),
|
||||
@@ -128,7 +128,6 @@ namespace BlackMisc
|
||||
|
||||
CIdentifier::CIdentifier(const QString &name, const QString &machineId, const QString &machineName,
|
||||
const QString &processName, qint64 processId) :
|
||||
ITimestampBased(QDateTime::currentMSecsSinceEpoch()),
|
||||
m_name(name), m_machineIdBase64(machineId), m_machineName(machineName),
|
||||
m_processName(processName), m_processId(processId)
|
||||
{ }
|
||||
@@ -157,7 +156,6 @@ namespace BlackMisc
|
||||
QByteArray baseData;
|
||||
baseData.append(getMachineId());
|
||||
baseData.append(reinterpret_cast<const char *>(&m_processId), sizeof(m_processId));
|
||||
baseData.append(reinterpret_cast<const char *>(&m_timestampMSecsSinceEpoch), sizeof(m_timestampMSecsSinceEpoch));
|
||||
baseData.append(getName());
|
||||
return QUuid::createUuidV5(ns, baseData);
|
||||
}
|
||||
@@ -283,7 +281,6 @@ namespace BlackMisc
|
||||
if (index.isMyself()) { return CVariant::from(*this); }
|
||||
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::propertyByIndex(index); }
|
||||
|
||||
switch (i)
|
||||
{
|
||||
@@ -305,7 +302,6 @@ namespace BlackMisc
|
||||
if (index.isMyself()) { return Compare::compare(m_processId, compareValue.m_processId); }
|
||||
|
||||
const ColumnIndex i = index.frontCasted<ColumnIndex>();
|
||||
if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::comparePropertyByIndex(index, compareValue); }
|
||||
|
||||
switch (i)
|
||||
{
|
||||
|
||||
@@ -13,10 +13,7 @@
|
||||
|
||||
#include "blackmisc/blackmiscexport.h"
|
||||
#include "blackmisc/metaclass.h"
|
||||
#include "blackmisc/propertyindex.h"
|
||||
#include "blackmisc/timestampbased.h"
|
||||
#include "blackmisc/valueobject.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QMetaType>
|
||||
@@ -30,9 +27,7 @@ namespace BlackMisc
|
||||
/*!
|
||||
* Value object encapsulating information identifying a component of a modular distributed swift process (core, GUI, audio)
|
||||
*/
|
||||
class BLACKMISC_EXPORT CIdentifier :
|
||||
public CValueObject<CIdentifier>,
|
||||
public ITimestampBased
|
||||
class BLACKMISC_EXPORT CIdentifier : public CValueObject<CIdentifier>
|
||||
{
|
||||
public:
|
||||
//! Properties by index
|
||||
@@ -172,8 +167,7 @@ namespace BlackMisc
|
||||
BLACK_METAMEMBER(machineIdBase64),
|
||||
BLACK_METAMEMBER(machineName, 0, DisabledForComparison | DisabledForHashing),
|
||||
BLACK_METAMEMBER(processName),
|
||||
BLACK_METAMEMBER(processId),
|
||||
BLACK_METAMEMBER(timestampMSecsSinceEpoch, 0, DisabledForComparison | DisabledForHashing)
|
||||
BLACK_METAMEMBER(processId)
|
||||
);
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@@ -25,8 +25,7 @@ namespace BlackMisc
|
||||
*/
|
||||
class BLACKMISC_EXPORT CIdentifierList :
|
||||
public CSequence<CIdentifier>,
|
||||
public Mixin::MetaType<CIdentifierList>,
|
||||
public ITimestampObjectList<CIdentifier, CIdentifierList>
|
||||
public Mixin::MetaType<CIdentifierList>
|
||||
{
|
||||
public:
|
||||
BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CIdentifierList)
|
||||
|
||||
@@ -747,7 +747,6 @@ namespace BlackMisc
|
||||
// see here for the reason of thess forward instantiations
|
||||
// https://isocpp.org/wiki/faq/templates#separate-template-fn-defn-from-decl
|
||||
template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList<BlackMisc::CCountry, BlackMisc::CCountryList>;
|
||||
template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList<BlackMisc::CIdentifier, BlackMisc::CIdentifierList>;
|
||||
template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList<BlackMisc::CStatusMessage, BlackMisc::CStatusMessageList>;
|
||||
template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList<BlackMisc::Aviation::CAircraftIcaoCode, BlackMisc::Aviation::CAircraftIcaoCodeList>;
|
||||
template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList<BlackMisc::Aviation::CAircraftCategory, BlackMisc::Aviation::CAircraftCategoryList>;
|
||||
|
||||
@@ -329,8 +329,6 @@ namespace BlackMisc
|
||||
|
||||
class CStatusMessage;
|
||||
class CStatusMessageList;
|
||||
class CIdentifier;
|
||||
class CIdentifierList;
|
||||
class CCountry;
|
||||
class CCountryList;
|
||||
|
||||
@@ -349,7 +347,6 @@ namespace BlackMisc
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::Network::CRawFsdMessage, BlackMisc::Network::CRawFsdMessageList>;
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::Network::CUrlLog, BlackMisc::Network::CUrlLogList>;
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::CStatusMessage, BlackMisc::CStatusMessageList>;
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::CIdentifier, BlackMisc::CIdentifierList>;
|
||||
extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList<BlackMisc::CCountry, BlackMisc::CCountryList>;
|
||||
|
||||
// for the derived version both templates are required
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
namespace BlackMisc
|
||||
{
|
||||
class CIdentifier;
|
||||
|
||||
namespace Weather
|
||||
{
|
||||
//! Direct threadsafe in memory access to weather grid
|
||||
|
||||
@@ -149,7 +149,6 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
CContinuousWorker::CContinuousWorker(QObject *owner, const QString &name) :
|
||||
CIdentifiable(name),
|
||||
m_owner(owner), m_name(name)
|
||||
{
|
||||
Q_ASSERT_X(!name.isEmpty(), Q_FUNC_INFO, "Empty name");
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "blackmisc/invoke.h"
|
||||
#include "blackmisc/promise.h"
|
||||
#include "blackmisc/stacktrace.h"
|
||||
#include "blackmisc/identifiable.h"
|
||||
#include "blackmisc/variant.h"
|
||||
|
||||
#include <QFuture>
|
||||
@@ -266,9 +265,7 @@ namespace BlackMisc
|
||||
/*!
|
||||
* Base class for a long-lived worker object which lives in its own thread.
|
||||
*/
|
||||
class BLACKMISC_EXPORT CContinuousWorker :
|
||||
public CWorkerBase,
|
||||
public CIdentifiable
|
||||
class BLACKMISC_EXPORT CContinuousWorker : public CWorkerBase
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
Reference in New Issue
Block a user