OpenCSD - CoreSight Trace Decode Library  1.3.3
ocsd_error.h
Go to the documentation of this file.
1 
9 /*
10  * Redistribution and use in source and binary forms, with or without modification,
11  * are permitted provided that the following conditions are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright notice,
17  * this list of conditions and the following disclaimer in the documentation
18  * and/or other materials provided with the distribution.
19  *
20  * 3. Neither the name of the copyright holder nor the names of its contributors
21  * may be used to endorse or promote products derived from this software without
22  * specific prior written permission.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 'AS IS' AND
25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27  * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #ifndef ARM_OCSD_ERROR_H_INCLUDED
37 #define ARM_OCSD_ERROR_H_INCLUDED
38 
39 #include "opencsd/ocsd_if_types.h"
40 #include <string>
58 class ocsdError {
59 public:
60  ocsdError(const ocsd_err_severity_t sev_type, const ocsd_err_t code);
61  ocsdError(const ocsd_err_severity_t sev_type, const ocsd_err_t code, const ocsd_trc_index_t idx);
62  ocsdError(const ocsd_err_severity_t sev_type, const ocsd_err_t code, const ocsd_trc_index_t idx, const uint8_t chan_id);
63  ocsdError(const ocsd_err_severity_t sev_type, const ocsd_err_t code, const std::string &msg);
64  ocsdError(const ocsd_err_severity_t sev_type, const ocsd_err_t code, const ocsd_trc_index_t idx, const std::string &msg);
65  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);
67  ocsdError(const ocsdError *pError);
68  ocsdError(const ocsdError &Error);
71  ocsdError& operator=(const ocsdError *p_err);
72  ocsdError& operator=(const ocsdError &err);
73 
74  void setMessage(const std::string &msg) { m_err_message = msg; };
75  const std::string &getMessage() const { return m_err_message; };
77  const ocsd_err_t getErrorCode() const { return m_error_code; };
78  const ocsd_err_severity_t getErrorSeverity() const { return m_sev; };
79  const ocsd_trc_index_t getErrorIndex() const { return m_idx; };
80  const uint8_t getErrorChanID() const { return m_chan_ID; };
82  static const std::string getErrorString(const ocsdError &error);
84 private:
85  static void appendErrorDetails(std::string &errStr, const ocsdError &error);
86  ocsdError();
88  ocsd_err_t m_error_code;
89  ocsd_err_severity_t m_sev;
90  ocsd_trc_index_t m_idx;
91  uint8_t m_chan_ID;
93  std::string m_err_message;
94 };
95 
97 {
98  this->m_error_code = p_err->getErrorCode();
99  this->m_sev = p_err->getErrorSeverity();
100  this->m_idx = p_err->getErrorIndex();
101  this->m_chan_ID = p_err->getErrorChanID();
102  this->m_err_message = p_err->getMessage();
103  return *this;
104 }
105 
107 {
108  return (*this = &err);
109 }
110 
111 /* class to get data path response values as strings */
113 {
114 public:
115  ocsdDataRespStr(ocsd_datapath_resp_t type) { m_type = type; }
117 
118  const char* getStr();
119 private:
120  ocsd_datapath_resp_t m_type;
121 };
122 
125 #endif // ARM_OCSD_ERROR_H_INCLUDED
126 
127 /* End of File ocsd_error.h */
ocsdDataRespStr(ocsd_datapath_resp_t type)
Definition: ocsd_error.h:115
const char * getStr()
static const std::string getErrorString(const ocsdError &error)
const uint8_t getErrorChanID() const
Definition: ocsd_error.h:80
ocsdError & operator=(const ocsdError *p_err)
Definition: ocsd_error.h:96
ocsdError(const ocsd_err_severity_t sev_type, const ocsd_err_t code)
const ocsd_err_t getErrorCode() const
Definition: ocsd_error.h:77
const ocsd_err_severity_t getErrorSeverity() const
Definition: ocsd_error.h:78
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 & getMessage() const
Definition: ocsd_error.h:75
ocsdError(const ocsd_err_severity_t sev_type, const ocsd_err_t code, const std::string &msg)
const ocsd_trc_index_t getErrorIndex() const
Definition: ocsd_error.h:79
ocsdError(const ocsd_err_severity_t sev_type, const ocsd_err_t code, const ocsd_trc_index_t idx)
void setMessage(const std::string &msg)
Definition: ocsd_error.h:74
ocsdError(const ocsdError &Error)
ocsdError(const ocsdError *pError)
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)
uint32_t ocsd_trc_index_t
Definition: ocsd_if_types.h:67
enum _ocsd_datapath_resp_t ocsd_datapath_resp_t
enum _ocsd_err_severity_t ocsd_err_severity_t
enum _ocsd_err_t ocsd_err_t
OpenCSD : Standard Types used in the library interfaces.