Audacity 3.2.0
Registry.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5Registry.h
6
7Paul Licameli split from CommandManager.h
8
9**********************************************************************/
10
11#ifndef __AUDACITY_REGISTRY__
12#define __AUDACITY_REGISTRY__
13
14#include "Prefs.h"
15#include "Composite.h"
16#include "TypeSwitch.h"
17#include "Variant.h"
18#include <functional>
19#include <type_traits>
20#include <utility>
21
22// Define classes and functions that associate parts of the user interface
23// with path names
24namespace Registry {
25 struct REGISTRIES_API EmptyContext{
27 };
29 template<typename... T> using List = TypeList::List<T...>;
33 };
34
35 // Items in the registry form an unordered tree, but each may also describe a
36 // desired insertion point among its peers. The request might not be honored
37 // (as when the other name is not found, or when more than one item requests
38 // the same ordering), but this is not treated as an error.
40 {
46 enum Type : int {
49 Unspecified // keep this last
51
52 // name of some other BaseItem; significant only when type is Before or
53 // After:
55
56 OrderingHint(Type type = Unspecified, const wxString &name = {})
57 : type{ type }, name{ name } {}
58
59 bool operator == ( const OrderingHint &other ) const
60 { return name == other.name && type == other.type; }
61
62 bool operator < ( const OrderingHint &other ) const
63 {
64 // This sorts unspecified placements later
65 return std::make_pair( type, name ) <
66 std::make_pair( other.type, other.name );
67 }
68 };
69
70 template<typename RegistryTraits> struct GroupItem;
71 using Path = std::vector<Identifier>;
72 struct Placement;
73 struct SingleItem;
74
75namespace detail { using namespace TypeList;
76 struct GroupItemBase;
77
78 struct REGISTRIES_API BaseItem {
79 // declare at least one virtual function so dynamic_cast will work
80 explicit
81 BaseItem( const Identifier &internalName )
82 : name{ internalName }
83 {}
84 virtual ~BaseItem();
85
87
89 };
90
91 using BaseItemPtr = std::unique_ptr<BaseItem>;
92
93 using BaseItemSharedPtr = std::shared_ptr<BaseItem>;
94
95 struct REGISTRIES_API IndirectItemBase : BaseItem {
97 : BaseItem{ wxEmptyString }
98 , ptr{ ptr }
99 {}
100 ~IndirectItemBase() override;
101
103 };
104
105 struct ComputedItemBase;
106
107 template<typename Type, typename List> struct ConsUnique {
108 template<typename L> struct NotAlready {
109 static constexpr bool value = !std::is_same_v<Type, Head_t<L>>;
110 };
111 using type = std::conditional_t<
112 std::disjunction<Null<List>, NotAlready<List>>::value,
114 >;
115 };
116 template<typename Type, typename List> using ConsUnique_t
118
119 template<typename RegistryTraits> using VisitedNodeTypes =
121 typename RegistryTraits::NodeTypes>>;
122 template<typename RegistryTraits> using VisitedLeafTypes =
124 typename RegistryTraits::LeafTypes>>;
125 template<typename Types> using VisitorFunction =
126 std::function<void(Head_t<Types> &, const Path &)>;
127}
128
133 // see below
134 struct SingleItem, struct detail::GroupItemBase
135 >;
136 template<typename Item> using AcceptableBaseItem =
137 TypeList::HasBaseIn<Item, BaseItemTypes>;
138 template<typename Item> constexpr auto AcceptableBaseItem_v =
139 AcceptableBaseItem<Item>::value;
140
141 template<typename RegistryTraits> struct AllTypes {
143 typename RegistryTraits::LeafTypes,
144 typename RegistryTraits::NodeTypes
145 >;
146 };
147 template<typename RegistryTraits> using AllTypes_t =
149
150 template<typename RegistryTraits> constexpr auto AcceptableTraits_v =
151 TypeList::Every_v<TypeList::Fn<AcceptableBaseItem>,
153 TypeSwitch::TypeListCheck_v<detail::VisitedNodeTypes<RegistryTraits>> &&
154 TypeSwitch::TypeListCheck_v<detail::VisitedLeafTypes<RegistryTraits>>;
155
156namespace detail {
158
163 template<typename Item>
165 using ItemType = Item;
166 static_assert(AcceptableBaseItem_v<ItemType>);
167 explicit IndirectItem(const std::shared_ptr<Item> &ptr)
169 {}
170 };
171}
172
174 template<typename Item>
175 inline std::unique_ptr<detail::IndirectItem<Item>> Indirect(
176 const std::shared_ptr<Item> &ptr)
177 {
178 return std::make_unique<detail::IndirectItem<Item>>( ptr );
179 }
180
181namespace detail {
182 struct REGISTRIES_API ComputedItemBase : BaseItem {
183 using TypeErasedFactory = std::function<BaseItemSharedPtr(void*)>;
184
186 : BaseItem(wxEmptyString)
187 , factory{ move(factory) }
188 {}
189 ~ComputedItemBase() override;
190
192 };
193
196
200 template<typename Context, typename Item>
202 using ItemType = Item;
203 static_assert(AcceptableBaseItem_v<ItemType>);
204
206
212 template<typename Factory> ComputedItem(const Factory &factory)
214 // p comes from the compute item context argument of
215 // Registry::Visit, passed by reference
216 assert(p);
217 return factory(*static_cast<Context *>(p));
218 } }
219 {}
220 };
221}
222
224 struct REGISTRIES_API SingleItem : detail::BaseItem {
225 using BaseItem::BaseItem;
226 ~SingleItem() override = 0;
227 };
228
229namespace detail {
231 REGISTRIES_API void RegisterItem(GroupItemBase &registry,
232 const Placement &placement, BaseItemPtr pItem);
233
235 struct REGISTRIES_API GroupItemBase : Composite::Base<
236 BaseItem, std::unique_ptr<BaseItem>, const Identifier &
237 > {
238 using Base::Base;
239
240 GroupItemBase(const GroupItemBase&) = delete;
242 ~GroupItemBase() override = 0;
243
245 enum Ordering {
256 };
257
259 virtual Ordering GetOrdering() const;
260
261 private:
262 friend REGISTRIES_API void RegisterItem(GroupItemBase &registry,
263 const Placement &placement, BaseItemPtr pItem);
264 };
265}
266
267 // Forward declarations necessary before customizing Composite::Traits
268 template<typename RegistryTraits> struct GroupItem;
269 namespace detail {
270 template<typename RegistryTraits> struct Builder;
271 }
272}
273
274template<typename RegistryTraits> struct Composite::Traits<
275 Registry::detail::GroupItemBase, Registry::GroupItem<RegistryTraits>
276> {
277 static constexpr auto ItemBuilder =
280 template<typename T> static constexpr auto enables_item_type_v =
281 !std::is_same_v<T, Registry::detail::BaseItemPtr>;
282};
283
284namespace Registry {
286
289 template<typename RegistryTraits>
291 detail::GroupItemBase, GroupItem<RegistryTraits>, const Identifier &
292 > {
293 ~GroupItem() override = default;
294 using Composite::Builder<
296 >::Builder;
297 };
298
299 // The /-separated path is relative to the GroupItem supplied to
300 // RegisterItem.
301 // For instance, wxT("Transport/Cursor") to locate an item under a sub-menu
302 // of a main menu
303 struct Placement {
304 wxString path;
306
307 Placement(const wxString &path = {}, const OrderingHint &hint = {})
308 : path{ path }, hint{ hint }
309 {}
310 Placement(const wxChar *path, const OrderingHint &hint = {})
311 : path{ path }, hint{ hint }
312 {}
313 };
314
316 template<typename T> struct ActualItem{ using type = T; };
317 template<typename T> using ActualItem_t = typename ActualItem<T>::type;
318 template<typename T> struct ActualItem<detail::IndirectItem<T>>
319 { using type = ActualItem_t<T>; };
320 template<typename C, typename T>
321 struct ActualItem<detail::ComputedItem<C, T>>
322 { using type = ActualItem_t<T>; };
323
324 template<typename Item, typename TypeList> struct AcceptableItemType {
325 static constexpr auto value =
326 ::TypeList::HasBaseIn_v<ActualItem_t<Item>, TypeList>;
327 };
328
329 template<typename RegistryTraits, typename Item> using AcceptableType =
331 template<typename RegistryTraits, typename Item>
332 constexpr auto AcceptableType_v =
334
335namespace detail {
336 template<typename RegistryTraits>
337 struct Builder {
338 using Context = typename RegistryTraits::ComputedItemContextType;
339
340 template<typename ItemType>
341 auto operator () (std::unique_ptr<ItemType> ptr) const {
342 static_assert(AcceptableType_v<RegistryTraits, ItemType>);
343 return move(ptr);
344 }
347 template<typename Factory,
348 typename ItemType =
349 typename std::invoke_result_t<Factory, Context&>::element_type
350 >
351 auto operator () (const Factory &factory) const {
352 static_assert(AcceptableType_v<RegistryTraits, ItemType>);
353 return std::make_unique<ComputedItem<Context, ItemType>>(factory);
354 }
356 template<typename ItemType>
357 auto operator () (const std::shared_ptr<ItemType> &ptr) const {
358 static_assert(AcceptableType_v<RegistryTraits, ItemType>);
359 return std::make_unique<IndirectItem<ItemType>>(ptr);
360 }
361 };
362}
363
364 // registry collects items, before consulting preferences and ordering
365 // hints, and applying the merge procedure to them.
366 // This function puts one more item into the registry.
367 // The sequence of calls to RegisterItem has no significance for
368 // determining the visitation ordering. When sequence is important, register
369 // a GroupItem.
370 template<typename RegistryTraits, typename Item>
372 const Placement &placement, std::unique_ptr<Item> pItem)
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 }
380
382
387 template<typename RegistryClass>
389 public:
390 template<typename Ptr>
391 RegisteredItem(Ptr pItem, const Placement &placement = {})
392 {
393 if (pItem)
394 RegisterItem(RegistryClass::Registry(), placement, move(pItem));
395 }
396 };
397
398namespace detail {
399 // Helpers allowing a single callable instead of a tuple
400 template<typename V> auto ForwardTuple_(const V &visitor, std::false_type) {
401 // Visitor is not a tuple
402 return std::tuple<const V&>{ visitor };
403 }
404 template<typename V> auto ForwardTuple_(const V &visitor, std::true_type) {
405 // Visitor is a tuple
406 return Tuple::ForwardAll(visitor);
407 }
408 template<typename V> auto ForwardTuple(const V &visitor) {
409 return ForwardTuple_(visitor,
410 std::bool_constant<Tuple::is_tuple_like_v<V>>{});
411 }
412
413 template<typename V> auto MakeTuple_(const V &visitor, std::false_type) {
414 // Visitor is not a tuple
415 return std::tuple<V>{ visitor };
416 }
417 template<typename V> auto MakeTuple_(const V &visitor, std::true_type) {
418 // Visitor is a tuple
419 return Tuple::All(visitor);
420 }
421 template<typename V> auto MakeTuple(const V &visitor) {
422 return MakeTuple_(visitor,
423 std::bool_constant<Tuple::is_tuple_like_v<V>>{});
424 }
425
426 template<typename V> auto CaptureTuple_(const V &visitor, std::true_type) {
427 // Capture by reference
428 return ForwardTuple(visitor);
429 }
430 template<typename V> auto CaptureTuple_(const V &visitor, std::false_type) {
431 // Capture by value
432 return MakeTuple(visitor);
433 }
434 template<bool Reference, typename V> auto CaptureTuple(const V &visitor) {
435 return CaptureTuple_(visitor, std::bool_constant<Reference>{});
436 }
437
439 template<typename Types, bool Reference, typename Visitor>
441 return [visitor = CaptureTuple<Reference>(visitor)](
442 Head_t<Types> &object, const Path &path
443 ){
444 // The compile time checking of reachability of cases still applies
445 // before the visitor is wrapped
446 TypeSwitch::Dispatch<void, Types>(object, visitor, path);
447 };
448 }
449
451 template<typename Visitors> static constexpr auto TupleSize =
452 std::conditional_t<
453 Tuple::is_tuple_like_v<Visitors>,
454 std::tuple_size<Visitors>,
455 std::integral_constant<size_t, 1>
456 >::value;
457
458 template<typename RegistryTraits> using NodeVisitorFunction =
460 template<typename RegistryTraits> using LeafVisitorFunction =
462 template<typename RegistryTraits> using VisitorFunctionTriple = std::tuple<
466 >;
467}
468
472
475 template<typename RegistryTraits, bool Reference = false>
476 struct VisitorFunctions : std::variant<
477 detail::LeafVisitorFunction<RegistryTraits>,
478 detail::VisitorFunctionTriple<RegistryTraits>
479 >{
482
484
489 template<typename Visitors> VisitorFunctions(Visitors &&visitors) {
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 }
505 void BeginGroup(const GroupItem<RegistryTraits> &item, const Path &path)
506 const {
507 if (const auto *pTriple = std::get_if<1>(this))
508 (std::get<0>(*pTriple))(item, path);
509 }
511 void Visit(const SingleItem &item, const Path &path) const {
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 }
522 void EndGroup(const GroupItem<RegistryTraits> &item, const Path &path)
523 const {
524 if (const auto *pTriple = std::get_if<1>(this))
525 (std::get<2>(*pTriple))(item, path);
526 }
527 };
528
530 constexpr auto NoOp = [](auto&, auto&){};
531
532namespace detail {
533 class REGISTRIES_API VisitorBase
534 {
535 public:
536 virtual ~VisitorBase();
537 virtual void BeginGroup(const GroupItemBase &item, const Path &path)
538 const = 0;
539 virtual void Visit(const SingleItem &item, const Path &path)
540 const = 0;
541 virtual void EndGroup(const GroupItemBase &item, const Path &path)
542 const = 0;
543 };
544
545 REGISTRIES_API void Visit(
546 VisitorBase &visitor,
547 const GroupItemBase *pTopItem,
548 const GroupItemBase *pRegistry,
549 void *pComputedItemContext);
550
552
555 template<typename RegistryTraits, typename Visitors>
560 static constexpr auto size = TupleSize<Visitors>;
561 static_assert(size == 1 || size == 3);
562 Visitor(const Visitors &visitors) : visitors{ visitors } {}
563
564 void BeginGroup(const GroupItemBase &item, const Path &path)
565 const override {
566 if constexpr (size == 3)
567 TypeSwitch::Dispatch<void, NodeTypes>(item,
568 ForwardTuple(std::get<0>(visitors)), path);
569 }
570 void Visit(const SingleItem &item, const Path &path) const override {
571 TypeSwitch::Dispatch<void, LeafTypes>(item,
572 ForwardTuple(std::get<size == 1 ? 0 : 1>(ForwardTuple(visitors))),
573 path);
574 }
575 void EndGroup(const GroupItemBase &item, const Path &path)
576 const override {
577 if constexpr (size == 3)
578 TypeSwitch::Dispatch<void, NodeTypes>(item,
579 ForwardTuple(std::get<2>(visitors)), path);
580 }
581 const Visitors &visitors;
582 };
583}
584
587
608 template<typename RegistryTraits, typename Visitors>
609 void Visit(const Visitors &visitors,
610 const GroupItem<RegistryTraits> *pTopItem,
611 const GroupItem<RegistryTraits> *pRegistry = {},
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 }
619
622 template<typename RegistryTraits>
624 const GroupItem<RegistryTraits> *pTopItem,
625 const GroupItem<RegistryTraits> *pRegistry = {},
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 }
634
635 // Typically a static object. Constructor initializes certain preferences
636 // if they are not present. These preferences determine an extrinsic
637 // visitation ordering for registered items. This is needed in some
638 // places that have migrated from a system of exhaustive listings, to a
639 // registry of plug-ins, and something must be done to preserve old
640 // behavior. It can be done in the central place using string literal
641 // identifiers only, not requiring static compilation or linkage dependency.
642 struct REGISTRIES_API
644 using Literal = const wxChar *;
645 using Pair = std::pair< Literal, Literal >;
646 using Pairs = std::vector< Pair >;
648 // Specifies the topmost preference section:
649 Literal root,
650 // Specifies /-separated Registry paths relative to root
651 // (these should be blank or start with / and not end with /),
652 // each with a ,-separated sequence of identifiers, which specify a
653 // desired ordering at one node of the tree:
654 Pairs pairs );
655
656 void operator () () override;
657
658 private:
661 };
662
663#ifndef _WIN32
664// extern explicit instantiation to avoid link time de-duplication
665extern
666#endif
667 template struct
668#ifdef _WIN32
669// Can't do that on Windows, but need this to link:
670 __declspec(dllexport)
671#endif
673}
674
675#endif
static RegisteredToolbarFactory factory
wxString name
Definition: TagsEditor.cpp:166
Dispatch to one of a set of functions by the run-time type of an object.
emulates std::visit for one visitor
static const auto fn
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
Generates classes whose instances register items at construction.
Definition: Registry.h:388
RegisteredItem(Ptr pItem, const Placement &placement={})
Definition: Registry.h:391
virtual void EndGroup(const GroupItemBase &item, const Path &path) const =0
virtual void BeginGroup(const GroupItemBase &item, const Path &path) const =0
virtual void Visit(const SingleItem &item, const Path &path) const =0
VisitorFunction< Types > MakeVisitorFunction(const Visitor &visitor)
Capture a callable for Visit() in a std::function wrapper.
Definition: Registry.h:440
std::tuple< NodeVisitorFunction< RegistryTraits >, LeafVisitorFunction< RegistryTraits >, NodeVisitorFunction< RegistryTraits > > VisitorFunctionTriple
Definition: Registry.h:466
auto CaptureTuple_(const V &visitor, std::true_type)
Definition: Registry.h:426
std::shared_ptr< BaseItem > BaseItemSharedPtr
Definition: Registry.h:93
auto MakeTuple_(const V &visitor, std::false_type)
Definition: Registry.h:413
auto ForwardTuple_(const V &visitor, std::false_type)
Definition: Registry.h:400
auto CaptureTuple(const V &visitor)
Definition: Registry.h:434
REGISTRIES_API void Visit(VisitorBase &visitor, const GroupItemBase *pTopItem, const GroupItemBase *pRegistry, void *pComputedItemContext)
Definition: Registry.cpp:725
REGISTRIES_API void RegisterItem(GroupItemBase &registry, const Placement &placement, BaseItemPtr pItem)
Type-erased implementation details, don't call directly.
Definition: Registry.cpp:765
std::unique_ptr< BaseItem > BaseItemPtr
Definition: Registry.h:91
VisitorFunction< VisitedLeafTypes< RegistryTraits > > LeafVisitorFunction
Definition: Registry.h:461
auto MakeTuple(const V &visitor)
Definition: Registry.h:421
std::function< void(Head_t< Types > &, const Path &)> VisitorFunction
Definition: Registry.h:126
static constexpr auto TupleSize
How large a tuple to make from Visitors.
Definition: Registry.h:451
auto ForwardTuple(const V &visitor)
Definition: Registry.h:408
typename ConsUnique< Type, List >::type ConsUnique_t
Definition: Registry.h:117
VisitorFunction< VisitedNodeTypes< RegistryTraits > > NodeVisitorFunction
Definition: Registry.h:459
ConsUnique_t< const GroupItem< RegistryTraits >, Map_t< Fn< std::add_const_t >, typename RegistryTraits::NodeTypes > > VisitedNodeTypes
Definition: Registry.h:121
ConsUnique_t< const SingleItem, Map_t< Fn< std::add_const_t >, typename RegistryTraits::LeafTypes > > VisitedLeafTypes
Definition: Registry.h:124
constexpr auto NoOp
Supply this when one member of a visitor function triple isn't needed.
Definition: Registry.h:530
std::vector< Identifier > Path
Definition: Registry.h:71
void Visit(const Visitors &visitors, const GroupItem< RegistryTraits > *pTopItem, const GroupItem< RegistryTraits > *pRegistry={}, typename RegistryTraits::ComputedItemContextType &computedItemContext=RegistryTraits::ComputedItemContextType::Instance)
Definition: Registry.h:609
std::unique_ptr< detail::IndirectItem< Item > > Indirect(const std::shared_ptr< Item > &ptr)
A convenience function.
Definition: Registry.h:175
typename ActualItem< T >::type ActualItem_t
Definition: Registry.h:317
void RegisterItem(GroupItem< RegistryTraits > &registry, const Placement &placement, std::unique_ptr< Item > pItem)
Definition: Registry.h:371
typename AllTypes< RegistryTraits >::type AllTypes_t
Definition: Registry.h:148
constexpr auto AcceptableBaseItem_v
Definition: Registry.h:138
void VisitWithFunctions(const VisitorFunctions< RegistryTraits > &visitors, const GroupItem< RegistryTraits > *pTopItem, const GroupItem< RegistryTraits > *pRegistry={}, typename RegistryTraits::ComputedItemContextType &computedItemContext=RegistryTraits::ComputedItemContextType::Instance)
Definition: Registry.h:623
constexpr auto AcceptableType_v
Definition: Registry.h:332
constexpr auto AcceptableTraits_v
Definition: Registry.h:150
auto All(Tuple &&tuple)
Projection of all of a tuple.
Definition: Tuple.h:120
auto ForwardAll(Tuple &&tuple)
Forwarding of all of a tuple.
Definition: Tuple.h:130
Utilities for compile-time type manipulation. Some terminology as in Lisp.
Definition: TypeList.h:22
List<> Nil
Definition: TypeList.h:75
typename Map< Metafunction, TypeList >::type Map_t
Definition: TypeList.h:262
typename Cons< Type, TypeList >::type Cons_t
Definition: TypeList.h:142
typename Head< TypeList >::type Head_t
Definition: TypeList.h:95
typename Append< Lists... >::type Append_t
Definition: TypeList.h:273
decltype(auto) Visit(Visitor &&vis, Variant &&var)
Mimic some of std::visit, for the case of one visitor only.
Definition: Variant.h:138
STL namespace.
static constexpr auto ItemBuilder
Definition: Composite.h:80
static constexpr auto enables_item_type_v
Definition: Composite.h:81
static constexpr auto value
Definition: Registry.h:325
Find the real item type (following chains of indirections)
Definition: Registry.h:316
TypeList::Append_t< typename RegistryTraits::LeafTypes, typename RegistryTraits::NodeTypes > type
Definition: Registry.h:145
static EmptyContext Instance
Definition: Registry.h:26
Has variadic and range constructors that check types.
Definition: Registry.h:292
~GroupItem() override=default
enum Registry::OrderingHint::Type type
OrderingHint(Type type=Unspecified, const wxString &name={})
Definition: Registry.h:56
bool operator==(const OrderingHint &other) const
Definition: Registry.h:59
bool operator<(const OrderingHint &other) const
Definition: Registry.h:62
std::pair< Literal, Literal > Pair
Definition: Registry.h:645
OrderingHint hint
Definition: Registry.h:305
Placement(const wxChar *path, const OrderingHint &hint={})
Definition: Registry.h:310
Placement(const wxString &path={}, const OrderingHint &hint={})
Definition: Registry.h:307
Common abstract base class for items that are not groups.
Definition: Registry.h:224
VisitorFunctions(Visitors &&visitors)
Type-erasing constructor.
Definition: Registry.h:489
detail::VisitedLeafTypes< RegistryTraits > LeafTypes
Definition: Registry.h:481
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
detail::VisitedNodeTypes< RegistryTraits > NodeTypes
Definition: Registry.h:480
const Identifier name
Definition: Registry.h:86
OrderingHint orderingHint
Definition: Registry.h:88
BaseItem(const Identifier &internalName)
Definition: Registry.h:81
auto operator()(std::unique_ptr< ItemType > ptr) const
Definition: Registry.h:341
typename RegistryTraits::ComputedItemContextType Context
Definition: Registry.h:338
std::function< BaseItemSharedPtr(void *)> TypeErasedFactory
Definition: Registry.h:183
ComputedItemBase(const TypeErasedFactory &factory)
Definition: Registry.h:185
ComputedItem(const Factory &factory)
Type-erasing constructor template.
Definition: Registry.h:212
std::conditional_t< std::disjunction< Null< List >, NotAlready< List > >::value, Cons_t< Type, List >, List > type
Definition: Registry.h:114
Common abstract base class for items that group other items.
Definition: Registry.h:237
friend REGISTRIES_API void RegisterItem(GroupItemBase &registry, const Placement &placement, BaseItemPtr pItem)
Type-erased implementation details, don't call directly.
Ordering
Choose treatment of the children of the group when merging trees.
Definition: Registry.h:245
GroupItemBase(const GroupItemBase &)=delete
GroupItemBase & operator=(const GroupItemBase &)=delete
IndirectItemBase(const BaseItemSharedPtr &ptr)
Definition: Registry.h:96
An item that delegates to another held in a shared pointer.
Definition: Registry.h:164
IndirectItem(const std::shared_ptr< Item > &ptr)
Definition: Registry.h:167
Type-erasing adapter class (with no std::function overhead)
Definition: Registry.h:556
VisitedLeafTypes< RegistryTraits > LeafTypes
Definition: Registry.h:559
static constexpr auto size
Definition: Registry.h:560
ConsUnique_t< const GroupItemBase, VisitedNodeTypes< RegistryTraits > > NodeTypes
Definition: Registry.h:558
void BeginGroup(const GroupItemBase &item, const Path &path) const override
Definition: Registry.h:564
Visitor(const Visitors &visitors)
Definition: Registry.h:562
void Visit(const SingleItem &item, const Path &path) const override
Definition: Registry.h:570
const Visitors & visitors
Definition: Registry.h:581
void EndGroup(const GroupItemBase &item, const Path &path) const override
Definition: Registry.h:575
Whether the given type is derived from any member of the list.
Definition: TypeList.h:480
Empty specialization.
Definition: TypeList.h:63
Primary template for a list of arbitrary types.
Definition: TypeList.h:61