Move threading classes to zeek namespaces

This commit is contained in:
Tim Wojtulewicz 2020-08-01 10:48:46 -07:00
parent f310795d79
commit 1262109e5a
42 changed files with 299 additions and 210 deletions

View file

@ -23,8 +23,8 @@
#include "../threading/SerialTypes.h"
using namespace std;
using threading::Value;
using threading::Field;
using zeek::threading::Value;
using zeek::threading::Field;
namespace zeek::input {

View file

@ -4,8 +4,8 @@
#include "ReaderFrontend.h"
#include "Manager.h"
using threading::Value;
using threading::Field;
using zeek::threading::Value;
using zeek::threading::Field;
namespace zeek::input {

View file

@ -12,10 +12,9 @@
#include "threading/SerialTypes.h"
using namespace threading;
using namespace std;
using threading::Value;
using threading::Field;
using zeek::threading::Value;
using zeek::threading::Field;
namespace zeek::input::reader::detail {
@ -114,8 +113,8 @@ bool Ascii::DoInit(const ReaderInfo& info, int num_fields, const Field* const* f
if ( set_separator.size() != 1 )
Error("set_separator length has to be 1. Separator will be truncated.");
formatter::Ascii::SeparatorInfo sep_info(separator, set_separator, unset_field, empty_field);
formatter = unique_ptr<threading::formatter::Formatter>(new formatter::Ascii(this, sep_info));
zeek::threading::formatter::Ascii::SeparatorInfo sep_info(separator, set_separator, unset_field, empty_field);
formatter = unique_ptr<zeek::threading::Formatter>(new zeek::threading::formatter::Ascii(this, sep_info));
return DoUpdate();
}
@ -368,7 +367,7 @@ bool Ascii::DoUpdate()
if ( ! fit->present )
{
// add non-present field
fields[fpos] = new Value((*fit).type, false);
fields[fpos] = new Value((*fit).type, false);
fpos++;
continue;
}

View file

@ -82,7 +82,7 @@ private:
bool fail_on_file_problem;
std::string path_prefix;
std::unique_ptr<threading::formatter::Formatter> formatter;
std::unique_ptr<zeek::threading::Formatter> formatter;
};
} // namespace zeek::input::reader::detail

View file

@ -29,7 +29,7 @@ Benchmark::Benchmark(zeek::input::ReaderFrontend *frontend) : zeek::input::Reade
heartbeatstarttime = 0;
heartbeat_interval = double(zeek::BifConst::Threading::heartbeat_interval);
ascii = new threading::formatter::Ascii(this, threading::formatter::Ascii::SeparatorInfo());
ascii = new zeek::threading::formatter::Ascii(this, zeek::threading::formatter::Ascii::SeparatorInfo());
}
Benchmark::~Benchmark()
@ -43,7 +43,7 @@ void Benchmark::DoClose()
{
}
bool Benchmark::DoInit(const ReaderInfo& info, int num_fields, const Field* const* fields)
bool Benchmark::DoInit(const ReaderInfo& info, int num_fields, const zeek::threading::Field* const* fields)
{
num_lines = atoi(info.source);
@ -88,7 +88,7 @@ bool Benchmark::DoUpdate()
int linestosend = num_lines * heartbeat_interval;
for ( int i = 0; i < linestosend; i++ )
{
Value** field = new Value*[NumFields()];
zeek::threading::Value** field = new zeek::threading::Value*[NumFields()];
for (int j = 0; j < NumFields(); j++ )
field[j] = EntryToVal(Fields()[j]->type, Fields()[j]->subtype);
@ -124,9 +124,9 @@ bool Benchmark::DoUpdate()
return true;
}
threading::Value* Benchmark::EntryToVal(zeek::TypeTag type, zeek::TypeTag subtype)
zeek::threading::Value* Benchmark::EntryToVal(zeek::TypeTag type, zeek::TypeTag subtype)
{
Value* val = new Value(type, subtype, true);
auto* val = new zeek::threading::Value(type, subtype, true);
// basically construct something random from the fields that we want.
@ -189,7 +189,7 @@ threading::Value* Benchmark::EntryToVal(zeek::TypeTag type, zeek::TypeTag subtyp
// how many entries do we have...
unsigned int length = random() / (RAND_MAX / 15);
Value** lvals = new Value* [length];
zeek::threading::Value** lvals = new zeek::threading::Value* [length];
if ( type == zeek::TYPE_TABLE )
{
@ -209,7 +209,7 @@ threading::Value* Benchmark::EntryToVal(zeek::TypeTag type, zeek::TypeTag subtyp
for ( unsigned int pos = 0; pos < length; pos++ )
{
Value* newval = EntryToVal(subtype, zeek::TYPE_ENUM);
zeek::threading::Value* newval = EntryToVal(subtype, zeek::TYPE_ENUM);
if ( newval == nullptr )
{
Error("Error while reading set");
@ -250,10 +250,10 @@ bool Benchmark::DoHeartbeat(double network_time, double current_time)
if ( multiplication_factor != 1 || add != 0 )
{
// we have to document at what time we changed the factor to what value.
Value** v = new Value*[2];
v[0] = new Value(zeek::TYPE_COUNT, true);
zeek::threading::Value** v = new zeek::threading::Value*[2];
v[0] = new zeek::threading::Value(zeek::TYPE_COUNT, true);
v[0]->val.uint_val = num_lines;
v[1] = new Value(zeek::TYPE_TIME, true);
v[1] = new zeek::threading::Value(zeek::TYPE_TIME, true);
v[1]->val.double_val = CurrTime();
SendEvent("lines_changed", 2, v);

View file

@ -39,7 +39,7 @@ private:
double timedspread;
double heartbeat_interval;
threading::formatter::Ascii* ascii;
zeek::threading::formatter::Ascii* ascii;
};
} // namespace zeek::input::reader

View file

@ -8,8 +8,8 @@
#include "threading/SerialTypes.h"
using namespace std;
using threading::Value;
using threading::Field;
using zeek::threading::Value;
using zeek::threading::Field;
namespace zeek::input::reader::detail {

View file

@ -15,9 +15,8 @@
#include "input/Manager.h"
#include "threading/SerialTypes.h"
using namespace threading;
using threading::Value;
using threading::Field;
using zeek::threading::Value;
using zeek::threading::Field;
namespace zeek::input::reader::detail {
@ -72,8 +71,9 @@ bool Config::DoInit(const ReaderInfo& info, int num_fields, const Field* const*
empty_field.assign( (const char*) zeek::BifConst::InputConfig::empty_field->Bytes(),
zeek::BifConst::InputConfig::empty_field->Len());
formatter::Ascii::SeparatorInfo sep_info("\t", set_separator, "", empty_field);
formatter = std::unique_ptr<threading::formatter::Formatter>(new formatter::Ascii(this, sep_info));
zeek::threading::formatter::Ascii::SeparatorInfo sep_info("\t", set_separator, "", empty_field);
formatter = std::unique_ptr<zeek::threading::Formatter>(
new zeek::threading::formatter::Ascii(this, sep_info));
return DoUpdate();
}

View file

@ -49,7 +49,7 @@ private:
std::string set_separator;
std::string empty_field;
std::unique_ptr<threading::formatter::Formatter> formatter;
std::unique_ptr<zeek::threading::Formatter> formatter;
std::unordered_map<std::string, std::tuple<zeek::TypeTag, zeek::TypeTag>> option_types;
std::unordered_map<std::string, std::string> option_values;
};

View file

@ -20,8 +20,8 @@ extern "C" {
#include "setsignal.h"
}
using threading::Value;
using threading::Field;
using zeek::threading::Value;
using zeek::threading::Field;
namespace zeek::input::reader::detail {

View file

@ -15,8 +15,8 @@
#include "threading/SerialTypes.h"
using threading::Value;
using threading::Field;
using zeek::threading::Value;
using zeek::threading::Field;
namespace zeek::input::reader::detail {
@ -39,8 +39,8 @@ SQLite::SQLite(zeek::input::ReaderFrontend *frontend)
zeek::BifConst::InputSQLite::empty_field->Len()
);
io = new threading::formatter::Ascii(this, threading::formatter::Ascii::SeparatorInfo(std::string(),
set_separator, unset_field, empty_field));
io = new zeek::threading::formatter::Ascii(this, zeek::threading::formatter::Ascii::SeparatorInfo(
std::string(), set_separator, unset_field, empty_field));
}
SQLite::~SQLite()

View file

@ -21,7 +21,7 @@ public:
static zeek::input::ReaderBackend* Instantiate(zeek::input::ReaderFrontend* frontend) { return new SQLite(frontend); }
protected:
bool DoInit(const ReaderInfo& info, int arg_num_fields, const threading::Field* const* arg_fields) override;
bool DoInit(const ReaderInfo& info, int arg_num_fields, const zeek::threading::Field* const* arg_fields) override;
void DoClose() override;
bool DoUpdate() override;
bool DoHeartbeat(double network_time, double current_time) override { return true; }
@ -29,7 +29,7 @@ protected:
private:
bool checkError(int code);
threading::Value* EntryToVal(sqlite3_stmt *st, const threading::Field *field, int pos, int subpos);
zeek::threading::Value* EntryToVal(sqlite3_stmt *st, const zeek::threading::Field *field, int pos, int subpos);
const threading::Field* const * fields; // raw mapping
unsigned int num_fields;
@ -38,7 +38,7 @@ private:
std::string query;
sqlite3 *db;
sqlite3_stmt *st;
threading::formatter::Ascii* io;
zeek::threading::formatter::Ascii* io;
std::string set_separator;
std::string unset_field;