EUDAQ
 All Classes Namespaces Files Functions Variables Pages
ConnectionState.hh
1 #ifndef EUDAQ_INCLUDED_ConnectionState
2 #define EUDAQ_INCLUDED_ConnectionState
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 ConnectionState : public Serializable {
16  public:
17  enum State {
18  STATE_UNINIT,
19  STATE_UNCONF,
20  STATE_CONF,
21  STATE_RUNNING,
22  STATE_ERROR
23  };
24 
25  ConnectionState(const std::string &msg = "",int state = STATE_UNINIT)
26  :m_msg(msg), m_state(state) {}
28 
29  virtual void Serialize(Serializer &) const;
30 
31  ConnectionState &SetTag(const std::string &name, const std::string &val);
32  std::string GetTag(const std::string &name,
33  const std::string &def = "") const;
34 
35  static std::string State2String(int state);
36 
37  static int String2State(const std::string &);
38 
39  virtual ~ConnectionState() {}
40  virtual void print(std::ostream &) const;
41 
42  int GetState() const { return m_state; }
43 
44  bool isBusy(){return isbusy;}
45 
46 
47  protected:
48  typedef std::map<std::string, std::string> map_t;
49 
50  bool isbusy=false;
51  int m_state;
52 
53  std::string m_msg;
54  map_t m_tags;
55  };
56 
57  inline std::ostream &operator<<(std::ostream &os, const ConnectionState &s) {
58  s.print(os);
59  return os;
60  }
61 }
62 
63 #endif // EUDAQ_INCLUDED_ConnectionState
Definition: Serializer.hh:156
map_t m_tags
Metadata tags in (name=value) pairs of strings.
Definition: ConnectionState.hh:54
Definition: Serializable.hh:13
Definition: ConnectionState.hh:15
Definition: Serializer.hh:19