![]() |
LeechCraft
0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
|
Class for hook-based communication between plugins. More...
#include "ihookproxy.h"
Public Member Functions | |
virtual | ~IHookProxy () |
virtual void | CancelDefault ()=0 |
Cancels default handler of the event. More... | |
virtual const QVariant & | GetReturnValue () const =0 |
Returns the current "return value" of this hook call chain. More... | |
virtual void | SetReturnValue (const QVariant &value)=0 |
Sets the "return value" of this hook chain. More... | |
virtual QVariant | GetValue (const QByteArray &name) const =0 |
Returns the value of the given parameter. More... | |
virtual void | SetValue (const QByteArray &name, const QVariant &value)=0 |
Updates the value of the given parameter. More... | |
Class for hook-based communication between plugins.
This interface is designed to be implemented by classes that allow plugins to communicate with each other using hooks. Usage of somewhat standard implementation, Util::DefaultHookProxy, is encouraged.
The implementation of this interface may also be considered to be used as a container for parameters that could be passed to hooks, modified there and used back in the default handler. For that, GetValue() and SetValue() members are used.
Parameters are identified by their names, and the names are usually documented for each corresponding hook.
So, a hook should get the current value of the parameter by calling GetValue(), do the required work and possibly update the parameter by calling SetValue().
Please note that if several hooks are connected to a single hook point, the changes to parameters made by previously called hooks would be visible to next hooks in chain. That is intentional and by design.
It only makes sense to pass parameters like that for objects of types that are copyable and are usually passed by value or by reference. For example, that may be standard scalar types (int, bool), or QString, QByteArray and such.
The hook may cancel the default handler of an event by calling CancelDefault().
Definition at line 53 of file ihookproxy.h.
|
inlinevirtual |
Definition at line 56 of file ihookproxy.h.
|
pure virtual |
Cancels default handler of the event.
A canceled event handler can't be uncanceled later.
Implemented in LC::Util::DefaultHookProxy.
|
pure virtual |
Returns the current "return value" of this hook call chain.
Implemented in LC::Util::DefaultHookProxy.
|
pure virtual |
Returns the value of the given parameter.
This function returns current value of the given parameter, or a null QVariant() if no such parameter has been set.
[in] | name | The name of the parameter. |
Implemented in LC::Util::DefaultHookProxy.
|
pure virtual |
Sets the "return value" of this hook chain.
Consequent calls to this function would overwrite the previously set value.
[in] | value | The new return value of this hook. |
Implemented in LC::Util::DefaultHookProxy.
|
pure virtual |
Updates the value of the given parameter.
This function sets the value of the parameter identified by name, possibly overwriting previous value (if any).
Setting a null QVariant as value effectively erases the parameter value.
[in] | name | The name of the parameter. |
[in] | value | The new value of the parameter. |
Implemented in LC::Util::DefaultHookProxy.