Belle II Software  release-08-01-10
Debug.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #include <iostream>
10 #include "trg/trg/Debug.h"
11 
12 using namespace std;
13 
14 namespace Belle2 {
20  vector<string> TRGDebug::_stages;
21  int TRGDebug::_level = 0;
22 
23  void
24  TRGDebug::enterStage(const string& name)
25  {
26  if (_level)
27  cout << tab() << "--> ";
28  _stages.push_back(name);
29  if (_level)
30  cout << name << endl;
31  }
32 
33  void
34  TRGDebug::leaveStage(const string& name)
35  {
36  if (name != _stages.back()) {
37  cout << "TRGDebug !!! given stage name(" << name << ") doesn't match"
38  << " to expected stage name(" << _stages.back() << endl;
39  return;
40  }
41  _stages.pop_back();
42  if (_level)
43  cout << tab() << "<-- " << name << endl;
44  }
45 
46  string
47  TRGDebug::tab(void)
48  {
49  string t;
50  const unsigned n = _stages.size();
51  for (unsigned i = 0; i < n; i++)
52  t += " ";
53  return t;
54  }
55 
56  string
57  TRGDebug::tab(int extra)
58  {
59  string t = tab();
60  if (extra > 0)
61  for (unsigned i = 0; i < unsigned(extra); i++)
62  t += " ";
63  return t;
64  }
65 
66  int
67  TRGDebug::level(void)
68  {
69  return _level;
70  }
71 
72  int
73  TRGDebug::level(int a, bool b)
74  {
75  if (! b)
76  return _level = a;
77  else
78  return _level = a;
79  }
80 
82 } // namespace Belle2
83 
Abstract base class for different kinds of events.