Audacity  3.0.3
JournalRegistry.h
Go to the documentation of this file.
1 /*!********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  @file JournalRegistry.h
6  @brief Journal system's error status, command dictionary, initializers
7 
8  Paul Licameli
9 
10 **********************************************************************/
11 
12 #ifndef __AUDACITY_JOURNAL_REGISTRY__
13 #define __AUDACITY_JOURNAL_REGISTRY__
14 
15 #include <functional>
16 #include <unordered_map>
17 class wxArrayStringEx;
18 class wxString;
19 
20 namespace Journal
21 {
22  //\brief Whether the initialization or playback of journalling failed
23  bool GetError();
24 
25  //\brief Make GetError() return false
26  // If replaying, then the program will return non-zero status to the command
27  // line
28  void SetError();
29 
30  //\brief Type of a function that interprets a line of the input journal.
31  // It may indicate failure either by throwing SyncException or returning
32  // false (which will cause Journal::Dispatch to throw a SyncException)
33  using Dispatcher = std::function< bool(const wxArrayStringEx &fields) >;
34 
35  //\brief Associates a dispatcher with a keyword in the default dictionary.
36  // The keyword will also be the first field passed to the dispatcher. This
37  // struct is meant for static construction
39  explicit RegisteredCommand(
40  const wxString &name, Dispatcher dispatcher );
41  };
42 
43  //\brief type of the dictionary of registered commands
44  using Dictionary = std::unordered_map< wxString, Journal::Dispatcher >;
45 
46  //\brief read-only access to the dictionary
47  const Dictionary &GetDictionary();
48 
49  //\brief Function performing additional initialization steps for journals
50  // Return value is success
51  using Initializer = std::function< bool() >;
52 
53  //\brief Registers an initialization step in its constructor.
54  // Typically statically constructed
57  };
58 
59  using Initializers = std::vector< Initializer >;
60 
61  //\brief Get all registered initializers
63 
64 }
65 
66 #endif
Journal::GetDictionary
const Dictionary & GetDictionary()
Definition: JournalRegistry.cpp:53
Journal
Facilities for recording and playback of sequences of user interaction.
Journal::RegisteredCommand
Definition: JournalRegistry.h:38
Journal::Dictionary
std::unordered_map< wxString, Journal::Dispatcher > Dictionary
Definition: JournalRegistry.h:44
wxArrayStringEx
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Definition: wxArrayStringEx.h:18
Journal::GetError
bool GetError()
Definition: JournalRegistry.cpp:30
Journal::SetError
void SetError()
Definition: JournalRegistry.cpp:35
name
const TranslatableString name
Definition: Distortion.cpp:98
Journal::Initializer
std::function< bool() > Initializer
Definition: JournalRegistry.h:51
Journal::Initializers
std::vector< Initializer > Initializers
Definition: JournalRegistry.h:59
Journal::RegisteredInitializer
Definition: JournalRegistry.h:55
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