Cleanup of plugin component API.

- Move more functionality into base class.
- Remove cctors and assignment operators (weren't actually needed anymore)
- Switch from const char* to std::string.
This commit is contained in:
Robin Sommer 2013-12-12 17:39:03 -08:00
parent e9413c9361
commit 987452beff
18 changed files with 114 additions and 216 deletions

View file

@ -3,6 +3,8 @@
#ifndef PLUGIN_COMPONENT_H
#define PLUGIN_COMPONENT_H
#include <string>
class ODesc;
namespace plugin {
@ -32,8 +34,11 @@ public:
* Constructor.
*
* @param type The type of the compoment.
*
* @param name A descriptive name for the component. This name must
* be unique across all components of the same type.
*/
Component(component::Type type);
Component(component::Type type, const std::string& name);
/**
* Destructor.
@ -46,22 +51,37 @@ public:
component::Type Type() const;
/**
* Returns a descriptive name for the analyzer. This name must be
* unique across all components of the same type.
* Returns the compoment's name.
*/
virtual const char* Name() const = 0;
const std::string& Name() const;
/**
* Returns a textual representation of the component. The default
* version just output the type. Derived version should call the
* parent's implementation and that add further information.
* Returns a textual representation of the component. This goes into
* the output of "bro -NN".
*
* By default version, this just outputs the type and the name.
* Derived versions should override DoDescribe() to add type specific
* details.
*
* @param d The description object to use.
*/
virtual void Describe(ODesc* d) const;
protected:
/**
* Adds type specific information to the outout of Describe().
*
* @param d The description object to use.
*/
virtual void DoDescribe(ODesc* d) const { }
private:
// Disable.
Component(const Component& other);
Component operator=(const Component& other);
component::Type type;
std::string name;
};
}