Audacity 3.2.0
Journal.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 Journal.h
6
7 Paul Licameli
8
9**********************************************************************/
10
11#ifndef __AUDACITY_JOURNAL__
12#define __AUDACITY_JOURNAL__
13
14#include "Identifier.h"
15class wxArrayString;
16class wxArrayStringEx;
17class wxString;
18
19#include "AudacityException.h"
20
21// Whether the journalling feature is shown to the end user
22#undef END_USER_JOURNALLING
23
24namespace Journal
25{
26 //\brief Whether recording is enabled; but recording will happen only if this
27 // was true at application start up
28 bool RecordEnabled();
29
30 //\brief Change the enablement of recording and store in preferences
31 //\return whether successful
32 bool SetRecordEnabled(bool value);
33
34 //\brief Whether actually replaying.
35 // IsRecording() && IsReplaying() is possible
36 bool IsReplaying();
37
38 //\brief Set the played back journal file at start up
39 void SetInputFileName( const wxString &path );
40
41 //\brief Initialize playback if a file name has been set, and initialize
42 // output if recording is enabled.
43 // Must be called after wxWidgets initializes.
44 // Application initialization is late enough.
45 // @param dataDir the output journal.txt will be in this directory, and the
46 // input file, if it was relative, is made absolute with respect to it
47 // @return true if successful
48 bool Begin( const FilePath &dataDir );
49
50 //\brief Consume next line from the input journal (skipping blank lines and
51 // comments) and tokenize it.
52 // Throws SyncException if no next line or not replaying
54
55 //\brief if playing back and commands remain, may execute one.
56 // May throw SyncException if playing back but none remain, or if other error
57 // conditions are encountered.
58 // Returns true if any command was dispatched
59 bool Dispatch();
60
61 //\brief If recording, output the strings; if playing back, require
62 // identical strings. None of them may contain newlines
63 void Sync( const wxString &string );
64 void Sync( const wxArrayString &strings );
65 void Sync( std::initializer_list< const wxString > strings );
66
68
69 using InteractiveAction = std::function< int() >;
70
72
80 int IfNotPlaying(
81 const wxString &string, const InteractiveAction &action );
82
83 //\brief Get the value that the application will return to the command line
84 int GetExitCode();
85
86 //\brief thrown when playback of a journal doesn't match the recording
88 public:
90 ~SyncException() override;
91
92 // The delayed handler action forces the program to quit gracefully,
93 // so that the test playback failure is prompty reported. This is
94 // unlike other AudacityExceptions that roll back the project and
95 // continue.
96 void DelayedHandlerAction() override;
97 };
98}
99
100#endif
Declare abstract class AudacityException, some often-used subclasses, and GuardedCall.
wxString FilePath
Definition: Project.h:20
Base class for exceptions specially processed by the application.
~SyncException() override
Definition: Journal.cpp:110
void DelayedHandlerAction() override
Action to do in the main thread at idle time of the event loop.
Definition: Journal.cpp:112
Extend wxArrayString with move operations and construction and insertion fromstd::initializer_list.
Facilities for recording and playback of sequences of user interaction.
void Sync(const wxString &string)
Definition: Journal.cpp:230
bool RecordEnabled()
Definition: Journal.cpp:119
int IfNotPlaying(const wxString &string, const InteractiveAction &action)
Call action only if not replaying; synchronize on string and int values.
Definition: Journal.cpp:256
bool SetRecordEnabled(bool value)
Definition: Journal.cpp:124
bool Dispatch()
Definition: Journal.cpp:202
wxArrayStringEx GetTokens()
Definition: Journal.cpp:192
bool Begin(const FilePath &dataDir)
Definition: Journal.cpp:141
std::function< int() > InteractiveAction
Function that returns a value which will be written to the journal.
Definition: Journal.h:69
void SetInputFileName(const wxString &path)
Definition: Journal.cpp:136
bool IsReplaying()
Definition: Journal.cpp:131
int GetExitCode()
Definition: Journal.cpp:288