Audacity 3.2.0
Namespaces | Classes | Typedefs | Functions | Variables
Registry Namespace Reference

Namespaces

namespace  detail
 

Classes

struct  AcceptableItemType
 
struct  ActualItem
 Find the real item type (following chains of indirections) More...
 
struct  ActualItem< detail::ComputedItem< C, T > >
 
struct  ActualItem< detail::IndirectItem< T > >
 
struct  AllTypes
 
struct  DefaultTraits
 
struct  EmptyContext
 
struct  GroupItem
 Has variadic and range constructors that check types. More...
 
struct  OrderingHint
 
struct  OrderingPreferenceInitializer
 
struct  Placement
 
class  RegisteredItem
 Generates classes whose instances register items at construction. More...
 
struct  SingleItem
 Common abstract base class for items that are not groups. More...
 
struct  VisitorFunctions
 

Typedefs

using Path = std::vector< Identifier >
 
using BaseItemTypes = TypeList::List< detail::IndirectItemBase, detail::ComputedItemBase, struct SingleItem, struct detail::GroupItemBase >
 
template<typename Item >
using AcceptableBaseItem = TypeList::HasBaseIn< Item, BaseItemTypes >
 
template<typename RegistryTraits >
using AllTypes_t = typename AllTypes< RegistryTraits >::type
 
template<typename T >
using ActualItem_t = typename ActualItem< T >::type
 
template<typename RegistryTraits , typename Item >
using AcceptableType = AcceptableItemType< Item, AllTypes_t< RegistryTraits > >
 

Functions

template<typename Item >
std::unique_ptr< detail::IndirectItem< Item > > Indirect (const std::shared_ptr< Item > &ptr)
 A convenience function. More...
 
template<typename RegistryTraits , typename Item >
void RegisterItem (GroupItem< RegistryTraits > &registry, const Placement &placement, std::unique_ptr< Item > pItem)
 
template<typename RegistryTraits , typename Visitors >
void Visit (const Visitors &visitors, const GroupItem< RegistryTraits > *pTopItem, const GroupItem< RegistryTraits > *pRegistry={}, typename RegistryTraits::ComputedItemContextType &computedItemContext=RegistryTraits::ComputedItemContextType::Instance)
 
template<typename RegistryTraits >
void VisitWithFunctions (const VisitorFunctions< RegistryTraits > &visitors, const GroupItem< RegistryTraits > *pTopItem, const GroupItem< RegistryTraits > *pRegistry={}, typename RegistryTraits::ComputedItemContextType &computedItemContext=RegistryTraits::ComputedItemContextType::Instance)
 

Variables

template<typename Item >
constexpr auto AcceptableBaseItem_v
 
template<typename RegistryTraits >
constexpr auto AcceptableTraits_v
 
template<typename RegistryTraits , typename Item >
constexpr auto AcceptableType_v
 
constexpr auto NoOp = [](auto&, auto&){}
 Supply this when one member of a visitor function triple isn't needed. More...
 

Typedef Documentation

◆ AcceptableBaseItem

template<typename Item >
using Registry::AcceptableBaseItem = typedef TypeList::HasBaseIn<Item, BaseItemTypes>

Definition at line 136 of file Registry.h.

◆ AcceptableType

template<typename RegistryTraits , typename Item >
using Registry::AcceptableType = typedef AcceptableItemType<Item, AllTypes_t<RegistryTraits> >

Definition at line 329 of file Registry.h.

◆ ActualItem_t

template<typename T >
using Registry::ActualItem_t = typedef typename ActualItem<T>::type

Definition at line 317 of file Registry.h.

◆ AllTypes_t

template<typename RegistryTraits >
using Registry::AllTypes_t = typedef typename AllTypes<RegistryTraits>::type

Definition at line 147 of file Registry.h.

◆ BaseItemTypes

The underlying registry merging procedure assumes the listed types are an exhaustive partition

Definition at line 131 of file Registry.h.

◆ Path

using Registry::Path = typedef std::vector<Identifier>

Definition at line 71 of file Registry.h.

Function Documentation

◆ Indirect()

template<typename Item >
std::unique_ptr< detail::IndirectItem< Item > > Registry::Indirect ( const std::shared_ptr< Item > &  ptr)
inline

A convenience function.

Definition at line 175 of file Registry.h.

177 {
178 return std::make_unique<detail::IndirectItem<Item>>( ptr );
179 }

◆ RegisterItem()

template<typename RegistryTraits , typename Item >
void Registry::RegisterItem ( GroupItem< RegistryTraits > &  registry,
const Placement placement,
std::unique_ptr< Item >  pItem 
)

Definition at line 371 of file Registry.h.

373 {
374 static_assert(AcceptableTraits_v<RegistryTraits>);
375 static_assert(AcceptableType_v<RegistryTraits, Item>,
376 "Registered item must be of one of the types listed in the registry's "
377 "traits");
378 detail::RegisterItem(registry, placement, move(pItem));
379 }
void RegisterItem(GroupItem< RegistryTraits > &registry, const Placement &placement, std::unique_ptr< Item > pItem)
Definition: Registry.h:371

References Registry::detail::RegisterItem().

Referenced by PopupMenuTable::RegisterItem().

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

◆ Visit()

template<typename RegistryTraits , typename Visitors >
void Registry::Visit ( const Visitors &  visitors,
const GroupItem< RegistryTraits > *  pTopItem,
const GroupItem< RegistryTraits > *  pRegistry = {},
typename RegistryTraits::ComputedItemContextType &  computedItemContext = RegistryTraits::ComputedItemContextType::Instance 
)

Top-down visitation of all items and groups in a tree rooted in pTopItem, as merged with pRegistry.

