Audacity 3.2.0
Classes | Typedefs | Functions | Variables
anonymous_namespace{Registry.cpp} Namespace Reference

Classes

struct  CollectedItems
 
struct  ItemOrdering
 
struct  PlaceHolder
 Used only internally. More...
 

Typedefs

using Path = std::vector< Identifier >
 

Functions

const OrderingHintChooseHint (BaseItem *delegate, const OrderingHint &hint)
 
void CollectItem (CollectedItems &collection, BaseItem *Item, const OrderingHint &hint, void *pComputedItemContext)
 
void CollectItems (CollectedItems &collection, const GroupItemBase &items, const OrderingHint &hint, void *pComputedItemContext)
 
void BadPath (const TranslatableString &format, const wxString &key, const Identifier &name)
 
void ReportGroupGroupCollision (const wxString &key, const Identifier &name)
 
void ReportItemItemCollision (const wxString &key, const Identifier &name)
 
void ReportConflictingPlacements (const wxString &key, const Identifier &name)
 
bool MajorComp (const CollectedItems::NewItem &a, const CollectedItems::NewItem &b)
 
bool MinorComp (const CollectedItems::NewItem &a, const CollectedItems::NewItem &b)
 
bool Comp (const CollectedItems::NewItem &a, const CollectedItems::NewItem &b)
 
void VisitItem (VisitorBase &visitor, CollectedItems &collection, Path &path, const BaseItem *pItem, const GroupItemBase *pToMerge, const OrderingHint &hint, bool &doFlush, void *pComputedItemContext)
 
void VisitItems (VisitorBase &visitor, CollectedItems &collection, Path &path, const GroupItemBase &group, const GroupItemBase *pToMerge, const OrderingHint &hint, bool &doFlush, void *pComputedItemContext)
 

Variables

std::unordered_set< wxString > sBadPaths
 

Typedef Documentation

◆ Path

using anonymous_namespace{Registry.cpp}::Path = typedef std::vector< Identifier >

Definition at line 172 of file Registry.cpp.

Function Documentation

◆ BadPath()

void anonymous_namespace{Registry.cpp}::BadPath ( const TranslatableString format,
const wxString &  key,
const Identifier name 
)

Definition at line 175 of file Registry.cpp.

177 {
178 // Warn, but not more than once in a session for each bad path
179 auto badPath = key + '/' + name.GET();
180 if ( sBadPaths.insert( badPath ).second ) {
181 auto msg = TranslatableString{ format }.Format( badPath );
182 // debug message
183 wxLogDebug( msg.Translation() );
184#ifdef IS_ALPHA
185 // user-visible message
187#endif
188 }
189 }
static const AudacityProject::AttachedObjects::RegisteredFactory key
wxString name
Definition: TagsEditor.cpp:166
Holds a msgid for the translation catalog; may also bind format arguments.
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
Definition: BasicUI.h:287
std::unordered_set< wxString > sBadPaths
Definition: Registry.cpp:174

References anonymous_namespace{ExportPCM.cpp}::format, key, name, sBadPaths, and BasicUI::ShowMessageBox().

Referenced by TempDirectory::IsTempDirectoryNameOK(), ReportConflictingPlacements(), ReportGroupGroupCollision(), and ReportItemItemCollision().

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

◆ ChooseHint()

const OrderingHint & anonymous_namespace{Registry.cpp}::ChooseHint ( BaseItem *  delegate,
const OrderingHint hint 
)

Definition at line 101 of file Registry.cpp.

102{
103 return !delegate || delegate->orderingHint.type == OrderingHint::Unspecified
104 ? hint
105 : delegate->orderingHint;
106}

References Registry::OrderingHint::type.

Referenced by CollectItem(), and CollectItems().

Here is the caller graph for this function:

◆ CollectItem()

void anonymous_namespace{Registry.cpp}::CollectItem ( CollectedItems collection,
BaseItem *  Item,
const OrderingHint hint,
void *  pComputedItemContext 
)

Definition at line 124 of file Registry.cpp.

