fast pQCD calculations for hadron-induced processes
speaker.h
1 // Author: Daniel Britzger
2 // DESY, 06/08/2012
3 
4 #ifndef SPEAKER_H_
5 #define SPEAKER_H_
6 
7 #include <string>
8 #include <iostream>
9 #include <map>
10 
11 namespace say {
12  enum Verbosity {DEBUG=-1000, MANUAL=2, INFO=0, WARNING=1, ERROR=2, SILENT=1000};
13 }
14 
15 class speaker {
16 public:
17  speaker(std::string prefix="",say::Verbosity volume=say::INFO,bool err=false,bool quiet=false);
18  speaker(const speaker& spk);
19  ~speaker();
20  //speaker(const speaker& spk) : weg(0) {;};
21  const speaker& operator= (const speaker& other);
22  std::ostream& operator[](const std::string& fct) const ;
23  const speaker& operator+ (const std::string& fct) const {
24  return this->prefix(fct);
25  }
26  const speaker& prefix(const std::string& fct) const ;
27  std::ostream& operator()(const std::string& fct) const ;
28 
29  template<typename T> std::ostream& operator<< (const T& arg) const {
30  if (fquiet) return *weg;
31  else {
32  if (errs && fe2cerr) return std::cerr<<pref<<arg;
33  else return std::cout<<pref<<arg;
34  }
35  }
36 #ifndef SWIG
37  std::ostream& operator>> (const std::string& arg) const ;
38 #endif
39  std::ostream& print(const std::string& mes) const ;
40  void DoSpeak(bool loud) {
41  fquiet=!loud;
42  };
43  bool GetSpeak() const {
44  return !fquiet;
45  };
46  void SetPrefix(std::string prefix) {
47  pref=prefix;
48  };
49  std::string GetPrefix() const {
50  return pref;
51  };
52  void SetClassName(std::string classname) {
53  cn=classname;
54  };
55  std::string GetClassName(void) const {
56  return cn;
57  };
58  say::Verbosity GetVolume(void) const {
59  return fvol;
60  };
61  void SetVolume(say::Verbosity volume) {
62  fvol=volume;
63  };
64  static int SetGlobalVerbosity(say::Verbosity volume);
65  static void ErrorToErrStream(bool ToCerr) {
66  fe2cerr=ToCerr;
67  };
68 
69 protected:
70  //std::ostream weg;
71  static std::ostream* weg;
72  bool fquiet;
73  std::string pref;
74  bool errs;
75  say::Verbosity fvol;
76  unsigned long fii;
77  static unsigned long ct;
78  static bool fe2cerr;
79  static say::Verbosity fverb;
80  static std::map<unsigned long,speaker*>* list;
81  std::string cn;
82 };
83 
84 namespace say {
85  extern speaker debug;
86  extern speaker man; //
87  extern speaker info;
88  extern speaker warn;
89  extern speaker error;
90  extern speaker shout; // same as error but streamed to cout
91  extern speaker yell; // same as error but streamed to cout without prefix
92  extern int SetGlobalVerbosity(Verbosity verbosity);
93 }
94 
95 
96 class PrimalScream {
97 public:
98  PrimalScream(std::string classname);//,std::string prefix="");
99  void SetClassName(const std::string classname );
100  void SetVerbosity(say::Verbosity volume);
101  speaker debug;
102  speaker man;
103  speaker info;
104  speaker warn;
105  speaker error;
106  speaker shout;
107  speaker yell;
108 private:
109  std::string ___cn;
110 };
111 
112 #endif //SPEAKER_H_
Definition: speaker.h:96
Definition: speaker.h:11
Definition: speaker.h:15