Implements a singleton handler that has a default instance and can be changed to another instance at runtime. All instances have to derive from the same interface. The singleton handler owns the default instance but all other instances are created externally.
More...
Implements a singleton handler that has a default instance and can be changed to another instance at runtime. All instances have to derive from the same interface. The singleton handler owns the default instance but all other instances are created externally.
- Template Parameters
-
| Interface | The interface of the handler instances. |
| Default | The type of the default instance. Must be equal to or derive from Interface. |
| Hooks | A struct that implements onSetAfterFinalize which is called when attempting to set or reset the handler after finalize was called. |
- Note
- In the special case where Default equals Interface, no polymorphism is required.
-
The lifetime of external non-default instances must exceed the lifetime of the PolymorphicHandler.
-
The PolymorphicHandler is guaranteed to provide a valid handler during the whole program lifetime (static). It is hence not advisable to have other static variables depend on the PolymorphicHandler. It must be ensured that they are destroyed before the PolymorphicHandler.
-
Hooks must implement static void onSetAfterFinalize(Interface& /*currentInstance*/, Interface& /*newInstance*/).
-
DefaultHooks call abort if the handler is set or reset after finalize
Definition at line 57 of file polymorphic_handler.hpp.