My Project
 All Classes Files Functions Variables Enumerations Enumerator Friends Macros Pages
Debug.h
Go to the documentation of this file.
1 #ifndef GCP_UTIL_DEBUG_H
2 #define GCP_UTIL_DEBUG_H
3 
11 #include <iostream>
12 #include "gcp/util/common/IoLock.h"
13 #include "gcp/util/common/MutexException.h"
14 #include "gcp/util/common/Mutex.h"
15 #include "gcp/util/common/TimeVal.h"
16 #include "gcp/util/common/Directives.h"
17 
18 #if DIR_DEBUG
19 #define DBPRINT(doprint, level, statement) \
20 if(doprint && gcp::util::Debug::debugging(level)) {\
21  gcp::util::TimeVal timeVal; \
22  timeVal.setToCurrentTime(); \
23  gcp::util::IoLock::lockCout(); \
24  std::cout << timeVal \
25  << ": In " \
26  << __PRETTY_FUNCTION__ << ": "\
27  << statement << std::endl; \
28  gcp::util::IoLock::unlockCout(); \
29 }
30 #else
31 #define DBPRINT(doprint, level, statement) {}
32 #endif
33 
34 // Some handy predefines
35 
36 #define DEBUG_CAN gcp::util::Debug::DEBUG1
37 #define DEBUG_CALTERT gcp::util::Debug::DEBUG2
38 #define DEBUG_SIGNAL gcp::util::Debug::DEBUG3
39 #define DEBUG_DELAY gcp::util::Debug::DEBUG4
40 
41 #define DEBUG_PMAC gcp::util::Debug::DEBUG6
42 #define DEBUG_TRACKER gcp::util::Debug::DEBUG7
43 #define DEBUG_IFMOD gcp::util::Debug::DEBUG8
44 
45 namespace gcp {
46  namespace util {
47 
48  class Debug {
49  public:
50 
51  enum Level {
52  DEBUGNONE = 0x0,
53  DEBUG1 = 0x1,
54  DEBUG2 = 0x2,
55  DEBUG3 = 0x4,
56  DEBUG4 = 0x8,
57  DEBUG5 = 0x10,
58  DEBUG6 = 0x20,
59  DEBUG7 = 0x40,
60  DEBUG8 = 0x80,
61  DEBUG9 = 0x100,
62  DEBUG10 = 0x200,
63  DEBUG11 = 0x400,
64  DEBUG12 = 0x800,
65  DEBUG13 = 0x1000,
66  DEBUG14 = 0x2000,
67  DEBUG15 = 0x4000,
68  DEBUG16 = 0x8000,
69  DEBUG17 = 0x10000,
70  DEBUG18 = 0x20000,
71  DEBUG19 = 0x40000,
72  DEBUG20 = 0x80000,
73  DEBUG21 = 0x100000,
74  DEBUG22 = 0x200000,
75  DEBUG23 = 0x400000,
76  DEBUG24 = 0x800000,
77  DEBUG25 = 0x1000000,
78  DEBUG26 = 0x2000000,
79  DEBUG27 = 0x4000000,
80  DEBUG28 = 0x8000000,
81  DEBUG29 = 0x10000000,
82  DEBUG30 = 0x20000000,
83  DEBUG31 = 0x40000000,
84  DEBUG32 = 0x80000000,
85  DEBUGANY = 0xFFFFFFFF
86  };
87 
91  static void setLevel(Level level);
92 
96  static void setLevel(unsigned int);
97 
101  static void addLevel(Level level);
102 
106  static void remLevel(Level level);
107 
111  static bool debugging(Level level = Debug::DEBUGANY);
112 
113  static void lock();
114  static void unlock();
115 
116  private:
117 
121  static Mutex mutex_;
122 
126  static Level level_;
127 
131  Debug();
132 
133  }; // End class Debug
134 
135  }; // End namespace util
136 }; // End namespace gcp
137 
138 #endif // End #ifndef
static void remLevel(Level level)
Definition: Debug.cc:41
Definition: Debug.h:48
static void addLevel(Level level)
Definition: Debug.cc:31
static void setLevel(Level level)
Definition: Debug.cc:23
Definition: Mutex.h:16
static bool debugging(Level level=Debug::DEBUGANY)
Definition: Debug.cc:62