00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _OPENRAWPP_DEBUG_H_
00023 #define _OPENRAWPP_DEBUG_H_
00024
00025 #include <string>
00026 #include <vector>
00027 #include <iostream>
00028 #include <algorithm>
00029 #include <boost/bind.hpp>
00030
00031 #include <libopenraw/debug.h>
00032
00033 namespace Debug {
00034
00035
00037 class Trace
00038 {
00039 public:
00040
00041 Trace(debug_level level)
00042 : m_level(level)
00043 {
00044 }
00045 Trace & operator<<(int i);
00046 Trace & operator<<(const char * s);
00047 Trace & operator<<(void *);
00048 Trace & operator<<(const std::string & s);
00049
00050 template <class T>
00051 Trace & operator<<(const std::vector<T> & v);
00052
00053 static void setDebugLevel(debug_level lvl);
00054 private:
00055 static void print(int i);
00056 static int debugLevel;
00057 int m_level;
00058 };
00059
00060
00061 template <class T>
00062 Trace & Trace::operator<<(const std::vector<T> & v)
00063 {
00064 if (m_level <= debugLevel) {
00065 std::for_each(v.begin(), v.end(), boost::bind(&print, _1));
00066 }
00067 return *this;
00068 }
00069
00070
00071 }
00072
00073 #endif