#ifndef ARM_OCSD_ERROR_H_INCLUDED
#define ARM_OCSD_ERROR_H_INCLUDED
#include "opencsd/ocsd_if_types.h"
#include <string>
class ocsdError {
public:
ocsdError(const ocsd_err_severity_t sev_type, const ocsd_err_t code);
ocsdError(const ocsd_err_severity_t sev_type, const ocsd_err_t code, const ocsd_trc_index_t idx);
ocsdError(const ocsd_err_severity_t sev_type, const ocsd_err_t code, const ocsd_trc_index_t idx, const uint8_t chan_id);
ocsdError(const ocsd_err_severity_t sev_type, const ocsd_err_t code, const std::string &msg);
ocsdError(const ocsd_err_severity_t sev_type, const ocsd_err_t code, const ocsd_trc_index_t idx, const std::string &msg);
ocsdError(const ocsd_err_severity_t sev_type, const ocsd_err_t code, const ocsd_trc_index_t idx, const uint8_t chan_id, const std::string &msg);
ocsdError(const ocsdError *pError);
ocsdError(const ocsdError &Error);
~ocsdError();
ocsdError& operator=(const ocsdError *p_err);
ocsdError& operator=(const ocsdError &err);
void setMessage(const std::string &msg) { m_err_message = msg; };
const std::string &getMessage() const { return m_err_message; };
const ocsd_err_t getErrorCode() const { return m_error_code; };
const ocsd_err_severity_t getErrorSeverity() const { return m_sev; };
const ocsd_trc_index_t getErrorIndex() const { return m_idx; };
const uint8_t getErrorChanID() const { return m_chan_ID; };
static const std::string getErrorString(const ocsdError &error);
private:
static void appendErrorDetails(std::string &errStr, const ocsdError &error);
ocsdError();
ocsd_err_t m_error_code;
ocsd_err_severity_t m_sev;
ocsd_trc_index_t m_idx;
uint8_t m_chan_ID;
std::string m_err_message;
};
inline ocsdError& ocsdError::operator=(const ocsdError *p_err)
{
this->m_error_code = p_err->getErrorCode();
this->m_sev = p_err->getErrorSeverity();
this->m_idx = p_err->getErrorIndex();
this->m_chan_ID = p_err->getErrorChanID();
this->m_err_message = p_err->getMessage();
return *this;
}
inline ocsdError& ocsdError::operator=(const ocsdError &err)
{
return (*this = &err);
}
class ocsdDataRespStr
{
public:
ocsdDataRespStr(ocsd_datapath_resp_t type) { m_type = type; }
~ocsdDataRespStr() {};
const char* getStr();
private:
ocsd_datapath_resp_t m_type;
};
#endif