The merger of the trees is recomputed in each call, not saved. So neither given tree is modified. But there may be a side effect on preferences to remember the ordering imposed on each node of the unordered tree of registered items; each item seen in the registry for the first time is placed somewhere, and that ordering should be kept the same thereafter in later runs (which may add yet other previously unknown items).

Parameters
visitorsA tuple of size 1 or 3, or a callable.
  • If a triple, the first member is for pre-visit of group nodes, the last is for post-visit, and the middle for leaf visits.
  • If single, or a callable, then visit leaves only.
  • If a tuple, each member can be a tuple of callables (passed to TypeSwitch::Dispatch), or simply a single callable.
  • "tuple" means std::tuple or any other tuple-like type. The callables take a reference to an object of a const GroupItem<RegistryTraits> or a const SingleItem subtype, and the path up to its parent node.
computedItemContextis passed to factory functions of computed items

Definition at line 609 of file Registry.h.

611 {},
612 typename RegistryTraits::ComputedItemContextType &computedItemContext =
613 RegistryTraits::ComputedItemContextType::Instance)
614 {
615 static_assert(AcceptableTraits_v<RegistryTraits>);
616 detail::Visitor<RegistryTraits, Visitors> visitor{ visitors };
617 detail::Visit(visitor, pTopItem, pRegistry, &computedItemContext);
618 }
void Visit(const Visitors &visitors, const GroupItem< RegistryTraits > *pTopItem, const GroupItem< RegistryTraits > *pRegistry={}, typename RegistryTraits::ComputedItemContextType &computedItemContext=RegistryTraits::ComputedItemContextType::Instance)
Definition: Registry.h:609

Referenced by PrefsPanel::DefaultFactories(), SnapFunctionsRegistry::Find(), ExportPluginRegistry::Initialize(), Importer::Initialize(), LibraryPrefs::PopulateOrExchange(), ImportExportPrefs::PopulateOrExchange(), and NumericConverterRegistry::Visit().

Here is the caller graph for this function:

◆ VisitWithFunctions()

template<typename RegistryTraits >
void Registry::VisitWithFunctions ( const VisitorFunctions< RegistryTraits > &  visitors,
const GroupItem< RegistryTraits > *  pTopItem,
const GroupItem< RegistryTraits > *  pRegistry = {},
typename RegistryTraits::ComputedItemContextType &  computedItemContext = RegistryTraits::ComputedItemContextType::Instance 
)

Top-down visitation of all items and groups in a tree rooted in pTopItem, as merged with pRegistry.

The merger of the trees is recomputed in each call, not saved. So neither given tree is modified. But there may be a side effect on preferences to remember the ordering imposed on each node of the unordered tree of registered items; each item seen in the registry for the first time is placed somewhere, and that ordering should be kept the same thereafter in later runs (which may add yet other previously unknown items).

Parameters
visitorsA tuple of size 1 or 3, or a callable.
  • If a triple, the first member is for pre-visit of group nodes, the last is for post-visit, and the middle for leaf visits.
  • If single, or a callable, then visit leaves only.
  • If a tuple, each member can be a tuple of callables (passed to TypeSwitch::Dispatch), or simply a single callable.
  • "tuple" means std::tuple or any other tuple-like type. The callables take a reference to an object of a const GroupItem<RegistryTraits> or a const SingleItem subtype, and the path up to its parent node.
computedItemContextis passed to factory functions of computed items Like Visit but passing function(s) wrapped in std::function

Definition at line 623 of file Registry.h.

625 {},
626 typename RegistryTraits::ComputedItemContextType &computedItemContext =
627 RegistryTraits::ComputedItemContextType::Instance)
628 {
629 static_assert(AcceptableTraits_v<RegistryTraits>);
630 Variant::Visit([&](auto &&visitor){
631 Visit(visitor, pTopItem, pRegistry, computedItemContext);
632 }, visitors);
633 }
decltype(auto) Visit(Visitor &&vis, Variant &&var)
Mimic some of std::visit, for the case of one visitor only.
Definition: Variant.h:138

Referenced by PopupMenuTable::ExtendMenu(), anonymous_namespace{RealtimeEffectPanel.cpp}::EffectsMenuHelper::Populate(), SnapFunctionsRegistry::Visit(), ProjectStatusFieldsRegistry::Visit(), and MenuRegistry::Visit().

Here is the caller graph for this function:

Variable Documentation

◆ AcceptableBaseItem_v

template<typename Item >
constexpr auto Registry::AcceptableBaseItem_v
constexpr
Initial value:
=
Whether the given type is derived from any member of the list.
Definition: TypeList.h:480

Definition at line 138 of file Registry.h.

◆ AcceptableTraits_v

template<typename RegistryTraits >
constexpr auto Registry::AcceptableTraits_v
constexpr
Initial value:
=
TypeList::Every_v<TypeList::Fn<AcceptableBaseItem>,
TypeSwitch::TypeListCheck_v<detail::VisitedNodeTypes<RegistryTraits>> &&
TypeSwitch::TypeListCheck_v<detail::VisitedLeafTypes<RegistryTraits>>
typename AllTypes< RegistryTraits >::type AllTypes_t
Definition: Registry.h:148

Definition at line 150 of file Registry.h.

◆ AcceptableType_v

template<typename RegistryTraits , typename Item >
constexpr auto Registry::AcceptableType_v
constexpr

◆ NoOp

constexpr auto Registry::NoOp = [](auto&, auto&){}
constexpr

Supply this when one member of a visitor function triple isn't needed.

Definition at line 530 of file Registry.h.

Referenced by PrefsPanel::DefaultFactories().