TuttleOFX
1
|
00001 #ifndef _TUTTLE_COMMON_UTILS_GLOBAL_HPP_ 00002 #define _TUTTLE_COMMON_UTILS_GLOBAL_HPP_ 00003 00004 #include "color.hpp" 00005 #include "formatters.hpp" 00006 00007 //////////////////////////////////////////////////////////////////////////////// 00008 // System stuff 00009 #include <tuttle/common/system/system.hpp> 00010 #include <tuttle/common/system/compatibility.hpp> 00011 #include <tuttle/common/system/windows/windows.h> 00012 00013 //////////////////////////////////////////////////////////////////////////////// 00014 // Assert needs to be everywhere 00015 #include <boost/static_assert.hpp> 00016 #include <boost/type_traits.hpp> 00017 #include <boost/current_function.hpp> 00018 00019 //////////////////////////////////////////////////////////////////////////////// 00020 // Define functions to display infos in the console 00021 #include <iostream> 00022 00023 #ifdef NDEBUG 00024 # if defined( _MSC_VER ) 00025 # define TUTTLE_FORCEINLINE __forceinline 00026 # elif defined( __GNUC__ ) && __GNUC__ > 3 00027 # define TUTTLE_FORCEINLINE inline __attribute__ ( ( always_inline ) ) 00028 # else 00029 # define TUTTLE_FORCEINLINE inline 00030 # endif 00031 #else 00032 # define TUTTLE_FORCEINLINE inline 00033 #endif 00034 00035 #define TUTTLE_TRACE BOOST_LOG_TRIVIAL(trace) 00036 #define TUTTLE_INFO BOOST_LOG_TRIVIAL(info) 00037 #define TUTTLE_WARNING BOOST_LOG_TRIVIAL(warning) 00038 #define TUTTLE_ERROR BOOST_LOG_TRIVIAL(error) 00039 #define TUTTLE_FATAL BOOST_LOG_TRIVIAL(fatal) 00040 00041 /** 00042 * @def TUTTLE_INFOS 00043 * @brief informations : filename, line number, function name 00044 **/ 00045 00046 #define TUTTLE_GET_INFOS_FILE "in file: " << __FILE__ << ", line: " << __LINE__ 00047 #define TUTTLE_GET_INFOS_FUNCTION "function: " << BOOST_CURRENT_FUNCTION 00048 #define TUTTLE_GET_INFOS TUTTLE_GET_INFOS_FILE << TUTTLE_GET_INFOS_FUNCTION 00049 00050 #define TUTTLE_GET_VAR( a ) #a << ": " << a 00051 #define TUTTLE_GET_VAR2( a, b ) TUTTLE_GET_VAR ( a ) << ", " << TUTTLE_GET_VAR ( b ) 00052 #define TUTTLE_GET_VAR3( a, b, c ) TUTTLE_GET_VAR ( a ) << ", " << TUTTLE_GET_VAR ( b ) << ", " << TUTTLE_GET_VAR ( c ) 00053 #define TUTTLE_GET_VAR4( a, b, c, d ) TUTTLE_GET_VAR ( a ) << ", " << TUTTLE_GET_VAR ( b ) << ", " << TUTTLE_GET_VAR ( c ) << ", " << TUTTLE_GET_VAR ( d ) 00054 00055 00056 /** 00057 * @param[in] ... : all parameters with an operator << defined 00058 * @brief terminal display 00059 **/ 00060 00061 #define TUTTLE_LOG_TRACE( ... ) BOOST_LOG_TRIVIAL(trace) << __VA_ARGS__ 00062 #define TUTTLE_LOG_INFO( ... ) BOOST_LOG_TRIVIAL(info) << __VA_ARGS__ 00063 #define TUTTLE_LOG_WARNING( ... ) BOOST_LOG_TRIVIAL(warning) << tuttle::common::Color::get()->_yellow << __VA_ARGS__ << tuttle::common::Color::get()->_std 00064 #define TUTTLE_LOG_ERROR( ... ) BOOST_LOG_TRIVIAL(error) << tuttle::common::Color::get()->_error << __VA_ARGS__ << tuttle::common::Color::get()->_std 00065 #define TUTTLE_LOG_FATAL( ... ) BOOST_LOG_TRIVIAL(fatal) << tuttle::common::Color::get()->_error << __VA_ARGS__ << tuttle::common::Color::get()->_std 00066 00067 #define TUTTLE_LOG( MODE, ... ) MODE << __VA_ARGS__ 00068 00069 #define TUTTLE_LOG_VAR( MODE, a ) TUTTLE_LOG( MODE, TUTTLE_GET_VAR ( a ) ) 00070 #define TUTTLE_LOG_VAR2( MODE, a, b ) TUTTLE_LOG( MODE, TUTTLE_GET_VAR2( a, b ) ) 00071 #define TUTTLE_LOG_VAR3( MODE, a, b, c ) TUTTLE_LOG( MODE, TUTTLE_GET_VAR3( a, b, c ) ) 00072 #define TUTTLE_LOG_VAR4( MODE, a, b, c, d ) TUTTLE_LOG( MODE, TUTTLE_GET_VAR4( a, b, c, d ) ) 00073 00074 /** 00075 * @brief terminal information display 00076 **/ 00077 #define TUTTLE_LOG_INFOS TUTTLE_LOG_TRACE( TUTTLE_GET_INFOS_FILE ); TUTTLE_LOG_TRACE( TUTTLE_GET_INFOS_FUNCTION ) 00078 00079 //////////////////////////////////////////////////////////////////////////////// 00080 // Some specifics things to debug or release version 00081 #ifdef DEBUG 00082 #include "debug.hpp" 00083 #else 00084 #include "release.hpp" 00085 #endif 00086 00087 //////////////////////////////////////////////////////////////////////////////// 00088 // TUTTLE_TLOG* defines are used by developers for temporary displays during development stages. 00089 // They are removed in production mode. 00090 #ifndef TUTTLE_PRODUCTION 00091 #define TUTTLE_TLOG TUTTLE_LOG 00092 #define TUTTLE_TLOG_VAR TUTTLE_LOG_VAR 00093 #define TUTTLE_TLOG_VAR2 TUTTLE_LOG_VAR2 00094 #define TUTTLE_TLOG_VAR3 TUTTLE_LOG_VAR3 00095 #define TUTTLE_TLOG_VAR4 TUTTLE_LOG_VAR4 00096 #define TUTTLE_TLOG_INFOS TUTTLE_LOG_INFOS 00097 #define TUTTLE_TLOG_WITHINFOS TUTTLE_LOG_WITHINFOS 00098 #define TUTTLE_TLOG_EXCEPTION TUTTLE_LOG_EXCEPTION 00099 #else 00100 #define TUTTLE_TLOG TUTTLE_LOG_DEBUG 00101 #define TUTTLE_TLOG_VAR TUTTLE_LOG_VAR_DEBUG 00102 #define TUTTLE_TLOG_VAR2 TUTTLE_LOG_VAR2_DEBUG 00103 #define TUTTLE_TLOG_VAR3 TUTTLE_LOG_VAR3_DEBUG 00104 #define TUTTLE_TLOG_VAR4 TUTTLE_LOG_VAR4_DEBUG 00105 #define TUTTLE_TLOG_INFOS TUTTLE_LOG_INFOS_DEBUG 00106 #define TUTTLE_TLOG_WITHINFOS TUTTLE_LOG_WITHINFOS_DEBUG 00107 #define TUTTLE_TLOG_EXCEPTION TUTTLE_LOG_EXCEPTION_DEBUG 00108 #endif 00109 00110 #define TUTTLE_LOG_PLUGIN_NAME_WIDTH 30 00111 00112 #endif