From bf2ba626b1a04a3001530903c38fb7a79351c87d Mon Sep 17 00:00:00 2001 From: Arne Welzel Date: Sat, 2 Mar 2024 15:20:05 +0100 Subject: [PATCH] plugin/ComponentManager: Support lookup by EnumValPtr --- src/plugin/ComponentManager.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/plugin/ComponentManager.h b/src/plugin/ComponentManager.h index 098ecd6bed..deb2317748 100644 --- a/src/plugin/ComponentManager.h +++ b/src/plugin/ComponentManager.h @@ -136,7 +136,7 @@ public: C* Lookup(const zeek::Tag& tag, bool consider_remappings = true) const; /** - * @param name A component's enum value. + * @param val A component's enum value. * @param consider_remappings If true, component mappings will be honored * if the original component is disabled. * @return The component associated with the value or a null pointer if no @@ -144,6 +144,15 @@ public: */ C* Lookup(EnumVal* val, bool consider_remappings = true) const; + /** + * @param val A component's enum value. + * @param consider_remappings If true, component mappings will be honored + * if the original component is disabled. + * @return The component associated with the value or a null pointer if no + * such component exists. + */ + C* Lookup(const EnumValPtr& val, bool consider_remappings = true) const; + /** * Registers a mapping of a component to another one that will be honored * by the `Lookup()` methods if (and only if) the original is currently @@ -347,6 +356,11 @@ C* ComponentManager::Lookup(EnumVal* val, bool consider_remappings) const { return nullptr; } +template +C* ComponentManager::Lookup(const EnumValPtr& val, bool consider_remappings) const { + return Lookup(val.get(), consider_remappings); +} + template void ComponentManager::RegisterComponent(C* component, const std::string& prefix) { std::string cname = component->CanonicalName();