Files
softbus_daemon/src/message_bus/pipeline/derivation/DerivationEngine.cpp
flower_linux 7280fca08d dommessage
2026-04-28 21:56:56 +08:00

45 lines
1.7 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "message_bus/pipeline/derivation/DerivationEngine.h"
#include <QJsonArray>
namespace softbus::message_bus::pipeline::derivation
{
DerivationEngine& DerivationEngine::instance()
{
static DerivationEngine eng;
return eng;
}
void DerivationEngine::deriveFromEnriched(const softbus::core::models::EnrichedMessage& in,
std::vector<softbus::core::models::EnrichedMessage>& outAppend) const
{
if (!m_enabled) {
return;
}
if (!in.attributes.value(QStringLiteral("sb.deriveMirror")).toBool()) {
return;
}
const QString srcPoint = in.attributes.value(QStringLiteral("pointId")).toString();
if (srcPoint.isEmpty()) {
return;
}
// MVP若存在派生后缀配置则复制一份工程值到派生点示例约定pointId + ".mirror"
const QString mirrorId = srcPoint + QStringLiteral(".mirror");
softbus::core::models::EnrichedMessage derived;
derived.sourceMessageId = mirrorId;
derived.logicalName = in.logicalName + QStringLiteral(" (derived)");
derived.unit = in.unit;
derived.engineeringValue = in.engineeringValue;
derived.quality = in.quality;
derived.attributes = in.attributes;
derived.traceLog = in.traceLog;
derived.attributes.insert(QStringLiteral("pointId"), mirrorId);
derived.attributes.insert(QStringLiteral("derivedFrom"), QJsonArray{srcPoint});
derived.attributes.insert(QStringLiteral("derivationRuleId"), QStringLiteral("builtin.mirror"));
derived.attributes.insert(QStringLiteral("derivationVersion"), QStringLiteral("1"));
outAppend.push_back(std::move(derived));
}
} // namespace softbus::message_bus::pipeline::derivation