Skip to content

Commit 6c883f6

Browse files
committed
wip
1 parent bd50924 commit 6c883f6

1 file changed

Lines changed: 63 additions & 9 deletions

File tree

include/boost/openmethod/registry.hpp

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -547,13 +547,16 @@ struct use_class_aux;
547547
//! initialized independently. Classes referenced by methods in different
548548
//! registries must be registered with each registry individually.
549549
//!
550-
//! A registry contains a list of @ref policies, which can be used to customize
551-
//! certain important aspects of the library.
552550
//!
553-
//! @see @ref policies
554551
//!
552+
//! @tparam Policies The policies used in the registry.
555553
//!
556-
554+
//! @par Requirements
555+
//!
556+
//! `Policies` must be models of @ref policies::Policy. There may be at most one
557+
//! policy per category, i.e. `Policies::category...` must all be different.
558+
//!
559+
//! @see @ref policies
557560
template<class... Policies>
558561
class registry : detail::registry_base {
559562
inline static detail::class_catalog classes;
@@ -609,52 +612,103 @@ class registry : detail::registry_base {
609612
//! `<boost/openmethod/initialize.hpp>` header.
610613
static void finalize();
611614

612-
//! A pointer to the virtual table for a class.
615+
//! A pointer to the virtual table for a registered class.
616+
//!
617+
//! `static_vptr` is set by @ref initialize to the address of the class's
618+
//! virtual table. It remains valid until the next call to `initialize` or
619+
//! `finalize`.
613620
//!
614621
//! @tparam Class A registered class.
615622
template<class Class>
616623
inline static vptr_type static_vptr;
617624

625+
//! The list of policies selected in a registry.
626+
//!
627+
//! `policy_list` is a Boost.Mp11 list containing the policies passed to the
628+
//! @ref registry clas template.
629+
//!
630+
//! @tparam Class A registered class.
618631
using policy_list = mp11::mp_list<Policies...>;
619632

620-
template<class PolicyCategory>
633+
//! Returns the policy for a policy category.
634+
//!
635+
//! `policy` searches for a policy that derives from the specified @ref
636+
//! PolicyCategory. If none is found, it aliases to `void`. Otherwise, it
637+
//! aliases to the policy's `fn` class template, instantiated for this
638+
//! registry.
639+
//!
640+
//! @tparam Category A model of @ref policies::PolicyCategory.
641+
template<class Category>
621642
using policy = typename detail::get_policy_aux<
622643
registry,
623644
mp11::mp_find_if_q<
624645
policy_list,
625646
mp11::mp_bind_front_q<
626-
mp11::mp_quote_trait<std::is_base_of>, PolicyCategory>>>::type;
647+
mp11::mp_quote_trait<std::is_base_of>, Category>>>::type;
627648

649+
//! Returns a copy of this registry, with additional policies.
650+
//!
651+
//! `with` aliases to a registry containing `NewPolicies`, in addition to
652+
//! this registry's policies that are not in the same category as any of the
653+
//! `NewPolicies`.
654+
//!
655+
//! @tparam NewPolicies Models of @ref policies::Policy.
628656
template<class... NewPolicies>
629657
using with = boost::mp11::mp_apply<
630658
registry, typename detail::with_aux<policy_list, NewPolicies...>::type>;
631659

632-
template<class... RemovePolicies>
660+
//! Returns a copy of this registry, with some policies removed.
661+
//!
662+
//! `without` returns a copy of this registry, without the policies that
663+
//! derive from `Categories`.
664+
//!
665+
//! @tparam Categories Models of @ref policies::PolicyCategory.
666+
template<class... Categories>
633667
using without = boost::mp11::mp_apply<
634668
registry,
635-
typename detail::without_aux<policy_list, RemovePolicies...>::type>;
669+
typename detail::without_aux<policy_list, Categories...>::type>;
636670

671+
//! The registry's rtti policy.
637672
using rtti = policy<policies::rtti>;
638673

674+
//! The registry's vptr policy if it contains one, or `void`.
639675
using vptr = policy<policies::vptr>;
676+
677+
//! `true` if the registry has a vptr policy.
640678
static constexpr auto has_vptr = !std::is_same_v<vptr, void>;
641679

680+
//! The registry's error_handler policy if it contains one, or `void`.
642681
using error_handler = policy<policies::error_handler>;
682+
683+
//! `true` if the registry has an error_handler policy.
643684
static constexpr auto has_error_handler =
644685
!std::is_same_v<error_handler, void>;
645686

687+
//! The registry's output policy if it contains one, or `void`.
646688
using output = policy<policies::output>;
689+
690+
//! `true` if the registry has an output policy.
647691
static constexpr auto has_output = !std::is_same_v<output, void>;
648692

693+
//! The registry's trace policy if it contains one, or `void`.
649694
using trace = policy<policies::trace>;
695+
696+
//! `true` if the registry has a trace policy.
650697
static constexpr auto has_trace = !std::is_same_v<trace, void>;
651698

699+
//! `true` if the registry has a deferred_static_rtti policy.
652700
static constexpr auto has_deferred_static_rtti =
653701
!std::is_same_v<policy<policies::deferred_static_rtti>, void>;
702+
703+
//! `true` if the registry has a runtime_checks policy.
654704
static constexpr auto has_runtime_checks =
655705
!std::is_same_v<policy<policies::runtime_checks>, void>;
706+
707+
//! `true` if the registry has an indirect_vptr policy.
656708
static constexpr auto has_indirect_vptr =
657709
!std::is_same_v<policy<policies::indirect_vptr>, void>;
710+
711+
//! `true` if the registry has a n2216 policy.
658712
static constexpr auto has_n2216 =
659713
!std::is_same_v<policy<policies::n2216>, void>;
660714
};

0 commit comments

Comments
 (0)