Line data Source code
1 : // Copyright 2024 Accenture.
2 :
3 : #include "console/AsyncCommandWrapper.h"
4 :
5 : #include "console/AsyncConsole.h"
6 :
7 : #include <async/Async.h>
8 :
9 : namespace console
10 : {
11 1 : AsyncCommandWrapper::AsyncCommandWrapper(
12 1 : ::util::command::ICommand& command, ::async::ContextType context)
13 1 : : fCommand(command), fArguments(), fpSharedOutputStream(nullptr), fContext(context)
14 : {
15 1 : AsyncConsole::addCommand(*this);
16 1 : }
17 :
18 1 : char const* AsyncCommandWrapper::getId() const { return fCommand.getId(); }
19 :
20 0 : void AsyncCommandWrapper::getHelp(::util::command::ICommand::IHelpCallback& callback) const
21 : {
22 0 : fCommand.getHelp(callback);
23 0 : }
24 :
25 0 : ::util::command::ICommand::ExecuteResult AsyncCommandWrapper::execute(
26 : ::util::string::ConstString const& arguments,
27 : ::util::stream::ISharedOutputStream* sharedOutputStream)
28 : {
29 0 : fArguments = arguments;
30 0 : fpSharedOutputStream = sharedOutputStream;
31 :
32 0 : ::async::execute(fContext, *this);
33 :
34 0 : return ::util::command::ICommand::ExecuteResult(::util::command::ICommand::Result::OK);
35 : }
36 :
37 0 : void AsyncCommandWrapper::execute()
38 : {
39 : ::util::command::ICommand::ExecuteResult const result
40 0 : = fCommand.execute(fArguments, fpSharedOutputStream);
41 0 : AsyncConsole::commandExecuted(result);
42 0 : }
43 :
44 : } /* namespace console */
|