Audacity  3.0.3
ProjectFileIORegistry.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  ProjectFileIORegistry.cpp
6 
7  Paul Licameli
8 
9 **********************************************************************/
10 
11 #include "ProjectFileIORegistry.h"
12 
13 #include "Identifier.h"
14 #include <unordered_map>
15 #include <wx/string.h>
16 
17 
19 
20 namespace {
21  using TagTable = std::unordered_map< wxString, TagHandlerFactory >;
22  static TagTable &sTagTable()
23  {
24  static TagTable theTable;
25  return theTable;
26  }
27 }
28 
30  const wxString &tag, const TagHandlerFactory &factory )
31 {
32  sTagTable()[ tag ] = factory;
33 }
34 
35 TagHandlerFactory Lookup( const wxString &tag )
36 {
37  const auto &table = sTagTable();
38  auto iter = table.find( tag );
39  if ( iter == table.end() )
40  return {};
41  return iter->second;
42 }
43 
44 }
ProjectFileIORegistry
Definition: ProjectFileIORegistry.cpp:18
ProjectFileIORegistry::TagHandlerFactory
std::function< XMLTagHandler *(AudacityProject &) > TagHandlerFactory
Definition: ProjectFileIORegistry.h:24
ProjectFileIORegistry::Lookup
TagHandlerFactory Lookup(const wxString &tag)
Definition: ProjectFileIORegistry.cpp:35
factory
static RegisteredToolbarFactory factory
Definition: ControlToolBar.cpp:806
Identifier.h
ProjectFileIORegistry.h
ProjectFileIORegistry::Entry::Entry
Entry(const wxString &tag, const TagHandlerFactory &factory)
Definition: ProjectFileIORegistry.cpp:29
ProjectFileIORegistry::anonymous_namespace{ProjectFileIORegistry.cpp}::sTagTable
static TagTable & sTagTable()
Definition: ProjectFileIORegistry.cpp:22
ProjectFileIORegistry::anonymous_namespace{ProjectFileIORegistry.cpp}::TagTable
std::unordered_map< wxString, TagHandlerFactory > TagTable
Definition: ProjectFileIORegistry.cpp:21