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

CommandContext provides addiitonal 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>

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)
 
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
 
AudacityAppGetApp () const
 
AudacityProjectGetProject () const
 

Public Attributes

AudacityProjectproject
 
std::unique_ptr
< CommandOutputTargets
pOutput
 
const wxEvent * pEvt
 
int index
 
CommandParameter parameter
 

Detailed Description

CommandContext provides addiitonal 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 25 of file CommandContext.h.

Constructor & Destructor Documentation

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

Definition at line 42 of file CommandContext.cpp.

48  : project{ p }
49  // No target specified? Use the special interactive one that pops up a dialog.
50  , pOutput( std::make_unique<InteractiveOutputTargets>() )
51  , pEvt{ e }
52  , index{ ii }
53  , parameter{ param }
54 {
55 }
std::unique_ptr< CommandOutputTargets > pOutput
const wxEvent * pEvt
AudacityProject & project
CommandParameter parameter
CommandContext::CommandContext ( AudacityProject p,
std::unique_ptr< CommandOutputTargets target 
)

Definition at line 57 of file CommandContext.cpp.

60  : project{ p }
61  // Revisit and use std_unique pointer for pOutput??
62  , pOutput( std::move( target) )
63  , pEvt{ nullptr }
64  , index{ 0 }
66 {
67 }
std::unique_ptr< CommandOutputTargets > pOutput
const wxEvent * pEvt
AudacityProject & project
CommandParameter parameter
wxString CommandParameter

Member Function Documentation

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

Definition at line 136 of file CommandContext.cpp.

References pOutput.

Referenced by GetInfoCommand::SendTracks().

137 {
138  if( pOutput )
139  pOutput->AddItem( value, name );
140 }
std::unique_ptr< CommandOutputTargets > pOutput
const wxChar * name
Definition: Distortion.cpp:94
void CommandContext::AddItem ( const wxString &  value,
const wxString &  name = "" 
) const
void CommandContext::AddItem ( const double  value,
const wxString &  name = "" 
) const

Definition at line 141 of file CommandContext.cpp.

References pOutput.

142 {
143  if( pOutput )
144  pOutput->AddItem( value, name );
145 }
std::unique_ptr< CommandOutputTargets > pOutput
const wxChar * name
Definition: Distortion.cpp:94
void CommandContext::EndArray ( ) const
void CommandContext::EndField ( ) const

Definition at line 126 of file CommandContext.cpp.

References pOutput.

Referenced by GetInfoCommand::SendEnvelopes().

127 {
128  if( pOutput )
129  pOutput->EndField();
130 }
std::unique_ptr< CommandOutputTargets > pOutput
void CommandContext::EndStruct ( ) const

Definition at line 116 of file CommandContext.cpp.

References pOutput.

Referenced by GetInfoCommand::ExploreMenu(), GetInfoCommand::SendClips(), GetInfoCommand::SendEnvelopes(), GetInfoCommand::SendLabels(), and GetInfoCommand::SendTracks().

117 {
118  if( pOutput )
119  pOutput->EndStruct();
120 }
std::unique_ptr< CommandOutputTargets > pOutput
void CommandContext::Error ( const wxString &  message) const
virtual

Definition at line 79 of file CommandContext.cpp.

References pOutput.

Referenced by SetLabelCommand::Apply(), ExportCommand::Apply(), ScreenshotCommand::Capture(), and CompareAudioCommand::GetSelection().

80 {
81  if( pOutput )
82  pOutput->Error( message );
83  else
84  {
85  wxLogDebug("Error:%s", message );
86  }
87 }
std::unique_ptr< CommandOutputTargets > pOutput
AudacityApp * CommandContext::GetApp ( ) const

Definition at line 95 of file CommandContext.cpp.

96 { return (AudacityApp *) wxTheApp;}
AudacityApp is the 'main' class for Audacity.
Definition: AudacityApp.h:59
AudacityProject * CommandContext::GetProject ( ) const
void CommandContext::Progress ( double  d) const
virtual

Definition at line 89 of file CommandContext.cpp.

References pOutput.

Referenced by CompareAudioCommand::Apply().

90 {
91  if( pOutput )
92  pOutput->Progress( d );
93 }
std::unique_ptr< CommandOutputTargets > pOutput
void CommandContext::StartArray ( ) const
void CommandContext::StartField ( const wxString &  name) const

Definition at line 121 of file CommandContext.cpp.

References pOutput.

Referenced by GetInfoCommand::SendEnvelopes().

122 {
123  if( pOutput )
124  pOutput->StartField(name);
125 }
std::unique_ptr< CommandOutputTargets > pOutput
const wxChar * name
Definition: Distortion.cpp:94
void CommandContext::StartStruct ( ) const

Definition at line 111 of file CommandContext.cpp.

References pOutput.

Referenced by GetInfoCommand::ExploreMenu(), GetInfoCommand::SendClips(), GetInfoCommand::SendEnvelopes(), GetInfoCommand::SendLabels(), and GetInfoCommand::SendTracks().

112 {
113  if( pOutput )
114  pOutput->StartStruct();
115 }
std::unique_ptr< CommandOutputTargets > pOutput
void CommandContext::Status ( const wxString &  message,
bool  bFlush = false 
) const
virtual

Member Data Documentation

int CommandContext::index

Definition at line 56 of file CommandContext.h.

Referenced by AudacityProject::OnAlign(), and AudacityProject::OnAlignNoSync().

CommandParameter CommandContext::parameter
const wxEvent* CommandContext::pEvt
std::unique_ptr<CommandOutputTargets> CommandContext::pOutput
AudacityProject& CommandContext::project

Definition at line 53 of file CommandContext.h.

Referenced by BatchEvalCommand::Apply().


The documentation for this class was generated from the following files: