mirror of
https://github.com/zeek/zeek.git
synced 2025-10-07 00:58:19 +00:00
Move VectorDispatcher to be the only dispatcher
This commit is contained in:
parent
d22481aef3
commit
b46e600775
8 changed files with 36 additions and 397 deletions
59
src/packet_analysis/Dispatcher.h
Normal file
59
src/packet_analysis/Dispatcher.h
Normal file
|
@ -0,0 +1,59 @@
|
|||
// See the file "COPYING" in the main distribution directory for copyright.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "Analyzer.h"
|
||||
|
||||
namespace zeek::packet_analysis {
|
||||
|
||||
class Dispatcher; // Forward decl for Value
|
||||
using DispatcherPtr = std::shared_ptr<Dispatcher>;
|
||||
|
||||
using register_pair = std::pair<identifier_t, std::pair<AnalyzerPtr, DispatcherPtr>>;
|
||||
using register_map = std::map<identifier_t, std::pair<AnalyzerPtr, DispatcherPtr>>;
|
||||
|
||||
class Value {
|
||||
public:
|
||||
AnalyzerPtr analyzer;
|
||||
DispatcherPtr dispatcher;
|
||||
|
||||
Value(AnalyzerPtr analyzer, DispatcherPtr dispatcher)
|
||||
: analyzer(analyzer), dispatcher(dispatcher)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
using ValuePtr = std::shared_ptr<Value>;
|
||||
|
||||
class Dispatcher {
|
||||
public:
|
||||
Dispatcher()
|
||||
: table(std::vector<ValuePtr>(1, nullptr))
|
||||
{ }
|
||||
|
||||
~Dispatcher();
|
||||
|
||||
bool Register(identifier_t identifier, AnalyzerPtr analyzer, DispatcherPtr dispatcher);
|
||||
void Register(const register_map& data);
|
||||
|
||||
ValuePtr Lookup(identifier_t identifier) const;
|
||||
|
||||
size_t Size() const;
|
||||
void Clear();
|
||||
void DumpDebug() const;
|
||||
|
||||
private:
|
||||
identifier_t lowest_identifier = 0;
|
||||
std::vector<ValuePtr> table;
|
||||
|
||||
void FreeValues();
|
||||
|
||||
inline identifier_t GetHighestIdentifier() const
|
||||
{
|
||||
return lowest_identifier + table.size() - 1;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue