00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef ERS_CONTEXT_
00011 #define ERS_CONTEXT_
00012
00017 #include <string>
00018 #include <vector>
00019
00020 namespace ers {
00021
00022
00042 class Context {
00043 protected:
00044 static Context* empty_instance ;
00045 static std::string s_host_type ;
00046 static std::vector<std::string> default_qualifiers ;
00047 std::string m_file_name ;
00048 int m_line_number ;
00049 std::string m_function_name ;
00050 std::string m_compiler_name ;
00051 std::string m_compiler_version ;
00052 std::string m_compilation_date ;
00053 std::string m_compilation_time ;
00054 std::string m_package_name ;
00055 mutable std::string m_compiler ;
00056 mutable std::string m_position ;
00057 mutable std::string m_compilation ;
00058 std::vector<std::string> m_stack_frames ;
00059 static void build_host_type() ;
00060 public:
00061 static const Context* empty() ;
00062 static std::string & host_type() ;
00063 static int debug_level();
00064 static void add_qualifier(const std::string &qualif) ;
00065 Context(const std::string &filename, int line_number, const std::string &function_name,
00066 const std::string &compiler_name, const std::string &compiler_version,
00067 const std::string &compilation_time, const std::string &compilation_date, const std::string &package) ;
00068 const std::string & file() const throw();
00069 int line() const throw() ;
00070 const std::string & function() const throw() ;
00071 const std::string & position() const ;
00072 const std::string & compiler() const ;
00073 const std::string & compilation() const ;
00074 const std::string & package_name() const throw();
00075 int stack_frames() const throw() ;
00076 const std::string &stack_frame(int i) const ;
00077 std::vector<std::string> qualifiers() const throw() ;
00078 } ;
00079
00080 }
00081
00085 #ifdef __GNUC__
00086 #define COMPILER_NAME "gcc"
00087 #endif
00088
00089 #ifdef __INTEL_COMPILER
00090 #define COMPILER_NAME "icc"
00091 #endif
00092
00093 #ifndef COMPILER_NAME
00094 #define COMPILER_NAME "unknown"
00095 #endif
00096
00097 #ifndef __VERSION__
00098 #define __VERSION__ "unknown"
00099 #endif
00100
00101 #ifdef TDAQ_PACKAGE_NAME
00102 #define ERS_PACK TDAQ_PACKAGE_NAME
00103 #else
00104 #define ERS_PACK ""
00105 #endif
00106
00108 #define ERS_EMPTY *(ers::Context::empty())
00109
00115 #ifndef N_DEBUG
00116 #ifdef __GNUC__
00117 #define ERS_HERE ers::Context(__FILE__,__LINE__,__PRETTY_FUNCTION__,COMPILER_NAME,__VERSION__,__TIME__,__DATE__,ERS_PACK)
00118 #else
00119 #define ERS_HERE ers::Context(__FILE__,__LINE__,__func__,COMPILER_NAME,__VERSION__,__TIME__,__DATE__,ERS_PACK)
00120 #endif
00121 #else
00122 #define ERS_HERE ERS_EMPTY
00123 #endif
00124
00125
00126
00127 #endif
00128