You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
781 B
51 lines
781 B
/*
|
|
*
|
|
*
|
|
*
|
|
*
|
|
*
|
|
*
|
|
*
|
|
*
|
|
*
|
|
*
|
|
* TODO : IMplement it as singleton
|
|
*/
|
|
|
|
|
|
#ifndef _ERRORHANDLIG_H_
|
|
#define _ERRORHANDLIG_H_
|
|
|
|
#include <iostream>
|
|
#include <array>
|
|
#include <string>
|
|
|
|
#define MAX_NUMBER_OF_ERRORS 255
|
|
|
|
|
|
/*
|
|
* Singleton Pattern based on : https://stackoverflow.com/questions/1008019/c-singleton-design-pattern/1008289
|
|
*
|
|
*/
|
|
|
|
class ErrorHandler
|
|
{
|
|
public:
|
|
ErrorHandler();
|
|
void addNewError(const int& no, const std::string& message);
|
|
void handleError(int no);
|
|
private:
|
|
|
|
struct error_t {
|
|
int errNo;
|
|
std::string errMessage;
|
|
};
|
|
|
|
unsigned int emptyIndex;
|
|
std::array <error_t,MAX_NUMBER_OF_ERRORS> errorLookup;
|
|
|
|
int getLookUpIndex(int errNo); // If error number exists returns the index otherwise -1
|
|
};
|
|
|
|
#endif // _ERRORHANDLIG_H_
|