Audacity 3.2.0
JournalRegistry.cpp
Go to the documentation of this file.
1/*!********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file JournalRegistry.cpp
6
7 Paul Licameli
8
9**********************************************************************/
10
11#include "JournalRegistry.h"
12
13#include <wx/log.h>
14#include <wx/string.h>
15
16namespace Journal {
17
18namespace {
19
20bool sError = false;
21
23{
24 static Dictionary theDictionary;
25 return theDictionary;
26}
27
28}
29
31{
32 return sError;
33}
34
36{
37 sError = true;
38}
39
41 const wxString &name, Dispatcher dispatcher )
42{
43 if ( !sDictionary().insert( { name, dispatcher } ).second ) {
44 wxLogDebug( wxString::Format (
45 wxT("Duplicated registration of Journal command name %s"),
46 name
47 ) );
48 // Cause failure of startup of journalling and graceful exit
49 SetError();
50 }
51}
52
54{
55 return sDictionary();
56}
57
58static std::vector<Initializer> &sInitializers()
59{
60 static std::vector<Initializer> sTheFunctions;
61 return sTheFunctions;
62}
63
65{
66 sInitializers().push_back( move(initializer) );
67}
68
70{
71 return sInitializers();
72}
73
74}
wxT("CloseDown"))
const TranslatableString name
Definition: Distortion.cpp:82
Journal system's error status, command dictionary, initializers.
Facilities for recording and playback of sequences of user interaction.
std::vector< Initializer > Initializers
const Dictionary & GetDictionary()
std::function< bool(const wxArrayStringEx &fields) > Dispatcher
std::unordered_map< wxString, Journal::Dispatcher > Dictionary
bool GetError()
void SetError()
const Initializers & GetInitializers()
std::function< bool() > Initializer
static std::vector< Initializer > & sInitializers()
RegisteredCommand(const wxString &name, Dispatcher dispatcher)
RegisteredInitializer(Initializer initializer)