boost::openmethod::registry
Methods, classes and policies.
Synopsis
Declared in <boost/openmethod/preamble.hpp>
template<class... Policy>
class registry;
Description
Methods exist in the context of a registry. Any class used as a method or overrider parameter, or in as a method call argument, must be registered with the same registry.
Before calling a method, its registry must be initialized with the initialize function. This is typically done at the beginning of main.
Multiple registries can co‐exist in the same program. They must be initialized individually. Classes referenced by methods in different registries must be registered with each registry.
A registry also contains a set of policies that control how certain operations are performed. For example, the rtti policy provides type information, implements dynamic casting, etc. It can be replaced to interface with custom RTII systems (like LLVM's).
Policies are implemented as Boost.MP11 quoted metafunctions. A policy class must contain a fn<Registry> template that provides a set of static members, specific to the responsibility of the policy. Registries instantiate policies by passing themselves to the nested fn class templates.
There are two reason for this design.
Some policies are "stateful": they contain static data members. Since several registries can co‐exist in the same program, each stateful policy needs its own, separate set of static data members. For example, vptr_vector, a "vptr" policy, contains a static vector of vptrs, which cannot be shared with other registries.
Also, some policies need access to other policies in the same registry. They can be accessed via the Registry template parameter. For example, vptr_vector hashes type_ids before using them as an indexes, if Registry cotains a type_hash policy. It performs out‐of‐bounds checks if Registry contains the runtime_checks policy. If an error is detected, it invokes the error_handler policy if there is one.
Requirements
-
`Policy` must contain a `category` alias to its root base class. The registry may contain at most one policy per category.
-
`Policy` must contain a `fn<Registry>` metafunction.
Types
Name |
Description |
The type of this registry. |
|
List of policies selected in a registry. |
|
Find a policy by category. |
|
Add or replace policies. |
|
Remove policies. |
|
The registry's rtti policy. |
|
The registry's vptr policy if it contains one, or |
|
The registry's error_handler policy if it contains one, or |
|
The registry's output policy if it contains one, or |
Static Data Members
Name |
Description |
A pointer to the virtual table for a registered class. |
|
|
|
|
|
|
|
|
|
|
|
|