|
Krotos Modules 3
|
Middleware class for managing preset events and hooks. More...
#include <PresetEventMiddleware.h>
Public Member Functions | |
| void | addHook (std::unique_ptr< PresetEventHook > hook) |
| Adds a new hook to the middleware. | |
| bool | removeHook (PresetEventHook *hook) |
| Removes a hook from the middleware. | |
| PresetLoadResponse | processPresetLoad (PresetLoadRequest &request) |
| Processes a preset load request through all registered hooks. | |
| KwidgetLoadResponse | processKwidgetLoad (KwidgetLoadRequest &request) |
| Processes a Kwidget load request through all registered hooks. | |
Private Attributes | |
| std::vector< std::unique_ptr< PresetEventHook > > | m_hooks |
Middleware class for managing preset events and hooks.
The middleware can be used to add hooks that intercept and modify preset and Kwidget loading events. The middleware will process the hooks in the order they were added, and stop processing if a hook returns an unsuccessful response.
You can create your own hooks by deriving from the PresetEventHook class and implementing the onPresetLoad and onKwidgetLoad methods. Then add your hook to the middleware using the addHook method and call processPresetLoad or processKwidgetLoad at the point where the event takes place, using the response and request objects to pass the specific event data between the middleware and the caller.
| void krotos::PresetEventMiddleware::addHook | ( | std::unique_ptr< PresetEventHook > | hook | ) |
Adds a new hook to the middleware.
| hook | Unique pointer to the hook to be added. |
| KwidgetLoadResponse krotos::PresetEventMiddleware::processKwidgetLoad | ( | KwidgetLoadRequest & | request | ) |
| PresetLoadResponse krotos::PresetEventMiddleware::processPresetLoad | ( | PresetLoadRequest & | request | ) |
Processes a preset load request through all registered hooks.
| request | The preset load request to be processed. |
| bool krotos::PresetEventMiddleware::removeHook | ( | PresetEventHook * | hook | ) |
Removes a hook from the middleware.
| hook | Pointer to the hook to be removed. |
|
private |