From e080a26651f90c88176140d63a74c93c2f4041a2 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Fri, 22 Jan 2021 21:41:11 -0500 Subject: add SampleBuffer and ErrorManager; WAV testing --- source/error.hpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 source/error.hpp (limited to 'source/error.hpp') diff --git a/source/error.hpp b/source/error.hpp new file mode 100644 index 0000000..699c746 --- /dev/null +++ b/source/error.hpp @@ -0,0 +1,38 @@ +#include + +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 m_queue; + unsigned int m_index = 0; +}; + -- cgit v1.2.3