51#ifndef __COMMANDTARGETS__
52#define __COMMANDTARGETS__
66 virtual void Update(
double completed) = 0;
75 virtual void Update(
const wxString &message) = 0;
76 virtual void StartArray();
77 virtual void EndArray();
78 virtual void StartStruct();
79 virtual void EndStruct();
80 virtual void AddItem(
const wxString &value ,
const wxString &
name = {} );
81 virtual void AddBool(
const bool value ,
const wxString &
name = {} );
82 virtual void AddItem(
const double value ,
const wxString &
name = {} );
83 virtual void StartField(
const wxString &
name = {} );
84 virtual void EndField( );
86 wxString Escaped(
const wxString &
str);
96 void Update(
const wxString &message)
override { mTarget.Update( message );}
98 void EndArray()
override { mTarget.EndArray();}
101 void AddItem(
const wxString &value ,
const wxString &
name = {} )
override
102 { mTarget.AddItem(value,
name);}
103 void AddBool(
const bool value ,
const wxString &
name = {} )
override
104 { mTarget.AddBool(value,
name);}
105 void AddItem(
const double value ,
const wxString &
name = {} )
override
106 { mTarget.AddItem(value,
name);}
108 { mTarget.StartField(
name);}
110 { mTarget.EndField();}
123 virtual void StartArray()
override;
124 virtual void EndArray()
override;
125 virtual void StartStruct()
override;
126 virtual void EndStruct()
override;
127 virtual void AddItem(
const wxString &value ,
const wxString &
name = {})
129 virtual void AddBool(
const bool value ,
const wxString &
name = {})
131 virtual void AddItem(
const double value ,
const wxString &
name = {})
133 virtual void StartField(
const wxString &
name = {} )
override;
134 virtual void EndField( )
override;
144 virtual void StartArray()
override;
145 virtual void EndArray()
override;
146 virtual void StartStruct()
override;
147 virtual void EndStruct()
override;
148 virtual void AddItem(
const wxString &value ,
const wxString &
name = {})
150 virtual void AddBool(
const bool value ,
const wxString &
name = {})
152 virtual void AddItem(
const double value ,
const wxString &
name = {})
154 virtual void StartField(
const wxString &
name = {} )
override;
155 virtual void EndField( )
override;
163 void Update(
double WXUNUSED(completed))
override {}
170 std::unique_ptr<CommandMessageTarget>
mTarget;
173 : mTarget(
std::move(target))
178 mTarget->Update(wxString::Format(
wxT(
"%.2f%%"), completed*100));
187 void Update(
const wxString &)
override {}
195 void Update(
const wxString &message)
override;
207 mBuffer(wxEmptyString)
210 mBuffer.Alloc(40000);
213 void Update(
const wxString &message)
override
232 std::unique_ptr<CommandMessageTarget>
m1, m2;
235 std::unique_ptr<CommandMessageTarget> &&t2)
236 : m1(
std::move(t1)), m2(
std::move(t2))
242 void Update(
const wxString &message)
override
260 return std::make_unique<NullProgressTarget>();
265 return std::make_shared<MessageBoxTarget>();
282 std::unique_ptr<CommandProgressTarget> pt =
284 std::shared_ptr<CommandMessageTarget> st =
286 std::shared_ptr<CommandMessageTarget> et =
299 void Status(
const wxString &status,
bool bFlush=
false)
BriefCommandMessageTarget is a CommandOutputTarget that provides status in a briefer listing.
BriefCommandMessageTarget(CommandMessageTarget &target)
virtual void AddItem(const double value, const wxString &name={}) override
virtual void AddItem(const wxString &value, const wxString &name={}) override
~BriefCommandMessageTarget() override
BriefCommandOutputTargets is a CommandOutputTargets that replaces the status message target with the ...
CommandOutputTargets * pToRestore
Sends messages to two message targets at once.
CombinedMessageTarget(std::unique_ptr< CommandMessageTarget > &&t1, std::unique_ptr< CommandMessageTarget > &&t2)
std::unique_ptr< CommandMessageTarget > m1
~CombinedMessageTarget() override
void Update(const wxString &message) override
CommandMessageTargetDecorator is a CommandOutputTarget that forwards its work on to another one....
void AddBool(const bool value, const wxString &name={}) override
void StartStruct() override
void StartField(const wxString &name={}) override
void AddItem(const double value, const wxString &name={}) override
void AddItem(const wxString &value, const wxString &name={}) override
~CommandMessageTargetDecorator() override
void EndStruct() override
void Update(const wxString &message) override
void StartArray() override
CommandMessageTargetDecorator(CommandMessageTarget &target)
CommandMessageTarget & mTarget
Interface for objects that can receive (string) messages from a command.
std::vector< int > mCounts
virtual void Update(const wxString &message)=0
CommandOutputTargets a mix of three output classes to output progress indication, status messages and...
std::shared_ptr< CommandMessageTarget > mStatusTarget
void AddItem(const double value, const wxString &name={})
std::unique_ptr< CommandProgressTarget > mProgressTarget
void StartField(const wxString &name)
CommandOutputTargets(std::unique_ptr< CommandProgressTarget > pt=TargetFactory::ProgressDefault(), std::shared_ptr< CommandMessageTarget > st=TargetFactory::MessageDefault(), std::shared_ptr< CommandMessageTarget > et=TargetFactory::MessageDefault())
std::shared_ptr< CommandMessageTarget > mErrorTarget
void AddBool(const bool value, const wxString &name={})
void Error(const wxString &message)
void AddItem(const wxString &value, const wxString &name={})
void Progress(double completed)
void Status(const wxString &status, bool bFlush=false)
Interface for objects that can receive command progress information.
virtual ~CommandProgressTarget()
virtual void Update(double completed)=0
LispifiedCommandOutputTargets is a CommandOutputTargets that replaces the status message target with ...
CommandOutputTargets * pToRestore
LispyCommandMessageTarget is a CommandOutputTarget that provides status in a lispy style.
LispyCommandMessageTarget(CommandMessageTarget &target)
~LispyCommandMessageTarget() override
Displays messages from a command in a BasicUI::MessageBox.
~MessageBoxTarget() override
Used to ignore a command's message updates.
void Update(const wxString &) override
~NullMessageTarget() override
Used to ignore a command's progress updates.
~NullProgressTarget() override
void Update(double WXUNUSED(completed)) override
ProgressToMessageTarget formats the percentage complete text as a message and sends it to that messag...
void Update(double completed) override
~ProgressToMessageTarget() override
ProgressToMessageTarget(std::unique_ptr< CommandMessageTarget > &&target)
std::unique_ptr< CommandMessageTarget > mTarget
Constructs a response (to be sent back to a script)
~ResponseTarget() override
virtual void Flush() override
void Update(const wxString &message) override
TargetFactory makes Command output targets. By default, we ignore progress updates but display all ot...
static std::unique_ptr< CommandProgressTarget > ProgressDefault()
static std::shared_ptr< CommandMessageTarget > MessageDefault()