126{
127 if (!pItem)
128 return;
129
130 using namespace Registry;
131 if (const auto pIndirect =
132 dynamic_cast<IndirectItemBase*>(pItem)) {
133 auto delegate = pIndirect->ptr.get();
134 if (delegate)
135 // recursion
136 CollectItem(collection, delegate,
137 ChooseHint(delegate, pIndirect->orderingHint), pComputedItemContext);
138 }
139 else
140 if (const auto pComputed =
141 dynamic_cast<ComputedItemBase*>(pItem)) {
142 auto result = pComputed->factory(pComputedItemContext);
143 if (result) {
144 // Guarantee long enough lifetime of the result
145 collection.computedItems.push_back( result );
146 // recursion
147 CollectItem(collection, result.get(),
148 ChooseHint(result.get(), pComputed->orderingHint),
149 pComputedItemContext);
150 }
151 }
152 else
153 if (auto pGroup = dynamic_cast<GroupItemBase*>(pItem)) {
154 if (pGroup->GetOrdering() == GroupItemBase::Anonymous)
155 // anonymous grouping item is transparent to path calculations
156 // collect group members now
157 // recursion
158 CollectItems(collection, *pGroup,
159 ChooseHint(pGroup, hint), pComputedItemContext);
160 else
161 // all other group items
162 // defer collection of members until collecting at next lower level
163 collection.items.push_back( {pItem, nullptr, hint} );
164 }
165 else {
166 wxASSERT( dynamic_cast<SingleItem*>(pItem) );
167 // common to all single items
168 collection.items.push_back( {pItem, nullptr, hint} );
169 }
170}
void CollectItem(CollectedItems &collection, BaseItem *Item, const OrderingHint &hint, void *pComputedItemContext)
Definition: Registry.cpp:124
void CollectItems(CollectedItems &collection, const GroupItemBase &items, const OrderingHint &hint, void *pComputedItemContext)
Definition: Registry.cpp:117
const OrderingHint & ChooseHint(BaseItem *delegate, const OrderingHint &hint)
Definition: Registry.cpp:101
Common abstract base class for items that are not groups.
Definition: Registry.h:224
std::vector< BaseItemSharedPtr > & computedItems
Definition: Registry.cpp:50

References ChooseHint(), CollectItem(), CollectItems(), anonymous_namespace{Registry.cpp}::CollectedItems::computedItems, and anonymous_namespace{Registry.cpp}::CollectedItems::items.

Referenced by CollectItem(), and CollectItems().

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

◆ CollectItems()

void anonymous_namespace{Registry.cpp}::CollectItems ( CollectedItems collection,
const GroupItemBase &  items,
const OrderingHint hint,
void *  pComputedItemContext 
)

Definition at line 117 of file Registry.cpp.

119{
120 for ( auto &item : items )
121 CollectItem(collection, item.get(),
122 ChooseHint(item.get(), hint), pComputedItemContext);
123}

References ChooseHint(), and CollectItem().

Referenced by CollectItem(), anonymous_namespace{Registry.cpp}::CollectedItems::MergeItems(), and VisitItems().

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

◆ Comp()

bool anonymous_namespace{Registry.cpp}::Comp ( const CollectedItems::NewItem a,
const CollectedItems::NewItem b 
)
inline

Definition at line 491 of file Registry.cpp.

492 {
493 if ( MajorComp( a, b ) )
494 return true;
495 if ( MajorComp( b, a ) )
496 return false;
497 return MinorComp( a, b );
498};
bool MinorComp(const CollectedItems::NewItem &a, const CollectedItems::NewItem &b)
Definition: Registry.cpp:485
bool MajorComp(const CollectedItems::NewItem &a, const CollectedItems::NewItem &b)
Definition: Registry.cpp:480

References MajorComp(), and MinorComp().

Referenced by anonymous_namespace{Registry.cpp}::CollectedItems::MergeItems().

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

◆ MajorComp()

bool anonymous_namespace{Registry.cpp}::MajorComp ( const CollectedItems::NewItem a,
const CollectedItems::NewItem b 
)
inline

Definition at line 480 of file Registry.cpp.

481 {
482 // Descending sort!
483 return a.first->name > b.first->name;
484};

Referenced by Comp(), anonymous_namespace{Registry.cpp}::CollectedItems::MergeItemsAscendingNamesPass(), and anonymous_namespace{Registry.cpp}::CollectedItems::MergeItemsDescendingNamesPass().

Here is the caller graph for this function:

◆ MinorComp()

bool anonymous_namespace{Registry.cpp}::MinorComp ( const CollectedItems::NewItem a,
const CollectedItems::NewItem b 
)
inline

Definition at line 485 of file Registry.cpp.

486 {
487 // Sort by hint type.
488 // This sorts items with unspecified hints last.
489 return a.second < b.second;
490};

Referenced by Comp().

Here is the caller graph for this function:

◆ ReportConflictingPlacements()

void anonymous_namespace{Registry.cpp}::ReportConflictingPlacements ( const wxString &  key,
const Identifier name 
)

Definition at line 205 of file Registry.cpp.

206 {
207 BadPath(
208XO("Plug-in items at %s specify conflicting placements"),
209 key, name);
210 }
XO("Cut/Copy/Paste")
void BadPath(const TranslatableString &format, const wxString &key, const Identifier &name)
Definition: Registry.cpp:175

References BadPath(), key, name, and XO().

Referenced by anonymous_namespace{Registry.cpp}::CollectedItems::MergeLikeNamedItems().

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

◆ ReportGroupGroupCollision()

void anonymous_namespace{Registry.cpp}::ReportGroupGroupCollision ( const wxString &  key,
const Identifier name 
)

