Headers

Headers for General Use

The following headers are sufficient for most basic uses of the library.

The following headers make it possible to use standard smart pointers with virtual_ptr:

High-level Headers

<boost/openmethod/core.hpp>

Defines the main constructs of the library: methods, overriders and virtual pointers, and mechanisms to implement them. Does not define any public macros apart from BOOST_OPENMETHOD_DEFAULT_REGISTRY, if it is not defined already.

<boost/openmethod/macros.hpp>

Defines the public macros of the library, such as BOOST_OPENMETHOD, BOOST_OPENMETHOD_CLASSES, etc.

There is little point in including this header directly, as this has the same effect as including boost/openmethod.hpp, which is shorter.

<boost/openmethod.hpp>

Includes core.hpp and macros.hpp.

<boost/openmethod/initialize.hpp>

Provides the initialize and finalize functions. This header is typically included in the translation unit containing main. Translation units that dynamically load or unload shared libraries may also need to call those functions.

<boost/openmethod/interop/std_shared_ptr.hpp>

Provides a virtual_traits specialization that makes it possible to use a std::shared_ptr in place of a raw pointer or reference in virtual parameters.

<boost/openmethod/interop/std_unique_ptr.hpp>

Provides a virtual_traits specialization that makes it possible to use a std::unique_ptr in place of a raw pointer or reference in virtual parameters.

<boost/openmethod/interop/std_weak_ptr.hpp>

Provides weak_virtual_ptr, a class that tracks an object with a std::weak_ptr and remembers its v-table pointer. It is not a virtual_ptr, and cannot be used in virtual parameters; its lock function returns a shared_virtual_ptr, without a hash table lookup.

<boost/openmethod/interop/boost_intrusive_ptr.hpp>

Provides a virtual_traits specialization that makes it possible to use a boost::intrusive_ptr in place of a raw pointer or reference in virtual parameters.

<boost/openmethod/interop/virtual_any.hpp>

Provides virtual_any, a wide any that combines an any, held by value, with a pointer to the v-table for the contained value - similar to virtual_ptr.

<boost/openmethod/interop/std_any.hpp>

Provides virtual_traits specializations that make it possible to use a std::any in virtual parameters.

<boost/openmethod/interop/boost_any.hpp>

Provides virtual_traits specializations that make it possible to use a boost::any in virtual parameters.

<boost/openmethod/interop/boost_type_erasure.hpp>

Provides specializations for using a boost::type_erasure::any in virtual parameters.

The headers below are for advanced use.

Policy Headers

Most stock policies live in a header of their own. Those that make up default_registry come in with <boost/openmethod.hpp>; the others are included explicitly. A policy header depends on nothing but the library’s foundations, so it may be included in any order relative to <boost/openmethod.hpp> - in particular after it, which is where a program that overrides BOOST_OPENMETHOD_DEFAULT_REGISTRY puts it.

Three policies have no header of their own: indirect_vptr, runtime_checks and deferred_static_rtti are defined alongside registry itself, and are available as soon as <boost/openmethod.hpp> has been included.

<boost/openmethod/policies/std_rtti.hpp>

Provides an implementation of the rtti policy using standard RTTI. Part of default_registry.

<boost/openmethod/policies/fast_perfect_hash.hpp>

Provides an implementation of the hash policy using a fast perfect hash function. Part of default_registry.

<boost/openmethod/policies/vptr_vector.hpp>

Provides an implementation of the vptr policy that stores the v-table pointers in a std::vector indexed by type ids, possibly hashed. Part of default_registry.

<boost/openmethod/policies/default_error_handler.hpp>

Provides an implementation of the error_handler policy that calls a std::function<void(openmethod_error)> when an error is encountered, and before the library aborts the program. Part of default_registry.

<boost/openmethod/policies/stderr_output.hpp>

Provides an implementation of the output policy that writes diagnostics to the C standard error stream (not using iostreams). Part of default_registry.

default_registry also contains runtime_checks when BOOST_OPENMETHOD_ENABLE_RUNTIME_CHECKS is defined. That policy needs no header - see above.

<boost/openmethod/policies/static_rtti.hpp>

Provides a minimal implementation of the rtti policy that does not depend on standard RTTI.

<boost/openmethod/policies/throw_error_handler.hpp>

Provides an implementation of the error_handler policy that throws errors as exceptions.

<boost/openmethod/policies/vptr_map.hpp>

Provides an implementation of the vptr policy that stores the v-table pointers in a map (by default a std::map) indexed by type ids.

<boost/openmethod/policies/minimal_perfect_hash.hpp>

Provides an implementation of the type_hash policy that spends one slot per type id whatever the type ids are, by hash and displace.

<boost/openmethod/policies/two_level_hash.hpp>

Provides an implementation of the type_hash policy that indexes a power-of-two table with a per-bucket multiplier.

<boost/openmethod/policies/minimal_cover_hash.hpp>

Provides an implementation of the type_hash policy that indexes by the smallest set of bit positions that separates the type ids, extracted with BMI2's pext. Requires that instruction; see Type Ids Across Modules for when to prefer each of the three.

Headers Included by Other Headers

These are the library’s foundations. Every other header includes them, and a program has no reason to include either directly.

<boost/openmethod/preamble.hpp>

Defines registry, the stock policy categories, and everything else needed to define a registry.

<boost/openmethod/default_registry.hpp>

Defines default_registry and indirect_registry, and includes the five policy headers the former is built from. core.hpp includes it unconditionally, so both registries are available as soon as <boost/openmethod.hpp> has been included, whether as the default registry or as a base for one built with with and without.