EUDAQ
 All Classes Namespaces Files Functions Variables Pages
Status.hh
1 #ifndef EUDAQ_INCLUDED_Status
2 #define EUDAQ_INCLUDED_Status
3 
4 #include "eudaq/Serializable.hh"
5 #include <string>
6 #include <map>
7 #include <ostream>
8 #include "eudaq/Platform.hh"
9 
10 namespace eudaq {
11 
12  class Serializer;
13  class Deserializer;
14 
15  class DLLEXPORT Status : public Serializable {
16  public:
17  enum Level {
18  LVL_DEBUG,
19  LVL_OK,
20  LVL_THROW,
21  LVL_EXTRA,
22  LVL_INFO,
23  LVL_WARN,
24  LVL_ERROR,
25  LVL_USER,
26  LVL_BUSY,
27  LVL_NONE // The last value, any additions should go before this
28  };
29 
30  Status(int level = LVL_OK, const std::string &msg = "")
31  : m_level(level), m_msg(msg) {}
33 
34  virtual void Serialize(Serializer &) const;
35 
36  Status &SetTag(const std::string &name, const std::string &val);
37  std::string GetTag(const std::string &name,
38  const std::string &def = "") const;
39 
40  static std::string Level2String(int level);
41 
42  static int String2Level(const std::string &);
43 
44  virtual ~Status() {}
45  virtual void print(std::ostream &) const;
46 
47  int GetLevel() const { return m_level; }
48 
49 
50  protected:
51  typedef std::map<std::string, std::string> map_t;
52 
53  int m_level;
54 
55  std::string m_msg;
56  map_t m_tags;
57  };
58 
59  inline std::ostream &operator<<(std::ostream &os, const Status &s) {
60  s.print(os);
61  return os;
62  }
63 }
64 
65 #endif // EUDAQ_INCLUDED_Status
Definition: Serializer.hh:156
Definition: Serializable.hh:13
Definition: Status.hh:15
map_t m_tags
Metadata tags in (name=value) pairs of strings.
Definition: Status.hh:56
Definition: Serializer.hh:19