Audacity 3.2.0
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>
17class wxArrayStringEx;
18class wxString;
19
20namespace Journal
21{
22 //\brief Whether the initialization or playback of journalling failed
23 WX_INIT_API
24 bool GetError();
25
26 //\brief Make GetError() return false
27 // If replaying, then the program will return non-zero status to the command
28 // line
29 WX_INIT_API
30 void SetError();
31
32 //\brief Type of a function that interprets a line of the input journal.
33 // It may indicate failure either by throwing SyncException or returning
34 // false (which will cause Journal::Dispatch to throw a SyncException)
35 using Dispatcher = std::function< bool(const wxArrayStringEx &fields) >;
36
37 //\brief Associates a dispatcher with a keyword in the default dictionary.
38 // The keyword will also be the first field passed to the dispatcher. This
39 // struct is meant for static construction
40 struct WX_INIT_API RegisteredCommand{
41 explicit RegisteredCommand(
42 const wxString &name, Dispatcher dispatcher );
43 };
44
45 //\brief type of the dictionary of registered commands
46 using Dictionary = std::unordered_map< wxString, Journal::Dispatcher >;
47
48 //\brief read-only access to the dictionary
50
51 //\brief Function performing additional initialization steps for journals
52 // Return value is success
53 using Initializer = std::function< bool() >;
54
55 //\brief Registers an initialization step in its constructor.
56 // Typically statically constructed
57 struct WX_INIT_API RegisteredInitializer{
59 };
60
61 using Initializers = std::vector< Initializer >;
62
63 //\brief Get all registered initializers
64 WX_INIT_API
66
67}
68
69#endif
const TranslatableString name
Definition: Distortion.cpp:76
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Facilities for recording and playback of sequences of user interaction.
std::vector< Initializer > Initializers
const Dictionary & GetDictionary()
bool GetError()
const Initializers & GetInitializers()
std::function< bool(const wxArrayStringEx &fields) > Dispatcher
std::unordered_map< wxString, Journal::Dispatcher > Dictionary
std::function< bool() > Initializer
void SetError()