EUDAQ
 All Classes Namespaces Files Functions Variables Pages
BufferSerializer.hh
1 #ifndef EUDAQ_INCLUDED_BufferSerializer
2 #define EUDAQ_INCLUDED_BufferSerializer
3 
4 #include <deque>
5 #include <algorithm>
6 #include <iostream>
7 #include "eudaq/Serializer.hh"
8 #include "eudaq/Exception.hh"
9 
10 namespace eudaq {
11 
12  class BufferSerializer : public Serializer,
13  public Deserializer,
14  public Serializable {
15  public:
16  BufferSerializer() : m_offset(0) {}
17  template <typename InIt>
18  BufferSerializer(InIt first, InIt last)
19  : m_data(first, last), m_offset(0) {}
21  void clear() {
22  m_data.clear();
23  m_offset = 0;
24  }
25  const unsigned char &operator[](size_t i) const { return m_data[i]; }
26  size_t size() const { return m_data.size(); }
27  virtual bool HasData() { return m_data.size() != 0; }
28  virtual void Serialize(Serializer &) const;
29 
30  private:
31  virtual void Serialize(const unsigned char *data, size_t len);
32  virtual void Deserialize(unsigned char *data, size_t len);
33  std::vector<unsigned char> m_data;
34  size_t m_offset;
35  };
36 }
37 
38 #endif // EUDAQ_INCLUDED_BufferSerializer
Definition: Serializer.hh:156
Definition: Serializable.hh:13
Definition: Serializer.hh:19
Definition: BufferSerializer.hh:12