diff --git a/src/blackcore/afv/clients/afvclient.cpp b/src/blackcore/afv/clients/afvclient.cpp index 531fff72b..e03356eda 100644 --- a/src/blackcore/afv/clients/afvclient.cpp +++ b/src/blackcore/afv/clients/afvclient.cpp @@ -57,6 +57,7 @@ namespace BlackCore CAfvClient::CAfvClient(const QString &apiServer, QObject *owner) : CContinuousWorker(owner, "CAfvClient"), + CIdentifiable("CAfvClient"), m_connection(new CClientConnection(apiServer, this)), m_input(new CInput(SampleRate, this)), m_output(new COutput(this)), diff --git a/src/blackcore/afv/clients/afvclient.h b/src/blackcore/afv/clients/afvclient.h index 2f080e734..836117a22 100644 --- a/src/blackcore/afv/clients/afvclient.h +++ b/src/blackcore/afv/clients/afvclient.h @@ -45,7 +45,7 @@ namespace BlackCore namespace Clients { //! AFV client - class BLACKCORE_EXPORT CAfvClient final : public BlackMisc::CContinuousWorker + class BLACKCORE_EXPORT CAfvClient final : public BlackMisc::CContinuousWorker, public BlackMisc::CIdentifiable { Q_OBJECT diff --git a/src/blackcore/context/contextapplicationimpl.cpp b/src/blackcore/context/contextapplicationimpl.cpp index 36a2bd8bd..f43cbd025 100644 --- a/src/blackcore/context/contextapplicationimpl.cpp +++ b/src/blackcore/context/contextapplicationimpl.cpp @@ -130,19 +130,12 @@ namespace BlackCore { if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << application; } - CIdentifier identifier(application); - identifier.setCurrentUtcTime(); - - if (!m_registeredApplications.contains(identifier)) + if (!m_registeredApplications.contains(application)) { - m_registeredApplications.push_back(identifier); + m_registeredApplications.push_back(application); emit this->registrationChanged(); emit this->hotkeyActionsRegistered(sApp->getInputManager()->allAvailableActions(), {}); } - else - { - m_registeredApplications.replace(application, identifier); - } this->cleanupRegisteredApplications(); return application; @@ -158,15 +151,16 @@ namespace BlackCore void CContextApplication::cleanupRegisteredApplications() { - static const int outdatedMs = qRound(1.5 * PingIdentifiersMs); - m_registeredApplications.removeOlderThanNowMinusOffset(outdatedMs); + //static const int outdatedMs = qRound(1.5 * PingIdentifiersMs); + //m_registeredApplications.removeOlderThanNowMinusOffset(outdatedMs); } CIdentifierList CContextApplication::getRegisteredApplications() const { if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } - static const int outdatedMs = qRound(1.5 * PingIdentifiersMs); - return m_registeredApplications.findAfterNowMinusOffset(outdatedMs); + //static const int outdatedMs = qRound(1.5 * PingIdentifiersMs); + //return m_registeredApplications.findAfterNowMinusOffset(outdatedMs); + return m_registeredApplications; } CIdentifier CContextApplication::getApplicationIdentifier() const diff --git a/src/blackgui/models/identifierlistmodel.cpp b/src/blackgui/models/identifierlistmodel.cpp index a2acd2db3..876383251 100644 --- a/src/blackgui/models/identifierlistmodel.cpp +++ b/src/blackgui/models/identifierlistmodel.cpp @@ -26,7 +26,6 @@ namespace BlackGui this->m_columns.addColumn(CColumn::standardString("machine", CIdentifier::IndexMachineName)); this->m_columns.addColumn(CColumn::standardString("process", CIdentifier::IndexProcessName)); this->m_columns.addColumn(CColumn::standardString("p.id", "process id", CIdentifier::IndexProcessId)); - this->m_columns.addColumn(CColumn("time", "received", CIdentifier::IndexUtcTimestamp, new CDateTimeFormatter(CDateTimeFormatter::formatHms()))); this->m_columns.addColumn(CColumn("lcl m.", "local machine", CIdentifier::IndexIsFromLocalMachine, new CBoolIconFormatter("local", "remote"))); this->m_columns.addColumn(CColumn("same p.", "same process", CIdentifier::IndexIsFromSameProcess, new CBoolIconFormatter("same process", "other process"))); this->m_columns.addColumn(CColumn::standardString("m.id", "machine id", CIdentifier::IndexMachineIdBase64)); diff --git a/src/blackmisc/identifiable.cpp b/src/blackmisc/identifiable.cpp index 2e5092889..9f704fb6f 100644 --- a/src/blackmisc/identifiable.cpp +++ b/src/blackmisc/identifiable.cpp @@ -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 diff --git a/src/blackmisc/identifiable.h b/src/blackmisc/identifiable.h index a3ae0743e..0d7ae56cf 100644 --- a/src/blackmisc/identifiable.h +++ b/src/blackmisc/identifiable.h @@ -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; } diff --git a/src/blackmisc/identifier.cpp b/src/blackmisc/identifier.cpp index 38fe225e7..73ca95351 100644 --- a/src/blackmisc/identifier.cpp +++ b/src/blackmisc/identifier.cpp @@ -9,6 +9,7 @@ #include "blackmisc/identifier.h" #include "blackmisc/comparefunctions.h" #include "blackmisc/stringutils.h" +#include "blackmisc/propertyindex.h" #include #include @@ -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(&m_processId), sizeof(m_processId)); - baseData.append(reinterpret_cast(&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(); - 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(); - if (ITimestampBased::canHandleIndex(index)) { return ITimestampBased::comparePropertyByIndex(index, compareValue); } switch (i) { diff --git a/src/blackmisc/identifier.h b/src/blackmisc/identifier.h index 1386391b1..af4552516 100644 --- a/src/blackmisc/identifier.h +++ b/src/blackmisc/identifier.h @@ -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 #include @@ -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, - public ITimestampBased + class BLACKMISC_EXPORT CIdentifier : public CValueObject { 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 diff --git a/src/blackmisc/identifierlist.h b/src/blackmisc/identifierlist.h index 9ed760ef8..1e54fdb40 100644 --- a/src/blackmisc/identifierlist.h +++ b/src/blackmisc/identifierlist.h @@ -25,8 +25,7 @@ namespace BlackMisc */ class BLACKMISC_EXPORT CIdentifierList : public CSequence, - public Mixin::MetaType, - public ITimestampObjectList + public Mixin::MetaType { public: BLACKMISC_DECLARE_USING_MIXIN_METATYPE(CIdentifierList) diff --git a/src/blackmisc/timestampobjectlist.cpp b/src/blackmisc/timestampobjectlist.cpp index 521118ebf..7de3511f7 100644 --- a/src/blackmisc/timestampobjectlist.cpp +++ b/src/blackmisc/timestampobjectlist.cpp @@ -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; - template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList; template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList; template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList; template class BLACKMISC_EXPORT_DEFINE_TEMPLATE ITimestampObjectList; diff --git a/src/blackmisc/timestampobjectlist.h b/src/blackmisc/timestampobjectlist.h index 28337e6f9..410d46a99 100644 --- a/src/blackmisc/timestampobjectlist.h +++ b/src/blackmisc/timestampobjectlist.h @@ -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; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; - extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; extern template class BLACKMISC_EXPORT_DECLARE_TEMPLATE ITimestampObjectList; // for the derived version both templates are required diff --git a/src/blackmisc/weather/weathergridprovider.h b/src/blackmisc/weather/weathergridprovider.h index 422735d89..28ae98798 100644 --- a/src/blackmisc/weather/weathergridprovider.h +++ b/src/blackmisc/weather/weathergridprovider.h @@ -21,6 +21,8 @@ namespace BlackMisc { + class CIdentifier; + namespace Weather { //! Direct threadsafe in memory access to weather grid diff --git a/src/blackmisc/worker.cpp b/src/blackmisc/worker.cpp index 0a44ee2aa..7c13d6c66 100644 --- a/src/blackmisc/worker.cpp +++ b/src/blackmisc/worker.cpp @@ -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"); diff --git a/src/blackmisc/worker.h b/src/blackmisc/worker.h index c207fae73..44552cded 100644 --- a/src/blackmisc/worker.h +++ b/src/blackmisc/worker.h @@ -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 @@ -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 diff --git a/src/swiftguistandard/swiftguistd.cpp b/src/swiftguistandard/swiftguistd.cpp index 1b7feea10..ff5addf15 100644 --- a/src/swiftguistandard/swiftguistd.cpp +++ b/src/swiftguistandard/swiftguistd.cpp @@ -313,7 +313,7 @@ void SwiftGuiStd::setContextAvailability() if (!isShuttingDown && sGui->getIContextApplication() && !sGui->getIContextApplication()->isEmptyObject()) { // ping to check if core is still alive - m_coreAvailable = this->isMyIdentifier(sGui->getIContextApplication()->registerApplication(getCurrentTimestampIdentifier())); + m_coreAvailable = this->isMyIdentifier(sGui->getIContextApplication()->registerApplication(identifier())); } else {