summaryrefslogtreecommitdiffstats
path: root/src/rbd_replay/BufferReader.h
blob: 38a10577401d9480c27df907547a44239cb20a15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#ifndef CEPH_RBD_REPLAY_BUFFER_READER_H
#define CEPH_RBD_REPLAY_BUFFER_READER_H

#include "include/int_types.h"
#include "include/buffer.h"

namespace rbd_replay {

class BufferReader {
public:
  static const size_t DEFAULT_MIN_BYTES = 1<<20;
  static const size_t DEFAULT_MAX_BYTES = 1<<22;

  BufferReader(int fd, size_t min_bytes = DEFAULT_MIN_BYTES,
               size_t max_bytes = DEFAULT_MAX_BYTES);

  int fetch(bufferlist::const_iterator **it);

private:
  int m_fd;
  size_t m_min_bytes;
  size_t m_max_bytes;
  bufferlist m_bl;
  bufferlist::const_iterator m_bl_it;
  bool m_eof_reached;

};

} // namespace rbd_replay

#endif // CEPH_RBD_REPLAY_BUFFER_READER_H