mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 01:58:20 +00:00
Canonifying internal order for plugins and their components to make it
deterministic.
This commit is contained in:
parent
57b05a2989
commit
d8801bb9c4
8 changed files with 41 additions and 17 deletions
|
@ -72,7 +72,7 @@ public:
|
|||
* from what's passed to the constructor but upper-cased and
|
||||
* canonified to allow being part of a script-level ID.
|
||||
*/
|
||||
const char* Name() const { return name; }
|
||||
virtual const char* Name() const { return name; }
|
||||
|
||||
/**
|
||||
* Returns a canonocalized version of the analyzer's name. The
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
* from what's passed to the constructor but upper-cased and
|
||||
* canonified to allow being part of a script-level ID.
|
||||
*/
|
||||
const char* Name() const { return name; }
|
||||
virtual const char* Name() const { return name; }
|
||||
|
||||
/**
|
||||
* Returns a canonocalized version of the analyzer's name. The
|
||||
|
|
|
@ -45,6 +45,12 @@ public:
|
|||
*/
|
||||
component::Type Type() const;
|
||||
|
||||
/**
|
||||
* Returns a descriptive name for the analyzer. This name must be
|
||||
* unique across all components of the same type.
|
||||
*/
|
||||
virtual const char* Name() const = 0;
|
||||
|
||||
/**
|
||||
* Returns a textual representation of the component. The default
|
||||
* version just output the type. Derived version should call the
|
||||
|
|
|
@ -30,9 +30,18 @@ bool Manager::LoadPluginsFrom(const std::string& dir)
|
|||
return false;
|
||||
}
|
||||
|
||||
static bool plugin_cmp(const Plugin* a, const Plugin* b)
|
||||
{
|
||||
return a->Name() < b->Name();
|
||||
}
|
||||
|
||||
bool Manager::RegisterPlugin(Plugin *plugin)
|
||||
{
|
||||
Manager::PluginsInternal()->push_back(plugin);
|
||||
|
||||
// Sort plugins by name to make sure we have a deterministic order.
|
||||
PluginsInternal()->sort(plugin_cmp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -156,9 +156,18 @@ Plugin::component_list Plugin::Components() const
|
|||
return components;
|
||||
}
|
||||
|
||||
static bool component_cmp(const Component* a, const Component* b)
|
||||
{
|
||||
return a->Name() < b->Name();
|
||||
}
|
||||
|
||||
void Plugin::AddComponent(Component* c)
|
||||
{
|
||||
components.push_back(c);
|
||||
|
||||
// Sort components by name to make sure we have a deterministic
|
||||
// order.
|
||||
components.sort(component_cmp);
|
||||
}
|
||||
|
||||
void Plugin::AddBifInitFunction(bif_init_func c)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue