Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
KM3NeT_Debug.h
Go to the documentation of this file.
1 #ifndef KM3NET_DEBUG_H_
2 #define KM3NET_DEBUG_H_
3 
4 #include <stdlib.h>
5 #include <iostream>
6 #include <mutex>
7 #include <fstream>
8 
9 
10 #define DBG_MSG (*KM3NeT_Debug::get())
11 
12 
13 /**
14  * \author fsimeone
15  */
16 
18 {
19 public:
20 
21  static KM3NeT_Debug* get()
22  {
23  if (singleton_ == NULL) singleton_ = new KM3NeT_Debug();
24  return singleton_;
25  }
26 
27  static void kill()
28  {
29  if (singleton_ != NULL)
30  {
31  delete singleton_;
32  singleton_ = NULL;
33  }
34  }
35 
36  template <class T>
37  KM3NeT_Debug& operator<<(const T &s)
38  {
39  std::lock_guard<std::mutex> lock(mtx_);
40  std::cerr<<s;
41  return *this;
42  }
43 
44 private:
45 
46  KM3NeT_Debug();
47  virtual ~KM3NeT_Debug();
48 
50  std::mutex mtx_;
51 };
52 
53 #endif /* KM3NET_DEBUG_H_ */
54 
static void kill()
Definition: KM3NeT_Debug.h:27
KM3NeT_Debug & operator<<(const T &s)
Definition: KM3NeT_Debug.h:37
static KM3NeT_Debug * singleton_
Definition: KM3NeT_Debug.h:49
std::mutex mtx_
Definition: KM3NeT_Debug.h:50
virtual ~KM3NeT_Debug()