LeechCraft  0.6.70-15082-g543737046d
Modular cross-platform feature rich live environment.
LC::IHookProxy Class Referenceabstract

Class for hook-based communication between plugins. More...

#include "ihookproxy.h"

+ Inheritance diagram for LC::IHookProxy:

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...
 

Detailed Description

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().

See also
Util::DefaultHookProxy

Definition at line 53 of file ihookproxy.h.

Constructor & Destructor Documentation

◆ ~IHookProxy()

virtual LC::IHookProxy::~IHookProxy ( )
inlinevirtual

Definition at line 56 of file ihookproxy.h.

Member Function Documentation

◆ CancelDefault()

virtual void LC::IHookProxy::CancelDefault ( )
pure virtual

Cancels default handler of the event.

A canceled event handler can't be uncanceled later.

Implemented in LC::Util::DefaultHookProxy.

◆ GetReturnValue()

virtual const QVariant& LC::IHookProxy::GetReturnValue ( ) const
pure virtual

Returns the current "return value" of this hook call chain.

Returns
The current "return value".

Implemented in LC::Util::DefaultHookProxy.

◆ GetValue()

virtual QVariant LC::IHookProxy::GetValue ( const QByteArray &  name) const
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.

Parameters
[in]nameThe name of the parameter.
Returns
The parameter's value or null QVariant() if no such parameter exists.
See also
SetValue()

Implemented in LC::Util::DefaultHookProxy.

◆ SetReturnValue()

virtual void LC::IHookProxy::SetReturnValue ( const QVariant &  value)
pure virtual

Sets the "return value" of this hook chain.

Consequent calls to this function would overwrite the previously set value.

Parameters
[in]valueThe new return value of this hook.

Implemented in LC::Util::DefaultHookProxy.

◆ SetValue()

virtual void LC::IHookProxy::SetValue ( const QByteArray &  name,
const QVariant &  value 
)
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.

Parameters
[in]nameThe name of the parameter.
[in]valueThe new value of the parameter.
See also
GetValue()

Implemented in LC::Util::DefaultHookProxy.


The documentation for this class was generated from the following file: