semf
processor.h
Go to the documentation of this file.
1
10#ifndef SEMF_COMMUNICATION_ESH_PROCESSOR_H_
11#define SEMF_COMMUNICATION_ESH_PROCESSOR_H_
12
18#include <array>
19
20namespace semf::esh
21{
26{
27public:
31 enum class ErrorCode : uint8_t
32 {
33 LoadCommand_IsBusy = 0,
34 };
45 Processor(const LinkedList<Command>& commands, Printer& printer, char lineBuffer[], size_t lineBufferSize, char** argvBuffer, size_t argvBufferSize);
46 Processor(const Processor& other) = delete;
47 virtual ~Processor() = default;
52 void loadCommand();
56 void execLoadedCommand();
61
62private:
64 void parseLine();
66 void printError();
68 void onQuotationMarkPrinted();
70 void onNamePrinted();
72 void onDone();
74 const LinkedList<Command>& m_commands;
76 Printer& m_printer;
78 char* const m_lineBuffer;
80 const size_t m_lineBufferSize;
82 char** const m_argv;
84 const size_t m_argvSize;
86 bool m_busy = false;
88 const Command* m_currentCommand = nullptr;
90 int m_argc;
92 int m_lastExitStatus = 0;
94 SEMF_SLOT(m_onQuotationMarkPrintedSlot, Processor, *this, onQuotationMarkPrinted);
96 SEMF_SLOT(m_onNamePrintedSlot, Processor, *this, onNamePrinted);
98 SEMF_SLOT(m_onDoneSlot, Processor, *this, onDone);
100 static constexpr Error::ClassID kSemfClassId = Error::ClassID::Processor;
101};
102} // namespace semf::esh
103#endif // SEMF_COMMUNICATION_ESH_PROCESSOR_H_
Class for representing errors. Every error should have a unique source code. As a user feel encourage...
Definition: error.h:22
ClassID
Semf class IDs.
Definition: error.h:28
LinkedList is an managed double linked list implementation.
Definition: linkedlist.h:43
Wrapper class for shell command. The user has to create object of this class for adding their functio...
Definition: command.h:28
Class for string related UART communication. Using this class outside of an esh-context can make sens...
Definition: printer.h:25
Manages esh's command parsing and execution.
Definition: processor.h:26
SEMF_SIGNAL(error, Error)
Processor(const LinkedList< Command > &commands, Printer &printer, char lineBuffer[], size_t lineBufferSize, char **argvBuffer, size_t argvBufferSize)
Constructor.
Definition: processor.cpp:16
ErrorCode
Error codes for this class. Error ID identify a unique error() / onError call (excluding transferring...
Definition: processor.h:32
void loadCommand()
Load a command for execution according to the current command line.
Definition: processor.cpp:27
void execLoadedCommand()
Execute the currenty loaded command. Returns with no error if no command is loaded....
Definition: processor.cpp:56
virtual ~Processor()=default
Processor(const Processor &other)=delete