Audacity  3.0.3
CommandContext.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity - A Digital Audio Editor
4  Copyright 1999-2017 Audacity Team
5  License: wxwidgets
6 
7  Dan Horgan
8  James Crook
9 
10 ******************************************************************//*******************************************************************/
22 
23 
24 #include "CommandContext.h"
25 
26 #include <map>
27 #include <wx/log.h>
28 #include <wx/string.h>
29 #include <wx/variant.h>
30 #include <wx/arrstr.h>
31 
32 #include "CommandTargets.h"
33 
36  , const wxEvent *e
37  , int ii
38  , const CommandParameter &param
39  )
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 }
48 
50  AudacityProject &p,
51  std::unique_ptr<CommandOutputTargets> target)
52  : project{ p }
53  // Revisit and use std_unique pointer for pOutput??
54  , pOutput( std::move( target) )
55  , pEvt{ nullptr }
56  , index{ 0 }
57  , parameter{ CommandParameter{}}
58 {
59 }
60 
62 
63 void CommandContext::Status( const wxString & message, bool bFlush ) const
64 {
65  if( pOutput )
66  pOutput->Status( message, bFlush );
67  else
68  {
69  wxLogDebug("Status:%s", message );
70  }
71 }
72 
73 void CommandContext::Error( const wxString & message ) const
74 {
75  if( pOutput )
76  pOutput->Error( message );
77  else
78  {
79  wxLogDebug("Error:%s", message );
80  }
81 }
82 
83 void CommandContext::Progress( double d ) const
84 {
85  if( pOutput )
86  pOutput->Progress( d );
87 }
88 
90 {
91  if( pOutput )
92  pOutput->StartArray();
93 }
95 {
96  if( pOutput )
97  pOutput->EndArray();
98 }
100 {
101  if( pOutput )
102  pOutput->StartStruct();
103 }
105 {
106  if( pOutput )
107  pOutput->EndStruct();
108 }
109 void CommandContext::StartField(const wxString &name) const
110 {
111  if( pOutput )
112  pOutput->StartField(name);
113 }
115 {
116  if( pOutput )
117  pOutput->EndField();
118 }
119 void CommandContext::AddItem(const wxString &value , const wxString &name ) const
120 {
121  if( pOutput )
122  pOutput->AddItem( value, name );
123 }
124 void CommandContext::AddBool(const bool value , const wxString &name ) const
125 {
126  if( pOutput )
127  pOutput->AddItem( value, name );
128 }
129 void CommandContext::AddItem(const double value , const wxString &name ) const
130 {
131  if( pOutput )
132  pOutput->AddItem( value, name );
133 }
134 
135 
136 
137 
CommandContext::CommandContext
CommandContext(AudacityProject &p, const wxEvent *e=nullptr, int ii=0, const CommandParameter &param=CommandParameter{})
Definition: CommandContext.cpp:34
CommandContext::EndArray
void EndArray() const
Definition: CommandContext.cpp:94
CommandContext::EndField
void EndField() const
Definition: CommandContext.cpp:114
CommandContext::AddItem
void AddItem(const wxString &value, const wxString &name={}) const
Definition: CommandContext.cpp:119
CommandContext::AddBool
void AddBool(const bool value, const wxString &name={}) const
Definition: CommandContext.cpp:124
CommandContext::Status
virtual void Status(const wxString &message, bool bFlush=false) const
Definition: CommandContext.cpp:63
CommandContext.h
CommandContext::StartArray
void StartArray() const
Definition: CommandContext.cpp:89
name
const TranslatableString name
Definition: Distortion.cpp:98
CommandTargets.h
CommandContext::Error
virtual void Error(const wxString &message) const
Definition: CommandContext.cpp:73
CommandContext::Progress
virtual void Progress(double d) const
Definition: CommandContext.cpp:83
CommandContext::StartField
void StartField(const wxString &name) const
Definition: CommandContext.cpp:109
TaggedIdentifier< CommandIdTag, false >
CommandContext::EndStruct
void EndStruct() const
Definition: CommandContext.cpp:104
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
CommandContext::StartStruct
void StartStruct() const
Definition: CommandContext.cpp:99
CommandContext::~CommandContext
~CommandContext()
CommandContext::pOutput
std::unique_ptr< CommandOutputTargets > pOutput
Definition: CommandContext.h:65