plugin/ComponentManager: Support lookup by EnumValPtr

This commit is contained in:
Arne Welzel 2024-03-02 15:20:05 +01:00
parent 4aca6290a7
commit bf2ba626b1

View file

@ -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<C>::Lookup(EnumVal* val, bool consider_remappings) const {
return nullptr;
}
template<class C>
C* ComponentManager<C>::Lookup(const EnumValPtr& val, bool consider_remappings) const {
return Lookup(val.get(), consider_remappings);
}
template<class C>
void ComponentManager<C>::RegisterComponent(C* component, const std::string& prefix) {
std::string cname = component->CanonicalName();