frag_base.hpp 826 B

1234567891011121314151617181920212223242526272829303132333435
  1. #ifndef DEPTHGUIDE_FRAG_BASE_HPP
  2. #define DEPTHGUIDE_FRAG_BASE_HPP
  3. #include "../impl_utility.hpp"
  4. #include <boost/signals2.hpp>
  5. class frag_base : public data_channel {
  6. public:
  7. struct create_config {
  8. data_channel_type low_channel;
  9. size_t queue_size = 1; // max incomplete messages in queue, >= 1
  10. };
  11. explicit frag_base(create_config conf) {
  12. low = std::move(conf.low_channel);
  13. q_size = conf.queue_size;
  14. low->set_recv_func([this](auto data) { append_data(data); });
  15. }
  16. size_t header_size() const override { return 0; }
  17. using signal_type = boost::signals2::signal<void()>;
  18. signal_type sig_msg_loss;
  19. protected:
  20. data_channel_type low;
  21. size_t q_size = 0;
  22. virtual void append_data(const data_type &data) = 0;
  23. };
  24. #endif //DEPTHGUIDE_FRAG_BASE_HPP