mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 00:28:21 +00:00
Move enabled/disabled functionality from analyzers into Component
base class API.
The different analyzers types all had their own methods for enabling/disabling their availability. This change abstracts that into a new API inside their base class (`plugin::Component`) so that they can be toggled in a unified way. In principle, other types of components could/should use this as well now, so that, e.g., an input reader's availability could be toggled at runtime. The code doesn't make that broader change for now because it would requires a series of changes wherever these other component types are being used. However, that means that one now could try toggling some other component through the new API without that having any effect. To catch that, there's a runtime check in place that turns any such attempt into an internal error.
This commit is contained in:
parent
d7e30d9ee2
commit
ac1a7508ee
8 changed files with 50 additions and 55 deletions
|
@ -11,7 +11,7 @@ namespace zeek::file_analysis {
|
|||
Component::Component(const std::string& name, factory_function arg_factory, Tag::subtype_t subtype, bool arg_enabled)
|
||||
: plugin::Component(plugin::component::FILE_ANALYZER, name, subtype, file_mgr->GetTagType()) {
|
||||
factory_func = arg_factory;
|
||||
enabled = arg_enabled;
|
||||
SetEnabled(arg_enabled);
|
||||
}
|
||||
|
||||
void Component::Initialize() {
|
||||
|
@ -26,7 +26,7 @@ void Component::DoDescribe(ODesc* d) const {
|
|||
d->Add(", ");
|
||||
}
|
||||
|
||||
d->Add(enabled ? "enabled" : "disabled");
|
||||
d->Add(Enabled() ? "enabled" : "disabled");
|
||||
}
|
||||
|
||||
} // namespace zeek::file_analysis
|
||||
|
|
|
@ -70,20 +70,6 @@ public:
|
|||
*/
|
||||
factory_function FactoryFunction() const { return factory_func; }
|
||||
|
||||
/**
|
||||
* Returns true if the analyzer is currently enabled and hence
|
||||
* available for use.
|
||||
*/
|
||||
bool Enabled() const { return enabled; }
|
||||
|
||||
/**
|
||||
* Enables or disables this analyzer.
|
||||
*
|
||||
* @param arg_enabled True to enabled, false to disable.
|
||||
*
|
||||
*/
|
||||
void SetEnabled(bool arg_enabled) { enabled = arg_enabled; }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Overridden from plugin::Component.
|
||||
|
@ -94,7 +80,6 @@ private:
|
|||
friend class Manager;
|
||||
|
||||
factory_function factory_func; // The analyzer's factory callback.
|
||||
bool enabled; // True if the analyzer is enabled.
|
||||
};
|
||||
|
||||
} // namespace file_analysis
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue