Audacity  3.0.3
Public Member Functions | Public Attributes | List of all members
CommandContext Class Reference

CommandContext provides additional information to an 'Apply()' command. It provides the project, and provides output channels for Error, Progress and Status. Status is used for general messaging from a command back to its invoker. More...

#include <CommandContext.h>

Collaboration diagram for CommandContext:
[legend]

Public Member Functions

 CommandContext (AudacityProject &p, const wxEvent *e=nullptr, int ii=0, const CommandParameter &param=CommandParameter{})
 
 CommandContext (AudacityProject &p, std::unique_ptr< CommandOutputTargets > target)
 
 ~CommandContext ()
 
virtual void Status (const wxString &message, bool bFlush=false) const
 
virtual void Error (const wxString &message) const
 
virtual void Progress (double d) const
 
void StartArray () const
 
void EndArray () const
 
void StartStruct () const
 
void EndStruct () const
 
void StartField (const wxString &name) const
 
void EndField () const
 
void AddItem (const wxString &value, const wxString &name={}) const
 
void AddBool (const bool value, const wxString &name={}) const
 
void AddItem (const double value, const wxString &name={}) const
 

Public Attributes

AudacityProjectproject
 
std::unique_ptr< CommandOutputTargetspOutput
 
const wxEvent * pEvt
 
int index
 
CommandParameter parameter
 
TemporarySelection temporarySelection
 

Detailed Description

CommandContext provides additional information to an 'Apply()' command. It provides the project, and provides output channels for Error, Progress and Status. Status is used for general messaging from a command back to its invoker.

Definition at line 34 of file CommandContext.h.

Constructor & Destructor Documentation

◆ CommandContext() [1/2]

CommandContext::CommandContext ( AudacityProject p,
const wxEvent *  e = nullptr,
int  ii = 0,
const CommandParameter param = CommandParameter{} 
)

Definition at line 34 of file CommandContext.cpp.

40  : project{ p }
41  // No target specified? Use the special interactive one that pops up a dialog.
42  , pOutput( std::make_unique<InteractiveOutputTargets>() )
43  , pEvt{ e }
44  , index{ ii }
45  , parameter{ param }
46 {
47 }

◆ CommandContext() [2/2]

CommandContext::CommandContext ( AudacityProject p,
std::unique_ptr< CommandOutputTargets target 
)

Definition at line 49 of file CommandContext.cpp.

52  : project{ p }
53  // Revisit and use std_unique pointer for pOutput??
54  , pOutput( std::move( target) )
55  , pEvt{ nullptr }
56  , index{ 0 }
58 {
59 }

◆ ~CommandContext()

CommandContext::~CommandContext ( )
default

Member Function Documentation

◆ AddBool()

void CommandContext::AddBool ( const bool  value,
const wxString &  name = {} 
) const

Definition at line 124 of file CommandContext.cpp.

125 {
126  if( pOutput )
127  pOutput->AddItem( value, name );
128 }

References name, and pOutput.

Referenced by GetInfoCommand::SendTracks().

Here is the caller graph for this function:

◆ AddItem() [1/2]

void CommandContext::AddItem ( const double  value,
const wxString &  name = {} 
) const

Definition at line 129 of file CommandContext.cpp.

130 {
131  if( pOutput )
132  pOutput->AddItem( value, name );
133 }

References name, and pOutput.

◆ AddItem() [2/2]

void CommandContext::AddItem ( const wxString &  value,
const wxString &  name = {} 
) const

Definition at line 119 of file CommandContext.cpp.

120 {
121  if( pOutput )
122  pOutput->AddItem( value, name );
123 }

References name, and pOutput.

Referenced by GetInfoCommand::ExploreAdornments(), GetInfoCommand::ExploreMenu(), GetInfoCommand::ExploreTrackPanel(), GetInfoCommand::ExploreWindows(), GetInfoCommand::SendBoxes(), GetInfoCommand::SendClips(), GetInfoCommand::SendEnvelopes(), GetInfoCommand::SendLabels(), GetInfoCommand::SendMenus(), and GetInfoCommand::SendTracks().

Here is the caller graph for this function:

◆ EndArray()

void CommandContext::EndArray ( ) const

Definition at line 94 of file CommandContext.cpp.

95 {
96  if( pOutput )
97  pOutput->EndArray();
98 }

