Audacity 3.2.0
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/variant.h>
29#include <wx/arrstr.h>
30
31#include "CommandTargets.h"
32
35 , const wxEvent *e
36 , int ii
37 , const CommandParameter &param
38 )
39 : project{ p }
40 // No target specified? Use the special interactive one that pops up a dialog.
41 , pOutput( std::make_unique<InteractiveOutputTargets>() )
42 , pEvt{ e }
43 , index{ ii }
44 , parameter{ param }
45{
46}
47
50 std::unique_ptr<CommandOutputTargets> target)
51 : project{ p }
52 // Revisit and use std_unique pointer for pOutput??
53 , pOutput( std::move( target) )
54 , pEvt{ nullptr }
55 , index{ 0 }
56 , parameter{ CommandParameter{}}
57{
58}
59
61
62void CommandContext::Status( const wxString & message, bool bFlush ) const
63{
64 if( pOutput )
65 pOutput->Status( message, bFlush );
66 else
67 {
68 wxLogDebug("Status:%s", message );
69 }
70}
71
72void CommandContext::Error( const wxString & message ) const
73{
74 if( pOutput )
75 pOutput->Error( message );
76 else
77 {
78 wxLogDebug("Error:%s", message );
79 }
80}
81
82void CommandContext::Progress( double d ) const
83{
84 if( pOutput )
85 pOutput->Progress( d );
86}
87
89{
90 if( pOutput )
91 pOutput->StartArray();
92}
94{
95 if( pOutput )
96 pOutput->EndArray();
97}
99{
100 if( pOutput )
101 pOutput->StartStruct();
102}
104{
105 if( pOutput )
106 pOutput->EndStruct();
107}
108void CommandContext::StartField(const wxString &name) const
109{
110 if( pOutput )
111 pOutput->StartField(name);
112}
114{
115 if( pOutput )
116 pOutput->EndField();
117}
118void CommandContext::AddItem(const wxString &value , const wxString &name ) const
119{
120 if( pOutput )
121 pOutput->AddItem( value, name );
122}
123void CommandContext::AddBool(const bool value , const wxString &name ) const
124{
125 if( pOutput )
126 pOutput->AddItem( value, name );
127}
128void CommandContext::AddItem(const double value , const wxString &name ) const
129{
130 if( pOutput )
131 pOutput->AddItem( value, name );
132}
133
134
135
136
const TranslatableString name
Definition: Distortion.cpp:74
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
void EndField() const
void StartArray() const
void EndArray() const
virtual void Progress(double d) const
CommandContext(AudacityProject &p, const wxEvent *e=nullptr, int ii=0, const CommandParameter &param=CommandParameter{})
virtual void Error(const wxString &message) const
virtual void Status(const wxString &message, bool bFlush=false) const
void AddBool(const bool value, const wxString &name={}) const
void StartField(const wxString &name) const
void AddItem(const wxString &value, const wxString &name={}) const
void StartStruct() const
std::unique_ptr< CommandOutputTargets > pOutput
void EndStruct() const
InteractiveOutputTargets is an output target that pops up a dialog, if necessary.
STL namespace.