~ubuntu-branches/ubuntu/utopic/libopenraw/utopic

« back to all changes in this revision

Viewing changes to lib/debug.h

  • Committer: Package Import Robot
  • Author(s): David Paleino
  • Date: 2012-03-10 08:57:09 UTC
  • mto: (7.1.1 sid)
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: package-import@ubuntu.com-20120310085709-zuimi0xsth01nfkc
Tags: upstream-0.0.9
ImportĀ upstreamĀ versionĀ 0.0.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * libopenraw - debug.h
3
 
 *
4
 
 * Copyright (C) 2006-2007 Hubert Figuiere
5
 
 *
6
 
 * This library is free software: you can redistribute it and/or
7
 
 * modify it under the terms of the GNU Lesser General Public License
8
 
 * as published by the Free Software Foundation, either version 3 of
9
 
 * the License, or (at your option) any later version.
10
 
 *
11
 
 * This library is distributed in the hope that it will be useful,
12
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 
 * Lesser General Public License for more details.
15
 
 *
16
 
 * You should have received a copy of the GNU Lesser General Public
17
 
 * License along with this library.  If not, see
18
 
 * <http://www.gnu.org/licenses/>.
19
 
 */
20
 
 
21
 
 
22
 
#ifndef _OPENRAWPP_DEBUG_H_
23
 
#define _OPENRAWPP_DEBUG_H_
24
 
 
25
 
#include <string>
26
 
#include <vector>
27
 
#include <iostream>
28
 
#include <algorithm>
29
 
#include <boost/bind.hpp>
30
 
 
31
 
#include <libopenraw/debug.h>
32
 
 
33
 
namespace Debug {
34
 
 
35
 
        
36
 
        /** a basic Trace class for debug */
37
 
        class Trace 
38
 
        {
39
 
        public:
40
 
                
41
 
                Trace(debug_level level)
42
 
                        : m_level(level)
43
 
                        {
44
 
                        }
45
 
                Trace & operator<<(int i);
46
 
                Trace & operator<<(const char * s);
47
 
                Trace & operator<<(void *);
48
 
                Trace & operator<<(const std::string & s);
49
 
 
50
 
                template <class T>
51
 
                Trace & operator<<(const std::vector<T> & v);
52
 
 
53
 
                static void setDebugLevel(debug_level lvl);
54
 
        private:
55
 
                static void print(int i);
56
 
                static int debugLevel; // global debug level
57
 
                int m_level;
58
 
        };
59
 
 
60
 
 
61
 
        template <class T>
62
 
        Trace & Trace::operator<<(const std::vector<T> & v)
63
 
        {
64
 
                if (m_level <= debugLevel) {
65
 
                        std::for_each(v.begin(), v.end(), boost::bind(&print, _1));
66
 
                }
67
 
                return *this;
68
 
        }
69
 
 
70
 
        
71
 
}
72
 
 
73
 
#endif