References pOutput.

Referenced by GetInfoCommand::ExploreAdornments(), GetInfoCommand::ExploreTrackPanel(), GetInfoCommand::ExploreWindows(), GetInfoCommand::SendBoxes(), GetInfoCommand::SendClips(), GetInfoCommand::SendCommands(), GetInfoCommand::SendEnvelopes(), GetInfoCommand::SendLabels(), GetInfoCommand::SendMenus(), GetInfoCommand::SendPreferences(), and GetInfoCommand::SendTracks().

Here is the caller graph for this function:

◆ EndField()

void CommandContext::EndField ( ) const

Definition at line 114 of file CommandContext.cpp.

115 {
116  if( pOutput )
117  pOutput->EndField();
118 }

References pOutput.

Referenced by GetInfoCommand::ExploreAdornments(), GetInfoCommand::ExploreTrackPanel(), GetInfoCommand::ExploreWindows(), GetInfoCommand::SendBoxes(), and GetInfoCommand::SendEnvelopes().

Here is the caller graph for this function:

◆ EndStruct()

void CommandContext::EndStruct ( ) const

Definition at line 104 of file CommandContext.cpp.

105 {
106  if( pOutput )
107  pOutput->EndStruct();
108 }

References pOutput.

Referenced by GetInfoCommand::ExploreAdornments(), GetInfoCommand::ExploreMenu(), GetInfoCommand::ExploreTrackPanel(), GetInfoCommand::ExploreWindows(), GetInfoCommand::SendBoxes(), GetInfoCommand::SendClips(), GetInfoCommand::SendEnvelopes(), GetInfoCommand::SendLabels(), GetInfoCommand::SendMenus(), and GetInfoCommand::SendTracks().

Here is the caller graph for this function:

◆ Error()

void CommandContext::Error ( const wxString &  message) const
virtual

Definition at line 73 of file CommandContext.cpp.

74 {
75  if( pOutput )
76  pOutput->Error( message );
77  else
78  {
79  wxLogDebug("Error:%s", message );
80  }
81 }

References pOutput.

Referenced by ExportCommand::Apply(), SetLabelCommand::Apply(), ScreenshotCommand::Capture(), CompareAudioCommand::GetSelection(), anonymous_namespace{TransportMenus.cpp}::PlayCurrentRegionAndWait(), anonymous_namespace{TransportMenus.cpp}::PlayPlayRegionAndWait(), anonymous_namespace{TransportMenus.cpp}::RecordAndWait(), and CommandImplementation::SetParameter().

Here is the caller graph for this function:

◆ Progress()

void CommandContext::Progress ( double  d) const
virtual

Definition at line 83 of file CommandContext.cpp.

84 {
85  if( pOutput )
86  pOutput->Progress( d );
87 }

References pOutput.

Referenced by CompareAudioCommand::Apply().

Here is the caller graph for this function:

◆ StartArray()

void CommandContext::StartArray ( ) const

Definition at line 89 of file CommandContext.cpp.

90 {
91  if( pOutput )
92  pOutput->StartArray();
93 }

References pOutput.

Referenced by GetInfoCommand::ExploreAdornments(), GetInfoCommand::ExploreTrackPanel(), GetInfoCommand::ExploreWindows(), GetInfoCommand::SendBoxes(), GetInfoCommand::SendClips(), GetInfoCommand::SendCommands(), GetInfoCommand::SendEnvelopes(), GetInfoCommand::SendLabels(), GetInfoCommand::SendMenus(), GetInfoCommand::SendPreferences(), and GetInfoCommand::SendTracks().

Here is the caller graph for this function:

◆ StartField()

void CommandContext::StartField ( const wxString &  name) const

Definition at line 109 of file CommandContext.cpp.

110 {
111  if( pOutput )
112  pOutput->StartField(name);
113 }

References name, and pOutput.

Referenced by GetInfoCommand::ExploreAdornments(), GetInfoCommand::ExploreTrackPanel(), GetInfoCommand::ExploreWindows(), GetInfoCommand::SendBoxes(), and GetInfoCommand::SendEnvelopes().

Here is the caller graph for this function:

◆ StartStruct()

void CommandContext::StartStruct ( ) const

Definition at line 99 of file CommandContext.cpp.

100 {
101  if( pOutput )
102  pOutput->StartStruct();
103 }

References pOutput.

Referenced by GetInfoCommand::ExploreAdornments(), GetInfoCommand::ExploreMenu(), GetInfoCommand::ExploreTrackPanel(), GetInfoCommand::ExploreWindows(), GetInfoCommand::SendBoxes(), GetInfoCommand::SendClips(), GetInfoCommand::SendEnvelopes(), GetInfoCommand::SendLabels(), GetInfoCommand::SendMenus(), and GetInfoCommand::SendTracks().

Here is the caller graph for this function:

◆ Status()

void CommandContext::Status ( const wxString &  message,
bool  bFlush = false 
) const
virtual

Definition at line 63 of file CommandContext.cpp.

64 {
65  if( pOutput )
66  pOutput->Status( message, bFlush );
67  else
68  {
69  wxLogDebug("Status:%s", message );
70  }
71 }

References pOutput.

Referenced by BatchEvalCommand::Apply(), CompareAudioCommand::Apply(), DemoCommand::Apply(), ExportCommand::Apply(), MessageCommand::Apply(), GetPreferenceCommand::Apply(), MacroCommands::ApplyCommand(), GetInfoCommand::ApplyInner(), HelpCommand::ApplyInner(), ScreenshotCommand::Capture(), and CompareAudioCommand::GetSelection().

Here is the caller graph for this function:

Member Data Documentation

◆ index

int CommandContext::index

◆ parameter

CommandParameter CommandContext::parameter

◆ pEvt

const wxEvent* CommandContext::pEvt

◆ pOutput

std::unique_ptr<CommandOutputTargets> CommandContext::pOutput

◆ project

AudacityProject& CommandContext::project

Definition at line 64 of file CommandContext.h.

Referenced by BatchEvalCommand::Apply(), CompareAudioCommand::Apply(), DragCommand::Apply(), GetInfoCommand::Apply(), HelpCommand::Apply(), ImportCommand::Apply(), ExportCommand::Apply(), OpenProjectCommand::Apply(), SaveProjectCommand::Apply(), SaveCopyCommand::Apply(), SetPreferenceCommand::Apply(), ScreenshotCommand::Apply(), SelectTimeCommand::Apply(), SelectFrequenciesCommand::Apply(), SelectTracksCommand::Apply(), SetLabelCommand::Apply(), SetProjectCommand::Apply(), SetTrackBase::Apply(), SetEnvelopeCommand::ApplyInner(), SetTrackStatusCommand::ApplyInner(), SetTrackVisualsCommand::ApplyInner(), ScreenshotCommand::CaptureCommands(), ScreenshotCommand::CapturePreferences(), MacroCommands::DoAudacityCommand(), EffectUI::DoEffect(), anonymous_namespace{FileMenus.cpp}::DoImport(), CommandManager::DoRepeatProcess(), anonymous_namespace{TransportMenus.cpp}::DoStartPlaying(), anonymous_namespace{TransportMenus.cpp}::DoStopPlaying(), GetInfoCommand::ExploreMenu(), GetInfoCommand::ExploreTrackPanel(), EditActions::Handler::FindSelection(), CommandManager::HandleTextualCommand(), TrackActions::Handler::MuteTracks(), HelpActions::Handler::OnAbout(), LabelEditActions::Handler::OnAddLabel(), LabelEditActions::Handler::OnAddLabelPlaying(), ViewActions::Handler::OnAdvancedVZoom(), TrackActions::Handler::OnAlign(), TrackActions::Handler::OnAlignNoSync(), PluginActions::Handler::OnApplyMacroDirectlyByName(), PluginActions::Handler::OnApplyMacrosPalette(), HelpActions::Handler::OnAudioDeviceInfo(), ExtraActions::Handler::OnAudioHost(), PluginActions::Handler::OnBenchmark(), ClipActions::Handler::OnClipLeft(), ClipActions::Handler::OnClipRight(), FileActions::Handler::OnClose(), ViewActions::Handler::OnCollapseAllTracks(), FileActions::Handler::OnCompact(), anonymous_namespace{Contrast.cpp}::Handler::OnContrast(), EditActions::Handler::OnCopy(), LabelEditActions::Handler::OnCopyLabels(), NavigationActions::Handler::OnCursorDown(), SelectActions::Handler::OnCursorLeft(), SelectActions::Handler::OnCursorLongJumpLeft(), SelectActions::Handler::OnCursorLongJumpRight(), ClipActions::Handler::OnCursorNextClipBoundary(), SelectActions::Handler::OnCursorPositionStore(), ClipActions::Handler::OnCursorPrevClipBoundary(), SelectActions::Handler::OnCursorRight(), SelectActions::Handler::OnCursorSelEnd(), SelectActions::Handler::OnCursorSelStart(), SelectActions::Handler::OnCursorShortJumpLeft(), SelectActions::Handler::OnCursorShortJumpRight(), SelectActions::Handler::OnCursorTrackEnd(), SelectActions::Handler::OnCursorTrackStart(), NavigationActions::Handler::OnCursorUp(), EditActions::Handler::OnCut(), LabelEditActions::Handler::OnCutLabels(), EditActions::Handler::OnDelete(), LabelEditActions::Handler::OnDeleteLabels(), PluginActions::Handler::OnDetectUpstreamDropouts(), EditActions::Handler::OnDisjoin(), LabelEditActions::Handler::OnDisjoinLabels(), ToolActions::Handler::OnDrawTool(), EditActions::Handler::OnDuplicate(), LabelEditActions::Handler::OnEditLabels(), EditActions::Handler::OnEditMetadata(), ToolActions::Handler::OnEnvelopeTool(), ViewActions::Handler::OnExpandAllTracks(), FileActions::Handler::OnExportAudio(), FileActions::Handler::OnExportFLAC(), FileActions::Handler::OnExportLabels(), FileActions::Handler::OnExportMIDI(), FileActions::Handler::OnExportMp3(), FileActions::Handler::OnExportMultiple(), FileActions::Handler::OnExportOgg(), FileActions::Handler::OnExportSelection(), FileActions::Handler::OnExportWav(), NavigationActions::Handler::OnFirstTrack(), ExtraActions::Handler::OnFullScreen(), ViewActions::Handler::OnGoSelEnd(), ViewActions::Handler::OnGoSelStart(), anonymous_namespace{HistoryWindow.cpp}::Handler::OnHistory(), FileActions::Handler::OnImportLabels(), FileActions::Handler::OnImportMIDI(), ExtraActions::Handler::OnInputChannels(), ExtraActions::Handler::OnInputDevice(), ExtraActions::Handler::OnInputGain(), ExtraActions::Handler::OnInputGainDec(), ExtraActions::Handler::OnInputGainInc(), EditActions::Handler::OnJoin(), LabelEditActions::Handler::OnJoinLabels(), anonymous_namespace{LyricsWindow.cpp}::Handler::OnKaraoke(), NavigationActions::Handler::OnLastTrack(), TransportActions::Handler::OnLockPlayRegion(), anonymous_namespace{SelectMenus.cpp}::OnlyHandleKeyUp(), PluginActions::Handler::OnManageAnalyzers(), PluginActions::Handler::OnManageEffects(), PluginActions::Handler::OnManageGenerators(), PluginActions::Handler::OnManageMacros(), PluginActions::Handler::OnManageTools(), HelpActions::Handler::OnManual(), HelpActions::Handler::OnMenuTree(), TrackActions::Handler::OnMixAndRender(), TrackActions::Handler::OnMixAndRenderToNewTrack(), anonymous_namespace{MixerBoard.cpp}::Handler::OnMixerBoard(), TransportActions::Handler::OnMoveToNextLabel(), TransportActions::Handler::OnMoveToPrevLabel(), ToolActions::Handler::OnMultiTool(), TrackActions::Handler::OnNewLabelTrack(), TrackActions::Handler::OnNewStereoTrack(), TrackActions::Handler::OnNewTimeTrack(), TrackActions::Handler::OnNewWaveTrack(), NavigationActions::Handler::OnNextFrame(), ToolActions::Handler::OnNextTool(), NavigationActions::Handler::OnNextWindow(), FileActions::Handler::OnOpen(), ExtraActions::Handler::OnOutputDevice(), ExtraActions::Handler::OnOutputGain(), ExtraActions::Handler::OnOutputGainDec(), ExtraActions::Handler::OnOutputGainInc(), FileActions::Handler::OnPageSetup(), TrackActions::Handler::OnPanCenter(), TrackActions::Handler::OnPanLeft(), TrackActions::Handler::OnPanRight(), EditActions::Handler::OnPaste(), LabelEditActions::Handler::OnPasteNewLabel(), TransportActions::Handler::OnPause(), TransportActions::Handler::OnPlayAfterSelectionEnd(), TransportActions::Handler::OnPlayAfterSelectionStart(), TransportActions::Handler::OnPlayAtSpeed(), TransportActions::Handler::OnPlayAtSpeedCutPreview(), TransportActions::Handler::OnPlayAtSpeedLooped(), TransportActions::Handler::OnPlayBeforeAndAfterSelectionEnd(), TransportActions::Handler::OnPlayBeforeAndAfterSelectionStart(), TransportActions::Handler::OnPlayBeforeSelectionEnd(), TransportActions::Handler::OnPlayBeforeSelectionStart(), TransportActions::Handler::OnPlayCutPreview(), TransportActions::Handler::OnPlayLooped(), TransportActions::Handler::OnPlayOneSecond(), TransportActions::Handler::OnPlaySpeedDec(), TransportActions::Handler::OnPlaySpeedInc(), TransportActions::Handler::OnPlayStop(), TransportActions::Handler::OnPlayStopSelect(), TransportActions::Handler::OnPlayToSelection(), anonymous_namespace{FreqWindow.cpp}::Handler::OnPlotSpectrum(), EditActions::Handler::OnPreferences(), NavigationActions::Handler::OnPrevFrame(), ToolActions::Handler::OnPrevTool(), NavigationActions::Handler::OnPrevWindow(), FileActions::Handler::OnPrint(), FileActions::Handler::OnProjectReset(), HelpActions::Handler::OnQuickFix(), HelpActions::Handler::OnQuickHelp(), EditActions::Handler::OnRedo(), TrackActions::Handler::OnRemoveTracks(), PluginActions::Handler::OnRepeatLastAnalyzer(), PluginActions::Handler::OnRepeatLastEffect(), PluginActions::Handler::OnRepeatLastGenerator(), PluginActions::Handler::OnRepeatLastTool(), TrackActions::Handler::OnResample(), PluginActions::Handler::OnResetConfig(), ToolManager::OnResetToolBars(), FileActions::Handler::OnSave(), FileActions::Handler::OnSaveAs(), FileActions::Handler::OnSaveCopy(), PluginActions::Handler::OnScreenshot(), SelectActions::Handler::OnSeekLeftLong(), SelectActions::Handler::OnSeekLeftShort(), SelectActions::Handler::OnSeekRightLong(), SelectActions::Handler::OnSeekRightShort(), SelectActions::Handler::OnSelContractLeft(), SelectActions::Handler::OnSelContractRight(), SelectActions::Handler::OnSelectAll(), SelectActions::Handler::OnSelectAllTime(), SelectActions::Handler::OnSelectAllTracks(), SelectActions::Handler::OnSelectCursorEnd(), SelectActions::Handler::OnSelectCursorStoredCursor(), ClipActions::Handler::OnSelectCursorToNextClipBoundary(), SelectActions::Handler::OnSelectionRestore(), SelectActions::Handler::OnSelectionSave(), ClipActions::Handler::OnSelectNextClip(), SelectActions::Handler::OnSelectNone(), ClipActions::Handler::OnSelectPrevClip(), ClipActions::Handler::OnSelectPrevClipBoundaryToCursor(), SelectActions::Handler::OnSelectStartCursor(), SelectActions::Handler::OnSelectSyncLockSel(), ToolActions::Handler::OnSelectTool(), SelectActions::Handler::OnSelectTrackStartToEnd(), SelectActions::Handler::OnSelExtendLeft(), SelectActions::Handler::OnSelExtendRight(), SelectActions::Handler::OnSelSetExtendLeft(), SelectActions::Handler::OnSelSetExtendRight(), SelectActions::Handler::OnSelToEnd(), SelectActions::Handler::OnSelToStart(), SelectActions::Handler::OnSetLeftSelection(), TransportActions::Handler::OnSetPlaySpeed(), SelectActions::Handler::OnSetRightSelection(), NavigationActions::Handler::OnShiftDown(), NavigationActions::Handler::OnShiftUp(), ScreenshotBigDialog::OnShortTracks(), ViewActions::Handler::OnShowClipping(), ViewActions::Handler::OnShowExtraMenus(), ViewActions::Handler::OnShowNameOverlay(), AttachedToolBarMenuItem::OnShowToolBar(), EditActions::Handler::OnSilence(), LabelEditActions::Handler::OnSilenceLabels(), PluginActions::Handler::OnSimulateRecordingErrors(), SelectActions::Handler::OnSkipEnd(), SelectActions::Handler::OnSkipStart(), SelectActions::Handler::OnSnapToNearest(), SelectActions::Handler::OnSnapToOff(), SelectActions::Handler::OnSnapToPrior(), TrackActions::Handler::OnSortName(), TrackActions::Handler::OnSortTime(), TransportActions::Handler::OnSoundActivated(), EditActions::Handler::OnSplit(), EditActions::Handler::OnSplitCut(), LabelEditActions::Handler::OnSplitCutLabels(), EditActions::Handler::OnSplitDelete(), LabelEditActions::Handler::OnSplitDeleteLabels(), LabelEditActions::Handler::OnSplitLabels(), EditActions::Handler::OnSplitNew(), TransportActions::Handler::OnStop(), TrackActions::Handler::OnSyncLock(), TransportActions::Handler::OnTimerRecord(), ToolActions::Handler::OnTimeShiftTool(), NavigationActions::Handler::OnToggle(), TransportActions::Handler::OnTogglePinnedHead(), TrackActions::Handler::OnTrackClose(), TrackActions::Handler::OnTrackGain(), TrackActions::Handler::OnTrackGainDec(), TrackActions::Handler::OnTrackGainInc(), TrackActions::Handler::OnTrackMenu(), TrackActions::Handler::OnTrackMoveBottom(), TrackActions::Handler::OnTrackMoveDown(), TrackActions::Handler::OnTrackMoveTop(), TrackActions::Handler::OnTrackMoveUp(), TrackActions::Handler::OnTrackMute(), TrackActions::Handler::OnTrackPan(), TrackActions::Handler::OnTrackPanLeft(), TrackActions::Handler::OnTrackPanRight(), TrackActions::Handler::OnTrackSolo(), EditActions::Handler::OnTrim(), EditActions::Handler::OnUndo(), TransportActions::Handler::OnUnlockPlayRegion(), SelectActions::Handler::OnZeroCrossing(), ViewActions::Handler::OnZoomFit(), ViewActions::Handler::OnZoomFitV(), ViewActions::Handler::OnZoomIn(), ViewActions::Handler::OnZoomNormal(), ViewActions::Handler::OnZoomOut(), ViewActions::Handler::OnZoomSel(), ViewActions::Handler::OnZoomToggle(), ToolActions::Handler::OnZoomTool(), anonymous_namespace{TransportMenus.cpp}::PlayCurrentRegionAndWait(), anonymous_namespace{TransportMenus.cpp}::PlayPlayRegionAndWait(), ScreenshotBigDialog::PopulateOrExchange(), anonymous_namespace{TransportMenus.cpp}::RecordAndWait(), CommandManager::RegisterLastAnalyzer(), CommandManager::RegisterLastTool(), GetInfoCommand::SendBoxes(), GetInfoCommand::SendClips(), GetInfoCommand::SendEnvelopes(), GetInfoCommand::SendLabels(), GetInfoCommand::SendMenus(), GetInfoCommand::SendPreferences(), GetInfoCommand::SendTracks(), ScreenshotBigDialog::SizeMainWindow(), ScreenshotBigDialog::SizeTracks(), and ScreenshotBigDialog::TimeZoom().

◆ temporarySelection

TemporarySelection CommandContext::temporarySelection

The documentation for this class was generated from the following files:
CommandContext::pEvt
const wxEvent * pEvt
Definition: CommandContext.h:66
name
const TranslatableString name
Definition: Distortion.cpp:98
CommandContext::parameter
CommandParameter parameter
Definition: CommandContext.h:68
TaggedIdentifier< CommandIdTag, false >
CommandContext::index
int index
Definition: CommandContext.h:67
CommandContext::project
AudacityProject & project
Definition: CommandContext.h:64
CommandContext::pOutput
std::unique_ptr< CommandOutputTargets > pOutput
Definition: CommandContext.h:65