Definition at line 191 of file Registry.cpp.

192 {
193 BadPath(
194XO("Plug-in group at %s was merged with a previously defined group"),
195 key, name);
196 }

References BadPath(), key, name, and XO().

Referenced by anonymous_namespace{Registry.cpp}::CollectedItems::MergeWithExistingItem().

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

◆ ReportItemItemCollision()

void anonymous_namespace{Registry.cpp}::ReportItemItemCollision ( const wxString &  key,
const Identifier name 
)

Definition at line 198 of file Registry.cpp.

199 {
200 BadPath(
201XO("Plug-in item at %s conflicts with a previously defined item and was discarded"),
202 key, name);
203 }

References BadPath(), key, name, and XO().

Referenced by anonymous_namespace{Registry.cpp}::CollectedItems::MergeWithExistingItem().

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

◆ VisitItem()

void anonymous_namespace{Registry.cpp}::VisitItem ( VisitorBase &  visitor,
CollectedItems collection,
Path path,
const BaseItem *  pItem,
const GroupItemBase *  pToMerge,
const OrderingHint hint,
bool &  doFlush,
void *  pComputedItemContext 
)

Definition at line 678 of file Registry.cpp.

683{
684 if (!pItem)
685 return;
686
687 if (const auto pSingle =
688 dynamic_cast<const SingleItem*>(pItem)) {
689 wxASSERT( !pToMerge );
690 visitor.Visit( *pSingle, path );
691 }
692 else
693 if (const auto pGroup =
694 dynamic_cast<const GroupItemBase*>(pItem)) {
695 visitor.BeginGroup(*pGroup, path);
696 // recursion
698 visitor, collection, path, *pGroup, pToMerge, hint, doFlush,
699 pComputedItemContext);
700 visitor.EndGroup(*pGroup, path);
701 }
702 else
703 wxASSERT( false );
704}
void VisitItems(VisitorBase &visitor, CollectedItems &collection, Path &path, const GroupItemBase &group, const GroupItemBase *pToMerge, const OrderingHint &hint, bool &doFlush, void *pComputedItemContext)
Definition: Registry.cpp:629

References VisitItems().

Referenced by Registry::detail::Visit(), and VisitItems().

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

◆ VisitItems()

void anonymous_namespace{Registry.cpp}::VisitItems ( VisitorBase &  visitor,
CollectedItems collection,
Path path,
const GroupItemBase &  group,
const GroupItemBase *  pToMerge,
const OrderingHint hint,
bool &  doFlush,
void *  pComputedItemContext 
)

Definition at line 629 of file Registry.cpp.

634{
635 // Make a NEW collection for this subtree, sharing the memo cache
636 CollectedItems newCollection{ {}, collection.computedItems };
637
638 // Gather items at this level
639 // (The ordering hint is irrelevant when not merging items in)
640 CollectItems(newCollection, group, {},
641 pComputedItemContext);
642
643 path.push_back(group.name.GET());
644
645 // Merge with the registry
646 if ( pToMerge )
647 {
648 ItemOrdering itemOrdering{ path };
649 newCollection.MergeItems(itemOrdering, *pToMerge, hint,
650 pComputedItemContext);
651
652 // Remember the NEW ordering, if there was any need to use the old.
653 // This makes a side effect in preferences.
654 if ( itemOrdering.gotOrdering ) {
655 wxString newValue;
656 for ( const auto &item : newCollection.items ) {
657 const auto &name = item.visitNow->name;
658 if ( !name.empty() )
659 newValue += newValue.empty()
660 ? name.GET()
661 : ',' + name.GET();
662 }
663 if (newValue != itemOrdering.strValue) {
664 gPrefs->Write( itemOrdering.key, newValue );
665 doFlush = true;
666 }
667 }
668 }
669
670 // Now visit them
671 for ( const auto &item : newCollection.items )
672 VisitItem(visitor, collection, path,
673 item.visitNow, item.mergeLater, item.hint,
674 doFlush, pComputedItemContext);
675
676 path.pop_back();
677}
audacity::BasicSettings * gPrefs
Definition: Prefs.cpp:68
virtual bool Write(const wxString &key, bool value)=0
void VisitItem(VisitorBase &visitor, CollectedItems &collection, Path &path, const BaseItem *pItem, const GroupItemBase *pToMerge, const OrderingHint &hint, bool &doFlush, void *pComputedItemContext)
Definition: Registry.cpp:678

References CollectItems(), anonymous_namespace{Registry.cpp}::CollectedItems::computedItems, gPrefs, name, VisitItem(), and audacity::BasicSettings::Write().

Referenced by VisitItem().

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

Variable Documentation

◆ sBadPaths

std::unordered_set< wxString > anonymous_namespace{Registry.cpp}::sBadPaths

Definition at line 174 of file Registry.cpp.

Referenced by BadPath().