Implement dynamic destination state selection.

The configuration API has been extended with permit_dynamic and
permit_dynamic_if to allow the destination state to be determined based
on a callable object.
The overloads that take a parameterized trigger forward the trigger
arguments to the callable when the trigger is fired.