[118] | 1 | #ifndef Morpheo_Debug_type_h |
---|
| 2 | #define Morpheo_Debug_type_h |
---|
| 3 | |
---|
| 4 | /* |
---|
| 5 | * $Id: Debug_type.h 138 2010-05-12 17:34:01Z rosiere $ |
---|
| 6 | * |
---|
| 7 | * [ Description ] |
---|
| 8 | * |
---|
| 9 | * Debug's Level : |
---|
| 10 | * - None : print elementary information |
---|
| 11 | * - Info : print basic information |
---|
| 12 | * - Trace : trace internal variable |
---|
| 13 | * - Func : trace call and return function |
---|
| 14 | * - All : print all information |
---|
| 15 | */ |
---|
| 16 | |
---|
[138] | 17 | #include "Common/include/ToString.h" |
---|
| 18 | #include "Common/include/FromString.h" |
---|
[118] | 19 | |
---|
[138] | 20 | |
---|
[118] | 21 | namespace morpheo { |
---|
| 22 | |
---|
| 23 | typedef enum |
---|
| 24 | { |
---|
| 25 | DEBUG_NONE , |
---|
| 26 | DEBUG_INFO , |
---|
| 27 | DEBUG_TRACE, |
---|
| 28 | DEBUG_FUNC , |
---|
| 29 | DEBUG_ALL |
---|
| 30 | } debug_verbosity_t; |
---|
| 31 | |
---|
[138] | 32 | template<> inline std::string toString<debug_verbosity_t>(const debug_verbosity_t& x) |
---|
| 33 | { |
---|
| 34 | switch (x) |
---|
| 35 | { |
---|
| 36 | case DEBUG_NONE : return "debug_none" ; break; |
---|
| 37 | case DEBUG_INFO : return "debug_info" ; break; |
---|
| 38 | case DEBUG_TRACE : return "debug_trace"; break; |
---|
| 39 | case DEBUG_FUNC : return "debug_func" ; break; |
---|
| 40 | case DEBUG_ALL : return "debug_all" ; break; |
---|
| 41 | default : return "" ; break; |
---|
| 42 | } |
---|
| 43 | }; |
---|
| 44 | |
---|
| 45 | template<> inline debug_verbosity_t fromString<debug_verbosity_t>(const std::string& x) |
---|
| 46 | { |
---|
| 47 | if ((x.compare(toString(static_cast<uint32_t>(DEBUG_NONE ))) == 0) or |
---|
| 48 | (x.compare(toString( DEBUG_NONE )) == 0)) |
---|
| 49 | return DEBUG_NONE; |
---|
| 50 | |
---|
| 51 | if ((x.compare(toString(static_cast<uint32_t>(DEBUG_INFO ))) == 0) or |
---|
| 52 | (x.compare(toString( DEBUG_INFO )) == 0)) |
---|
| 53 | return DEBUG_INFO; |
---|
| 54 | |
---|
| 55 | if ((x.compare(toString(static_cast<uint32_t>(DEBUG_TRACE))) == 0) or |
---|
| 56 | (x.compare(toString( DEBUG_TRACE )) == 0)) |
---|
| 57 | return DEBUG_TRACE; |
---|
| 58 | |
---|
| 59 | if ((x.compare(toString(static_cast<uint32_t>(DEBUG_FUNC ))) == 0) or |
---|
| 60 | (x.compare(toString( DEBUG_FUNC )) == 0)) |
---|
| 61 | return DEBUG_FUNC; |
---|
| 62 | |
---|
| 63 | if ((x.compare(toString(static_cast<uint32_t>(DEBUG_ALL ))) == 0) or |
---|
| 64 | (x.compare(toString( DEBUG_ALL )) == 0)) |
---|
| 65 | return DEBUG_ALL; |
---|
| 66 | |
---|
| 67 | #ifdef DEBUG |
---|
| 68 | return DEBUG; |
---|
| 69 | #else |
---|
| 70 | return DEBUG_NONE ; |
---|
| 71 | #endif |
---|
| 72 | }; |
---|
| 73 | |
---|
[118] | 74 | }; // end namespace morpheo |
---|
| 75 | #endif |
---|