Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
MenuRegistry::Visitor< MenuTraits > Struct Template Reference

#include <MenuRegistry.h>

Inheritance diagram for MenuRegistry::Visitor< MenuTraits >:
[legend]
Collaboration diagram for MenuRegistry::Visitor< MenuTraits >:
[legend]

Public Member Functions

 Visitor (VisitorFunctions< MenuTraits > functions, std::function< void()> doSeparator)
 
- Public Member Functions inherited from Registry::VisitorFunctions< MenuTraits >
 VisitorFunctions (Visitors &&visitors)
 Type-erasing constructor. More...
 
void BeginGroup (const GroupItem< MenuTraits > &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< MenuTraits > &item, const Path &path) const
 Call-through for a decorating post-visitor. More...
 
- Public Member Functions inherited from MenuRegistry::detail::VisitorBase
std::pair< bool, bool > ShouldBeginGroup (const ItemProperties *pProperties)
 
void AfterBeginGroup (const ItemProperties *pProperties)
 
bool ShouldEndGroup (const ItemProperties *pProperties)
 
bool ShouldDoSeparator ()
 

Private Attributes

const VisitorFunctions< MenuTraits > mWrapped
 
const std::function< void()> mDoSeparator
 

Additional Inherited Members

- Public Types inherited from Registry::VisitorFunctions< MenuTraits >
using NodeTypes = detail::VisitedNodeTypes< MenuTraits >
 
using LeafTypes = detail::VisitedLeafTypes< MenuTraits >
 
- Public Attributes inherited from MenuRegistry::detail::VisitorBase
std::vector< bool > firstItem
 
std::vector< bool > needSeparator
 

Detailed Description

template<typename MenuTraits>
struct MenuRegistry::Visitor< MenuTraits >

Wraps the behavior of another VisitorFuntions<MenuTraits>, and also needs a callback for what to do at separator lines

Definition at line 135 of file MenuRegistry.h.

Constructor & Destructor Documentation

◆ Visitor()

template<typename MenuTraits >
MenuRegistry::Visitor< MenuTraits >::Visitor ( VisitorFunctions< MenuTraits >  functions,
std::function< void()>  doSeparator 
)
inline

Definition at line 139 of file MenuRegistry.h.

141 : VisitorFunctions<MenuTraits>{ std::tuple{
142
143 [this](const GroupItem<MenuTraits> &item, const Path &path)
144 {
145 using namespace MenuRegistry;
146 const auto pProperties = dynamic_cast<const ItemProperties*>(&item);
147 auto [begin, separate] = ShouldBeginGroup(pProperties);
148 if (separate)
149 mDoSeparator();
150 if (begin)
151 mWrapped.BeginGroup(item, path);
152 AfterBeginGroup(pProperties);
153 },
154
155 [this](const Registry::SingleItem &item, const Path &path)
156 {
157 if (ShouldDoSeparator())
158 mDoSeparator();
159 mWrapped.Visit(item, path);
160 },
161
162 [this](const GroupItem<MenuTraits> &item, const Path &path)
163 {
164 using namespace MenuRegistry;
165 const auto pProperties = dynamic_cast<const ItemProperties*>(&item);
166 if (ShouldEndGroup(pProperties))
167 mWrapped.EndGroup(item, path);
168 }
169
170 }}
171 , mWrapped{ move(functions) }
172 , mDoSeparator{ move(doSeparator) }
173 {}
std::vector< Identifier > Path
Definition: Registry.h:71
const char * begin(const char *str) noexcept
Definition: StringUtils.h:101
A mix-in discovered by dynamic_cast; independent of the Traits.
Definition: MenuRegistry.h:106
const VisitorFunctions< MenuTraits > mWrapped
Definition: MenuRegistry.h:176
const std::function< void()> mDoSeparator
Definition: MenuRegistry.h:177
void AfterBeginGroup(const ItemProperties *pProperties)
bool ShouldEndGroup(const ItemProperties *pProperties)
std::pair< bool, bool > ShouldBeginGroup(const ItemProperties *pProperties)
Has variadic and range constructors that check types.
Definition: Registry.h:292
Common abstract base class for items that are not groups.
Definition: Registry.h:224
void BeginGroup(const GroupItem< RegistryTraits > &item, const Path &path) const
Call-through for a decorating pre-visitor.
Definition: Registry.h:505
void EndGroup(const GroupItem< RegistryTraits > &item, const Path &path) const
Call-through for a decorating post-visitor.
Definition: Registry.h:522
void Visit(const SingleItem &item, const Path &path) const
Call-through for a decorating leaf-visitor.
Definition: Registry.h:511

References MenuRegistry::detail::VisitorBase::AfterBeginGroup(), details::begin(), Registry::VisitorFunctions< RegistryTraits, Reference >::BeginGroup(), Registry::VisitorFunctions< RegistryTraits, Reference >::EndGroup(), MenuRegistry::Visitor< MenuTraits >::mDoSeparator, MenuRegistry::Visitor< MenuTraits >::mWrapped, MenuRegistry::detail::VisitorBase::ShouldBeginGroup(), MenuRegistry::detail::VisitorBase::ShouldDoSeparator(), MenuRegistry::detail::VisitorBase::ShouldEndGroup(), and Registry::VisitorFunctions< RegistryTraits, Reference >::Visit().

Here is the call graph for this function:

Member Data Documentation

◆ mDoSeparator

template<typename MenuTraits >
const std::function<void()> MenuRegistry::Visitor< MenuTraits >::mDoSeparator
private

Definition at line 177 of file MenuRegistry.h.

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

◆ mWrapped

template<typename MenuTraits >
const VisitorFunctions<MenuTraits> MenuRegistry::Visitor< MenuTraits >::mWrapped
private

Definition at line 176 of file MenuRegistry.h.

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


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