You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
676 B
C++

#include <array>
constexpr unsigned int MAX_ERROR_QUEUE_SIZE = 8;
enum class Error : char
{
None = 0,
BadParam,
BadParamSize,
BadUserCodeLoad,
BadUserCodeSize,
NotIdle,
ConversionAborted
};
class ErrorManager
{
public:
void add(Error error) {
if (m_index < m_queue.size())
m_queue[m_index++] = error;
}
bool assert(bool condition, Error error) {
if (!condition)
add(error);
return condition;
}
Error pop() {
return m_index == 0 ? Error::None : m_queue[--m_index];
}
private:
std::array<Error, MAX_ERROR_QUEUE_SIZE> m_queue;
unsigned int m_index = 0;
};