mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-23 17:30:17 +01:00
Define the registry merging procedure...
... before we populate the registry. This could apply to menu items, or more generally to other registries. A registry is a tree of items identified by path names. Various code, that need not coordinate, can specify items to attach to the tree, and the merging procedure collects them into a single tree that can be visited. Pathnames imply only an unordered tree. Some visitation ordering must be imposed on the nodes, and can be remembered in preferences for stability between runs, independently of accidents of the unspecified sequence of initialization of file-scope static objects in the various plug-ins. It can be arbitrary -- not constrained to some fixed intrinsic criterion like alphabetical order. Merging consults the preferences, and also updates them if previously unknown items are found and inserted. For now, such unknowns just go to the end of the sequence of siblings, sorted by their path component names.
This commit is contained in:
@@ -482,7 +482,7 @@ namespace Registry {
|
||||
|
||||
// Construction from an internal name and a previously built-up
|
||||
// vector of pointers
|
||||
GroupItem( const wxString &internalName, BaseItemPtrs &&items_ )
|
||||
GroupItem( const Identifier &internalName, BaseItemPtrs &&items_ )
|
||||
: BaseItem{ internalName }, items{ std::move( items_ ) }
|
||||
{}
|
||||
~GroupItem() override = 0;
|
||||
@@ -500,7 +500,7 @@ namespace Registry {
|
||||
using GroupItem::GroupItem;
|
||||
// In-line, variadic constructor that doesn't require building a vector
|
||||
template< typename... Args >
|
||||
InlineGroupItem( const wxString &internalName, Args&&... args )
|
||||
InlineGroupItem( const Identifier &internalName, Args&&... args )
|
||||
: GroupItem( internalName )
|
||||
{ Append( std::forward< Args >( args )... ); }
|
||||
|
||||
@@ -576,8 +576,19 @@ namespace Registry {
|
||||
virtual void Visit( SingleItem &item, const Path &path );
|
||||
};
|
||||
|
||||
// Top-down visitation of all items and groups in a tree
|
||||
void Visit( Visitor &visitor, BaseItem *pTopItem );
|
||||
// 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 somehere, and that
|
||||
// ordering should be kept the same thereafter in later runs (which may add
|
||||
// yet other previously unknown items).
|
||||
void Visit(
|
||||
Visitor &visitor,
|
||||
BaseItem *pTopItem,
|
||||
GroupItem *pRegistry = nullptr );
|
||||
}
|
||||
|
||||
struct MenuVisitor : Registry::Visitor
|
||||
|
||||
Reference in New Issue
Block a user