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)
{
adtf::base::tADTFRunLevel::RL_Running == psHookInfo->ui32Param1)
{
LOG_INFO(
"Runlevel RL_Running has been reached");
}
adtf::base::tADTFRunLevel::RL_Running == psHookInfo->ui32Param1)
{
LOG_INFO(
"Runlevel is going to be decreased to RL_Application");
}
{
LOG_INFO(cString::Format(
"Object '%s' has been registered.",
reinterpret_cast<const char*
>(psHookInfo->pvData)));
}
}
#define LOG_INFO(...)
Logs an info message.
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
A common result class usable as return value throughout.
@ RHI_RunLevelPreDecrement
Called before the run level is decremented.
@ RHI_RunLevelPostIncrement
Called after the run level was incremented.
@ RHI_RegisterObject
Called after an object has been registered.