mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 23:58:20 +00:00
Internal refactoring of how plugin components are tagged/managed.
Made some class templates for code that seemed duplicated between file/protocol tags and managers. Seems like it helps a bit and hopefully can be also be used to transition other things that have enum value "tags" (e.g. logging writers, input readers) to the plugin system.
This commit is contained in:
parent
9bd7a65071
commit
99c89b42d7
26 changed files with 432 additions and 366 deletions
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "Tag.h"
|
||||
#include "plugin/Component.h"
|
||||
#include "plugin/TaggedComponent.h"
|
||||
|
||||
#include "Val.h"
|
||||
|
||||
|
@ -22,7 +23,8 @@ class Analyzer;
|
|||
* A plugin can provide a specific file analyzer by registering this
|
||||
* analyzer component, describing the analyzer.
|
||||
*/
|
||||
class Component : public plugin::Component {
|
||||
class Component : public plugin::Component,
|
||||
public plugin::TaggedComponent<file_analysis::Tag> {
|
||||
public:
|
||||
typedef Analyzer* (*factory_callback)(RecordVal* args, File* file);
|
||||
|
||||
|
@ -38,15 +40,8 @@ public:
|
|||
* from file_analysis::Analyzer. This is typically a static \c
|
||||
* Instatiate() method inside the class that just allocates and
|
||||
* returns a new instance.
|
||||
*
|
||||
* @param subtype A subtype associated with this component that
|
||||
* further distinguishes it. The subtype will be integrated into
|
||||
* the file_analysis::Tag that the manager associates with this analyzer,
|
||||
* and analyzer instances can accordingly access it via
|
||||
* file_analysis::Tag(). If not used, leave at zero.
|
||||
*/
|
||||
Component(const char* name, factory_callback factory,
|
||||
file_analysis::Tag::subtype_t subtype = 0);
|
||||
Component(const char* name, factory_callback factory);
|
||||
|
||||
/**
|
||||
* Copy constructor.
|
||||
|
@ -79,13 +74,6 @@ public:
|
|||
*/
|
||||
factory_callback Factory() const { return factory; }
|
||||
|
||||
/**
|
||||
* Returns the analyzer's tag. Note that this is automatically
|
||||
* generated for each new Components, and hence unique across all of
|
||||
* them.
|
||||
*/
|
||||
file_analysis::Tag Tag() const;
|
||||
|
||||
/**
|
||||
* Generates a human-readable description of the component's main
|
||||
* parameters. This goes into the output of \c "bro -NN".
|
||||
|
@ -98,10 +86,6 @@ private:
|
|||
const char* name; // The analyzer's name.
|
||||
const char* canon_name; // The analyzer's canonical name.
|
||||
factory_callback factory; // The analyzer's factory callback.
|
||||
file_analysis::Tag tag; // The automatically assigned analyzer tag.
|
||||
|
||||
// Global counter used to generate unique tags.
|
||||
static file_analysis::Tag::type_t type_counter;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue