ADTF  3.18.3
Using Runtime Hooks

With the help of the Runtime Hook mechanism it is possible to react upon changes happening within the runtime.

For a complete list of hook locations and the information provided by those hooks see IRuntime::tRuntimeHookId.

Please keep in mind that this is a very advanced interaction with the ADTF System that is rarely required. Most Problems can be easily resolved without resorting to this techinque. Always consider the following options first:

  • Use a specific initialisation order of filters to ciricumvent dependency problems.
  • Use the IService::ServiceEvent method whenever possible instead of this method.

Important Notes

  • If you implement hook functionality in a filter make sure that you never transmit samples when your filters Start method has not been called, i.e. transmission of samples is only allowed during the running state.

Example usage

The following example shows an example IRuntimeHook implementation.

tResult cMyObject::RuntimeHook(tHookInfo* psHookInfo, const iobject_ptr<IObject>& pObject)
{
if (IRuntime::RHI_RunLevelPostIncrement == psHookInfo->idHook &&
adtf::base::tADTFRunLevel::RL_Running == psHookInfo->ui32Param1)
{
LOG_INFO("Runlevel RL_Running has been reached");
}
else if (IRuntime::RHI_RunLevelPreDecrement == psHookInfo->idHook &&
adtf::base::tADTFRunLevel::RL_Running == psHookInfo->ui32Param1)
{
LOG_INFO("Runlevel is going to be decreased to RL_Application");
}
else if (IRuntime::RHI_RegisterObject == psHookInfo->idHook)
{
LOG_INFO(cString::Format("Object '%s' has been registered.", reinterpret_cast<const char*>(psHookInfo->pvData)));
}
}
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
@ RHI_RunLevelPreDecrement
Called before the run level is decremented.
Definition: runtime_intf.h:224
@ RHI_RunLevelPostIncrement
Called after the run level was incremented.
Definition: runtime_intf.h:220
@ RHI_RegisterObject
Called after an object has been registered.
Definition: runtime_intf.h:150