/// \file ExceptionLevel.hh /* * * ExceptionLevel.hh header template generated by fclass * Creation date : mar. d�c. 24 2013 * * This file is part of XXX libraries. * * XXX is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * based upon these libraries are permitted. Any copy of these libraries * must include this copyright notice. * * XXX is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with XXX. If not, see . * * @author : Remi Ete * @version * @copyright * * */ #ifndef EXCEPTIONLEVEL_HH #define EXCEPTIONLEVEL_HH // std #include #include namespace lcamore { /** * @brief ExceptionType enum */ enum ExceptionType { eRuntime, eFatal, eInvalidParameter, eBadPointer, eMySQLError, eMemberNotImplemented, eNotFound }; /** * @brief ExceptionLevel class.
* Handles the exception level with a functor */ class ExceptionLevel { public: /** * @brief Ctor.
* Builds the exception type map */ ExceptionLevel() { _exceptionMap[ eRuntime ] = "RUNTIME"; _exceptionMap[ eFatal ] = "FATAL"; _exceptionMap[ eInvalidParameter ] = "INVALID_PARAMETER"; _exceptionMap[ eBadPointer ] = "BAD_POINTER"; _exceptionMap[ eMySQLError ] = "MYSQL_ERROR"; _exceptionMap[ eMemberNotImplemented ] = "MEMBER_NOT_IMPLEMENTED"; _exceptionMap[ eNotFound ] = "NOT_FOUND"; } /** * @brief Dtor */ ~ExceptionLevel() { _exceptionMap.clear(); } /** * @brief Functor to return the exception type into string */ std::string operator() ( ExceptionType eType ) { return _exceptionMap[ eType ]; } protected: std::map< ExceptionType , std::string > _exceptionMap; ///< The exception map for ExceptionType to std::string conversion }; } #endif // EXCEPTIONLEVEL_HH