Audacity  3.0.3
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 
16 namespace Journal {
17 
18 namespace {
19 
20 bool sError = false;
21 
23 {
24  static Dictionary theDictionary;
25  return theDictionary;
26 }
27 
28 }
29 
30 bool GetError()
31 {
32  return sError;
33 }
34 
35 void SetError()
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 
58 static 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 }
Journal::GetDictionary
const Dictionary & GetDictionary()
Definition: JournalRegistry.cpp:53
Journal
Facilities for recording and playback of sequences of user interaction.
Journal::Dictionary
std::unordered_map< wxString, Journal::Dispatcher > Dictionary
Definition: JournalRegistry.h:44
Journal::anonymous_namespace{JournalRegistry.cpp}::sDictionary
static Dictionary & sDictionary()
Definition: JournalRegistry.cpp:22
Journal::GetError
bool GetError()
Definition: JournalRegistry.cpp:30
Journal::SetError
void SetError()
Definition: JournalRegistry.cpp:35
Journal::sInitializers
static std::vector< Initializer > & sInitializers()
Definition: JournalRegistry.cpp:58
name
const TranslatableString name
Definition: Distortion.cpp:98
JournalRegistry.h
Journal system's error status, command dictionary, initializers.
Journal::anonymous_namespace{JournalRegistry.cpp}::sError
bool sError
Definition: JournalRegistry.cpp:20
Journal::Initializer
std::function< bool() > Initializer
Definition: JournalRegistry.h:51
Journal::Initializers
std::vector< Initializer > Initializers
Definition: JournalRegistry.h:59
Journal::Dispatcher
std::function< bool(const wxArrayStringEx &fields) > Dispatcher
Definition: JournalRegistry.h:33
Journal::Events::anonymous_namespace{JournalEvents.cpp}::initializer
RegisteredInitializer initializer
Definition: JournalEvents.cpp:449
Journal::GetInitializers
const Initializers & GetInitializers()
Definition: JournalRegistry.cpp:69
Journal::RegisteredCommand::RegisteredCommand
RegisteredCommand(const wxString &name, Dispatcher dispatcher)
Definition: JournalRegistry.cpp:40
Journal::RegisteredInitializer::RegisteredInitializer
RegisteredInitializer(Initializer initializer)
Definition: JournalRegistry.cpp:64