mirror of
https://github.com/cookiengineer/audacity
synced 2026-02-06 03:32:09 +01:00
Dispatch read of top-level project XML tags with a table of functions...
... which makes Project.cpp a bit less dependent on some details of other classes This puts Tags.cpp back into the big strongly connected component of the dependency graph. That will be remedied later when Project.cpp becomes a low-level file
This commit is contained in:
44
src/ProjectFileIORegistry.cpp
Normal file
44
src/ProjectFileIORegistry.cpp
Normal file
@@ -0,0 +1,44 @@
|
||||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
ProjectFileIORegistry.cpp
|
||||
|
||||
Paul Licameli
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#include "ProjectFileIORegistry.h"
|
||||
|
||||
#include "audacity/Types.h"
|
||||
#include <unordered_map>
|
||||
#include <wx/string.h>
|
||||
|
||||
|
||||
namespace ProjectFileIORegistry {
|
||||
|
||||
namespace {
|
||||
using TagTable = std::unordered_map< wxString, TagHandlerFactory >;
|
||||
static TagTable &sTagTable()
|
||||
{
|
||||
static TagTable theTable;
|
||||
return theTable;
|
||||
}
|
||||
}
|
||||
|
||||
Entry::Entry(
|
||||
const wxString &tag, const TagHandlerFactory &factory )
|
||||
{
|
||||
sTagTable()[ tag ] = factory;
|
||||
}
|
||||
|
||||
TagHandlerFactory Lookup( const wxString &tag )
|
||||
{
|
||||
const auto &table = sTagTable();
|
||||
auto iter = table.find( tag );
|
||||
if ( iter == table.end() )
|
||||
return {};
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user