Belle II Software  release-05-02-19
Debug.cc
1 //-----------------------------------------------------------------------------
2 // $Id$
3 //-----------------------------------------------------------------------------
4 // Filename : Debug.cc
5 // Section : TRG
6 // Owner : Yoshihito Iwasaki
7 // Email : yoshihito.iwasaki@kek.jp
8 //-----------------------------------------------------------------------------
9 // Description : Debug utility functions
10 //-----------------------------------------------------------------------------
11 // $Log$
12 //-----------------------------------------------------------------------------
13 
14 #include <iostream>
15 #include "trg/trg/Debug.h"
16 
17 using namespace std;
18 
19 namespace Belle2 {
25  vector<string> TRGDebug::_stages;
26  int TRGDebug::_level = 0;
27 
28  void
29  TRGDebug::enterStage(const string& name)
30  {
31  if (_level)
32  cout << tab() << "--> ";
33  _stages.push_back(name);
34  if (_level)
35  cout << name << endl;
36  }
37 
38  void
39  TRGDebug::leaveStage(const string& name)
40  {
41  if (name != _stages.back()) {
42  cout << "TRGDebug !!! given stage name(" << name << ") doesn't match"
43  << " to expected stage name(" << _stages.back() << endl;
44  return;
45  }
46  _stages.pop_back();
47  if (_level)
48  cout << tab() << "<-- " << name << endl;
49  }
50 
51  string
52  TRGDebug::tab(void)
53  {
54  string t;
55  const unsigned n = _stages.size();
56  for (unsigned i = 0; i < n; i++)
57  t += " ";
58  return t;
59  }
60 
61  string
62  TRGDebug::tab(int extra)
63  {
64  string t = tab();
65  if (extra > 0)
66  for (unsigned i = 0; i < unsigned(extra); i++)
67  t += " ";
68  return t;
69  }
70 
71  int
72  TRGDebug::level(void)
73  {
74  return _level;
75  }
76 
77  int
78  TRGDebug::level(int a, bool b)
79  {
80  if (! b)
81  return _level = a;
82  else
83  return _level = a;
84  }
85 
87 } // namespace Belle2
88 
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19