zeek/src/analyzer/Component.cc
Tim Wojtulewicz 7d66f4252f Unify plugin::Component and plugin::TaggedComponent into a single class
These two are almost always used in conjunction with each other, and
TaggedComponent is never used by itself. Combining them together into
a single class will help simplify some of the code around managing
the mapping between Tags and Components.
2021-11-23 19:36:49 -07:00

42 lines
1 KiB
C++

// See the file "COPYING" in the main distribution directory for copyright.
#include "zeek/analyzer/Component.h"
#include "zeek/Desc.h"
#include "zeek/analyzer/Manager.h"
#include "zeek/util.h"
namespace zeek::analyzer
{
Component::Component(const std::string& name, factory_callback arg_factory,
zeek::Tag::subtype_t arg_subtype, bool arg_enabled, bool arg_partial,
bool arg_adapter)
: plugin::Component(arg_adapter ? plugin::component::SESSION_ADAPTER
: plugin::component::ANALYZER,
name, arg_subtype, analyzer_mgr->GetTagType())
{
factory = arg_factory;
enabled = arg_enabled;
partial = arg_partial;
}
void Component::Initialize()
{
InitializeTag();
analyzer_mgr->RegisterComponent(this, "ANALYZER_");
}
void Component::DoDescribe(ODesc* d) const
{
if ( factory )
{
d->Add("ANALYZER_");
d->Add(CanonicalName());
d->Add(", ");
}
d->Add(enabled ? "enabled" : "disabled");
}
} // namespace zeek::analyzer