/* * * * * * * * * * * * TODO : IMplement it as singleton */ #ifndef _ERRORHANDLIG_H_ #define _ERRORHANDLIG_H_ #include #include #include #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 errorLookup; int getLookUpIndex(int errNo); // If error number exists returns the index otherwise -1 }; #endif // _ERRORHANDLIG_H_