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/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
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
63void 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
73void 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
83void 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}
109void CommandContext::StartField(const wxString &name) const
110{
111 if( pOutput )
112 pOutput->StartField(name);
113}
115{
116 if( pOutput )
117 pOutput->EndField();
118}
119void CommandContext::AddItem(const wxString &value , const wxString &name ) const
120{
121 if( pOutput )
122 pOutput->AddItem( value, name );
123}
124void CommandContext::AddBool(const bool value , const wxString &name ) const
125{
126 if( pOutput )
127 pOutput->AddItem( value, name );
128}
129void CommandContext::AddItem(const double value , const wxString &name ) const
130{
131 if( pOutput )
132 pOutput->AddItem( value, name );
133}
134
135
136
137
const TranslatableString name
Definition: Distortion.cpp:82
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
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.