nds2-client - ClientUser  0.16.8
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
nds_iterate_handler.hh
1 #ifndef __NDS_ITERATE_HANDLER_HH__
2 #define __NDS_ITERATE_HANDLER_HH__
3 
4 #include <memory>
5 #include "nds_buffer.hh"
6 
7 namespace NDS
8 {
9  namespace detail
10  {
11  struct conn_p_type;
12 
19  class iterate_handler
20  : public std::enable_shared_from_this< iterate_handler >
21  {
22  public:
23  explicit iterate_handler(
24  std::shared_ptr< NDS::detail::conn_p_type >&& conn_p )
25  : conn_p_{ conn_p }
26  {
27  }
28  virtual bool has_next( ) = 0;
29 
30  virtual void next( buffers_type& ) = 0;
31 
32  void next( );
33 
34  virtual ~iterate_handler( );
35 
36  virtual bool
37  done( )
38  {
39  return !has_next( );
40  }
41 
42  void abort( );
43 
44  std::shared_ptr< buffers_type > cache_;
45 
46  protected:
47  NDS::detail::conn_p_type*
48  conn( )
49  {
50  return conn_p_.get( );
51  }
52 
53  private:
54  std::shared_ptr< NDS::detail::conn_p_type > conn_p_;
55 
56  void invalidate( );
57  };
58  }
59 }
60 
61 #endif // __NDS_ITERATE_HANDLER_HH__