#pragma once

#include <mutex>

#include "core/models/EnrichedMessage.h"
#include "core/metadata/MetadataRegistry.h"
#include "message_bus/pipeline/stages/3_filters/IFilterStage.h"

namespace softbus::message_bus::pipeline::stages::filters
{

class ProtocolParseFilter final : public IFilterStage
{
public:
    ProtocolParseFilter();

    bool process(softbus::core::models::DOMMessage& message) override;
    softbus::core::models::EnrichedMessage enrich(const softbus::core::models::DOMMessage& message);

private:
    bool ensureLoaded() const;

private:
    mutable softbus::core::metadata::MetadataRegistry m_metadataRegistry;
    mutable std::once_flag                            m_loadOnce;
    mutable bool                                      m_loaded{false};
};

} // namespace softbus::message_bus::pipeline::stages::filters
