Mark one-parameter constructors as explicit & use override where possible

This commit marks (hopefully) ever one-parameter constructor as explicit.

It also uses override in (hopefully) all circumstances where a virtual
method is overridden.

There are a very few other minor changes - most of them were necessary
to get everything to compile (like one additional constructor). In one
case I changed an implicit operation to an explicit string conversion -
I think the automatically chosen conversion was much more convoluted.

This took longer than I want to admit but not as long as I feared :)
This commit is contained in:
Johanna Amann 2018-03-16 22:14:22 -07:00
parent 1f2bf50b49
commit 6d612ced3d
173 changed files with 1052 additions and 1046 deletions

View file

@ -37,7 +37,7 @@ public:
/**
* Destructor.
*/
~Component();
~Component() override;
/**
* Initialization function. This function has to be called before any

View file

@ -98,14 +98,14 @@ protected:
* @param subtype The sub type, which is left to an writer for
* interpretation. By default it's set to zero.
*/
Tag(type_t type, subtype_t subtype = 0);
explicit Tag(type_t type, subtype_t subtype = 0);
/**
* Constructor.
*
* @param val An enum value of script type \c Log::Writer.
*/
Tag(EnumVal* val) : ::Tag(val) {}
explicit Tag(EnumVal* val) : ::Tag(val) {}
};
}

View file

@ -47,7 +47,7 @@ public:
/**
* Destructor.
*/
virtual ~WriterBackend();
~WriterBackend() override;
/**
* A struct passing information to the writer at initialization time.

View file

@ -14,8 +14,8 @@ namespace logging { namespace writer {
class Ascii : public WriterBackend {
public:
Ascii(WriterFrontend* frontend);
~Ascii();
explicit Ascii(WriterFrontend* frontend);
~Ascii() override;
static string LogExt();
@ -23,19 +23,19 @@ public:
{ return new Ascii(frontend); }
protected:
virtual bool DoInit(const WriterInfo& info, int num_fields,
const threading::Field* const* fields);
virtual bool DoWrite(int num_fields, const threading::Field* const* fields,
threading::Value** vals);
virtual bool DoSetBuf(bool enabled);
virtual bool DoRotate(const char* rotated_path, double open,
double close, bool terminating);
virtual bool DoFlush(double network_time);
virtual bool DoFinish(double network_time);
virtual bool DoHeartbeat(double network_time, double current_time);
bool DoInit(const WriterInfo& info, int num_fields,
const threading::Field* const* fields) override;
bool DoWrite(int num_fields, const threading::Field* const* fields,
threading::Value** vals) override;
bool DoSetBuf(bool enabled) override;
bool DoRotate(const char* rotated_path, double open,
double close, bool terminating) override;
bool DoFlush(double network_time) override;
bool DoFinish(double network_time) override;
bool DoHeartbeat(double network_time, double current_time) override;
private:
bool IsSpecial(string path) { return path.find("/dev/") == 0; }
bool IsSpecial(const string &path) { return path.find("/dev/") == 0; }
bool WriteHeader(const string& path);
bool WriteHeaderField(const string& key, const string& value);
void CloseFile(double t);

View file

@ -11,24 +11,23 @@ namespace logging { namespace writer {
class None : public WriterBackend {
public:
None(WriterFrontend* frontend) : WriterBackend(frontend) {}
~None() {};
explicit None(WriterFrontend* frontend) : WriterBackend(frontend) {}
~None() override {};
static WriterBackend* Instantiate(WriterFrontend* frontend)
{ return new None(frontend); }
protected:
virtual bool DoInit(const WriterInfo& info, int num_fields,
const threading::Field* const * fields);
virtual bool DoWrite(int num_fields, const threading::Field* const* fields,
threading::Value** vals) { return true; }
virtual bool DoSetBuf(bool enabled) { return true; }
virtual bool DoRotate(const char* rotated_path, double open,
double close, bool terminating);
virtual bool DoFlush(double network_time) { return true; }
virtual bool DoFinish(double network_time) { return true; }
virtual bool DoHeartbeat(double network_time, double current_time) { return true; }
bool DoInit(const WriterInfo& info, int num_fields,
const threading::Field* const * fields) override;
bool DoWrite(int num_fields, const threading::Field* const* fields,
threading::Value** vals) override { return true; }
bool DoSetBuf(bool enabled) override { return true; }
bool DoRotate(const char* rotated_path, double open,
double close, bool terminating) override;
bool DoFlush(double network_time) override { return true; }
bool DoFinish(double network_time) override { return true; }
bool DoHeartbeat(double network_time, double current_time) override { return true; }
};
}

View file

@ -10,7 +10,7 @@ namespace Bro_SQLiteWriter {
class Plugin : public plugin::Plugin {
public:
plugin::Configuration Configure()
plugin::Configuration Configure() override
{
AddComponent(new ::logging::Component("SQLite", ::logging::writer::SQLite::Instantiate));

View file

@ -15,23 +15,23 @@ namespace logging { namespace writer {
class SQLite : public WriterBackend {
public:
SQLite(WriterFrontend* frontend);
~SQLite();
explicit SQLite(WriterFrontend* frontend);
~SQLite() override;
static WriterBackend* Instantiate(WriterFrontend* frontend)
{ return new SQLite(frontend); }
protected:
virtual bool DoInit(const WriterInfo& info, int arg_num_fields,
const threading::Field* const* arg_fields);
virtual bool DoWrite(int num_fields, const threading::Field* const* fields,
threading::Value** vals);
virtual bool DoSetBuf(bool enabled) { return true; }
virtual bool DoRotate(const char* rotated_path, double open,
double close, bool terminating);
virtual bool DoFlush(double network_time) { return true; }
virtual bool DoFinish(double network_time) { return true; }
virtual bool DoHeartbeat(double network_time, double current_time) { return true; }
bool DoInit(const WriterInfo& info, int arg_num_fields,
const threading::Field* const* arg_fields) override;
bool DoWrite(int num_fields, const threading::Field* const* fields,
threading::Value** vals) override;
bool DoSetBuf(bool enabled) override { return true; }
bool DoRotate(const char* rotated_path, double open,
double close, bool terminating) override;
bool DoFlush(double network_time) override { return true; }
bool DoFinish(double network_time) override { return true; }
bool DoHeartbeat(double network_time, double current_time) override { return true; }
private:
bool checkError(int code);