Audacity 3.2.0
Public Types | Public Member Functions | List of all members
Registry::VisitorFunctions< RegistryTraits, Reference > Struct Template Reference

#include <Registry.h>

Inheritance diagram for Registry::VisitorFunctions< RegistryTraits, Reference >:
[legend]
Collaboration diagram for Registry::VisitorFunctions< RegistryTraits, Reference >:
[legend]

Public Types

using NodeTypes = detail::VisitedNodeTypes< RegistryTraits >
 
using LeafTypes = detail::VisitedLeafTypes< RegistryTraits >
 

Public Member Functions

template<typename Visitors >
 VisitorFunctions (Visitors &&visitors)
 Type-erasing constructor. More...
 
void BeginGroup (const GroupItem< RegistryTraits > &item, const Path &path) const
 Call-through for a decorating pre-visitor. More...
 
void Visit (const SingleItem &item, const Path &path) const
 Call-through for a decorating leaf-visitor. More...
 
void EndGroup (const GroupItem< RegistryTraits > &item, const Path &path) const
 Call-through for a decorating post-visitor. More...
 

Detailed Description

template<typename RegistryTraits, bool Reference = false>
struct Registry::VisitorFunctions< RegistryTraits, Reference >

Adapt visitors, suitable to Visit(), as a std::function or a tuple of three std::functions, which other visitors may decorate with other steps

Template Parameters
Referenceif true, capture visitors by reference; else, move them

Definition at line 476 of file Registry.h.

Member Typedef Documentation

◆ LeafTypes

template<typename RegistryTraits , bool Reference = false>
using Registry::VisitorFunctions< RegistryTraits, Reference >::LeafTypes = detail::VisitedLeafTypes<RegistryTraits>

Definition at line 481 of file Registry.h.

◆ NodeTypes

template<typename RegistryTraits , bool Reference = false>
using Registry::VisitorFunctions< RegistryTraits, Reference >::NodeTypes = detail::VisitedNodeTypes<RegistryTraits>

Definition at line 480 of file Registry.h.

Constructor & Destructor Documentation

◆ VisitorFunctions()

template<typename RegistryTraits , bool Reference = false>
template<typename Visitors >
Registry::VisitorFunctions< RegistryTraits, Reference >::VisitorFunctions ( Visitors &&  visitors)
inline

Type-erasing constructor.

Parameters
visitorsone callable, for leaves only; or else a tuple(-like) of three callables (or type-switching tuples of callables), for group pre-visit, leaf visit, and group post-visit

Definition at line 489 of file Registry.h.

489 {
490 using namespace detail;
491 using namespace std;
492 decltype(auto) forwarded = forward<Visitors>(visitors);
493 static constexpr auto size = TupleSize<std::decay_t<Visitors>>;
494 static_assert(size == 1 || size == 3);
495 if constexpr (size == 1)
496 this->template emplace<0>(
497 MakeVisitorFunction<LeafTypes, Reference>(forwarded));
498 else if constexpr (size == 3)
499 this->template emplace<1>(
500 MakeVisitorFunction<NodeTypes, Reference>(get<0>(forwarded)),
501 MakeVisitorFunction<LeafTypes, Reference>(get<1>(forwarded)),
502 MakeVisitorFunction<NodeTypes, Reference>(get<2>(forwarded)));
503 }
STL namespace.

References size.

Member Function Documentation

◆ BeginGroup()

template<typename RegistryTraits , bool Reference = false>
void Registry::VisitorFunctions< RegistryTraits, Reference >::BeginGroup ( const GroupItem< RegistryTraits > &  item,
const Path path 
) const
inline

Call-through for a decorating pre-visitor.

Definition at line 505 of file Registry.h.

506 {
507 if (const auto *pTriple = std::get_if<1>(this))
508 (std::get<0>(*pTriple))(item, path);
509 }

Referenced by MenuRegistry::Visitor< MenuTraits >::Visitor().

Here is the caller graph for this function:

◆ EndGroup()

template<typename RegistryTraits , bool Reference = false>
void Registry::VisitorFunctions< RegistryTraits, Reference >::EndGroup ( const GroupItem< RegistryTraits > &  item,
const Path path 
) const
inline

Call-through for a decorating post-visitor.

Definition at line 522 of file Registry.h.

523 {
524 if (const auto *pTriple = std::get_if<1>(this))
525 (std::get<2>(*pTriple))(item, path);
526 }

Referenced by MenuRegistry::Visitor< MenuTraits >::Visitor().

Here is the caller graph for this function:

◆ Visit()

template<typename RegistryTraits , bool Reference = false>
void Registry::VisitorFunctions< RegistryTraits, Reference >::Visit ( const SingleItem item,
const Path path 
) const
inline

Call-through for a decorating leaf-visitor.

Definition at line 511 of file Registry.h.

511 {
512 using Function = detail::LeafVisitorFunction<RegistryTraits>;
513 static const auto selector = Callable::OverloadSet{
514 [](const Function& fn) -> const Function & { return fn; },
515 [](auto &&self) -> const Function & {
516 return std::get<1>(self); }
517 };
518 const auto &function = Variant::Visit(selector, *this);
519 function(item, path);
520 }
static const auto fn
decltype(auto) Visit(Visitor &&vis, Variant &&var)
Mimic some of std::visit, for the case of one visitor only.
Definition: Variant.h:138

References fn, and Variant::Visit().

Referenced by MenuRegistry::Visitor< MenuTraits >::Visitor().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this struct was generated from the following file: