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#include "CommandContext.h"
23
24#include <map>
25#include <wx/log.h>
26#include <wx/variant.h>
27#include <wx/arrstr.h>
28
29#include "CommandTargets.h"
30
33 , const wxEvent *e
34 , int ii
35 , const CommandParameter &param
36 )
37 : project{ p }
38 // No target specified? Use the special interactive one that pops up a dialog.
39 , pOutput{ TargetFactory::Call() }
40 , pEvt{ e }
41 , index{ ii }
42 , parameter{ param }
43{
44}
45
48 std::unique_ptr<CommandOutputTargets> target)
49 : project{ p }
50 // Revisit and use std_unique pointer for pOutput??
51 , pOutput( std::move( target) )
52 , pEvt{ nullptr }
53 , index{ 0 }
54 , parameter{ CommandParameter{}}
55{
56}
57
59
60void CommandContext::Status( const wxString & message, bool bFlush ) const
61{
62 if( pOutput )
63 pOutput->Status( message, bFlush );
64 else
65 {
66 wxLogDebug("Status:%s", message );
67 }
68}
69
70void CommandContext::Error( const wxString & message ) const
71{
72 if( pOutput )
73 pOutput->Error( message );
74 else
75 {
76 wxLogDebug("Error:%s", message );
77 }
78}
79
80void CommandContext::Progress( double d ) const
81{
82 if( pOutput )
83 pOutput->Progress( d );
84}
85
87{
88 if( pOutput )
89 pOutput->StartArray();
90}
92{
93 if( pOutput )
94 pOutput->EndArray();
95}
97{
98 if( pOutput )
99 pOutput->StartStruct();
100}
102{
103 if( pOutput )
104 pOutput->EndStruct();
105}
106void CommandContext::StartField(const wxString &name) const
107{
108 if( pOutput )
109 pOutput->StartField(name);
110}
112{
113 if( pOutput )
114 pOutput->EndField();
115}
116void CommandContext::AddItem(const wxString &value , const wxString &name ) const
117{
118 if( pOutput )
119 pOutput->AddItem( value, name );
120}
121void CommandContext::AddBool(const bool value , const wxString &name ) const
122{
123 if( pOutput )
124 pOutput->AddItem( value, name );
125}
126void CommandContext::AddItem(const double value , const wxString &name ) const
127{
128 if( pOutput )
129 pOutput->AddItem( value, name );
130}
131
132
133
134
wxString name
Definition: TagsEditor.cpp:166
const auto project
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
STL namespace.