|
bref
API 2014 of the Zia HTTP server.
|
Class used to operate with dynamically loaded modules. More...
#include <AModule.h>
Public Member Functions | |
| virtual const std::string & | name () const |
| Retrieve the module's name. | |
| virtual const std::string & | description () const |
| Retrieve the module's description. | |
| virtual const Version & | version () const |
| Retrieve the module's version. | |
| virtual const Version & | minimumApiVersion () const |
| Retrieve the minimum API version the module is compatible with. | |
| virtual void | registerHooks (Pipeline &) |
| Register the module hooks on the convenient hookpoints of the pipeline. | |
| virtual IDisposable * | registerSessionHooks (Pipeline &) |
| Register the module hooks on the convenient hookpoints of the pipeline. | |
Protected Member Functions | |
| AModule (const std::string &name, const std::string &description, const Version &version, const Version &minimumApiVersion) | |
| AModule constructor, which defines module's informations. | |
| virtual | ~AModule () |
| Virtual destructor for the module. | |
Protected Attributes | |
| std::string | name_ |
| Contains module's name. | |
| std::string | description_ |
| Contains module's description. | |
| Version | version_ |
| Contains module version. | |
| Version | minimumApiVersion_ |
| Minimum API version. | |
Class used to operate with dynamically loaded modules.
Each module must provide a function to allow its loading at runtime, matching the following prototype:
extern "C" bref::AModule *loadModule(bref::ILogger *, const bref::ServerConfig &, const bref::IConfHelper &);
Once the module is loaded, a version check should be performed as follows:
| bref::AModule::AModule | ( | const std::string & | name, |
| const std::string & | description, | ||
| const Version & | version, | ||
| const Version & | minimumApiVersion | ||
| ) | [protected] |
AModule constructor, which defines module's informations.
| name | Contains module's name |
| description | Contains module's description |
| version | Contain's module's version |
| minimumApiVersion | Required API version to use the module |
| virtual bref::AModule::~AModule | ( | ) | [inline, protected, virtual] |
| virtual const std::string& bref::AModule::description | ( | ) | const [virtual] |
Retrieve the module's description.
| virtual const Version& bref::AModule::minimumApiVersion | ( | ) | const [virtual] |
Retrieve the minimum API version the module is compatible with.
| virtual const std::string& bref::AModule::name | ( | ) | const [virtual] |
Retrieve the module's name.
| virtual void bref::AModule::registerHooks | ( | Pipeline & | ) | [inline, virtual] |
Register the module hooks on the convenient hookpoints of the pipeline.
Example:
void registerHooks(Pipeline & pipeline) { const float lowPriority = 0.5f; pipeline.connectionHooks.push_back(std::make_pair(&hook_function, lowPriority)); }
| [out] | pipeline | The pipeline. |
| virtual IDisposable* bref::AModule::registerSessionHooks | ( | Pipeline & | ) | [inline, virtual] |
Register the module hooks on the convenient hookpoints of the pipeline.
This method should be called by the server each time a new connection is made. The server should call IDisposable::dispose() on the returned value (if not null) when the connection is closed.
Example:
using namespace bref; class ModuleSession : public IDisposable { public: Pipeline::OnReceiveRequestHandler receive(const Environment &) { return Pipeline::OnReceiveRequestHandler(); } virtual void dispose() { delete this; } virtual ~ModuleSession() { } }; class Module { virtual IDisposable *registerSessionHooks(Pipeline & pipeline) { ModuleSession *ms = new ModuleSession(); Pipeline::OnReceiveHook hook(ms, &ModuleSession::receive); pipeline.onReceiveHooks.push_back(std::make_pair(hook, 0.5f)); return ms; } virtual void dispose() { delete this; } };
| [out] | pipeline | The pipeline. |
| virtual const Version& bref::AModule::version | ( | ) | const [virtual] |
Retrieve the module's version.
std::string bref::AModule::description_ [protected] |
Contains module's description.
Version bref::AModule::minimumApiVersion_ [protected] |
Minimum API version.
std::string bref::AModule::name_ [protected] |
Contains module's name.
Version bref::AModule::version_ [protected] |
Contains module version.
1.8.0