Bringing C++ iterators to the iterate interface.
There are several objects involved in the iteration of data.
-
The conn_p_type. This holds the actual network socket, and is the means of starting an iteration (via the connection::iterate call). In order to break cycles this contains only a weak ptr to the interate handler.
-
The iterate_handler. This used to be a local variable on the conn_p_type. It is now the coordination point of iteration. Users refer to it via a opaque type called a 'data_iterable' which creates iterators and knows how to link things to the iterate_handler. This object is specialized for each iteration type (gap handling, fast online, ...). It has a shared ptr link to the conn_p_type so it can access the network socket, and inform it when the iteration completes. It also maintains a copy of the 'current' data block, via a shared ptr.
-
The iterators. These are created by the data_iterable, and reference the iterate_handler. They hold a shared_ptr to the iterate_handler and to a cached copy of the current data block.
Iterate now returns a shared_ptr to a NDS::buffers_type. This is needed to match the semantics of an input iterator while also not holding the entire stream of data in memory at once.
As data from an iteration is held by shared_ptrs, it is alive as long as any iterator or iterator_handler object references it. So it is important that iteration sequences are completed, and iterators are advanced/assigned to the end() sentinal value.
Change iterate to return a interable/data_stream object which gives a begin/end pair. This object is in charge of managing iteration of data.
Iterating data can be done w/o a try/catch block.
Removing next/has_next from connection.
Moving daq_accessor to the detail namespace.
Removing the daq_accessor friend requirement in connection.
Updating how the internal nds1 channel cache works with daq_accessors.
Move connection::p_type to NDS::detail::conn_p_type as it needs to be named by other internal types. Change the internal reference from a unique_ptr to a shared_ptr, as multiple items need to track each other for lifetime issues.