uTL
micro Template library
utl::inbuf_dev< impl_t, data_t, streamsize > Class Template Reference

Abstract base class for input buffered devices. More...

#include <inbuf_dev.h>

Public Types

using type = inbuf_dev_t
 Export type as identity meta-function. More...
 
using data_type = data_t
 
using pointer_type = data_t *
 

Public Member Functions

Public Get interface
size_t in_avail ()
 
size_t get (data_t &data)
 The base get interface. This function should read a single data_t object from device usually in non-blocking mode. More...
 
size_t get (data_t *data, size_t n)
 Old stile get functionality using free standing data_t*. This function should return a stream of data from device. More...
 
Stream operator >> interface
template<typename _Dst_t >
inbuf_dev_toperator>> (_Dst_t &dst)
 Template operator >> implementation for for all by value/ref parameters. More...
 
template<typename _Dst_t >
inbuf_dev_toperator>> (_Dst_t *dst)=delete
 Specialization to disallow pointer types as destination. More...
 
inbuf_dev_toperator>> (data_t &dst)
 Overload for single data_t object. More...
 
iterator end () noexcept
 
const_iterator end () const noexcept
 
const_iterator cend () const noexcept
 

Protected Member Functions

Constructor / Destructor
 ~inbuf_dev ()=default
 Allow destructor from derived only. More...
 
 inbuf_dev ()=default
 A default constructor from derived only. More...
 
 inbuf_dev (const inbuf_dev_t &)=delete
 No copies. More...
 
inbuf_dev_toperator= (const inbuf_dev_t &)=delete
 

Private Types

using inbuf_dev_t = inbuf_dev< impl_t, data_t, streamsize >
 class type syntactic sugar More...
 

Private Member Functions

 _CRTP_IMPL (impl_t)
 
Common input device interface requirements
size_t in_avail_ ()
 
size_t get_ (data_t &data)
 
size_t get_ (data_t *data, size_t n)
 

STL-like Input iterator interface

using iterator = indev_it< inbuf_dev_t, data_t *, streamsize >
 Iterator. More...
 
using const_iterator = indev_it< inbuf_dev_t, const data_t *, streamsize >
 Const iterator. More...
 
iterator begin () noexcept
 .begin implementation More...
 
const_iterator begin () const noexcept
 
const_iterator cbegin () const noexcept
 

Detailed Description

template<typename impl_t, typename data_t, size_t streamsize = 0>
class utl::inbuf_dev< impl_t, data_t, streamsize >

Abstract base class for input buffered devices.

Template base class for buffered input buffered devices. using CRTP

This class force a common interface for input, buffered devices. By using this common interface the class implements

  • Stream-like extracting operator
  • Input iterator
  • Const input iterator to inherit to implementation.
Parameters
impl_tThe CRTP type (the derived/implementation class typename).
data_tThe devices base type of data
streamsizeThe number of elements to indicate eos.
  • None or 0 Stream only. No iterator as begin() now equals end().

Definition at line 55 of file inbuf_dev.h.

Member Typedef Documentation

◆ const_iterator

template<typename impl_t , typename data_t , size_t streamsize = 0>
using utl::inbuf_dev< impl_t, data_t, streamsize >::const_iterator = indev_it <inbuf_dev_t, const data_t*, streamsize>

Const iterator.

Definition at line 162 of file inbuf_dev.h.

◆ data_type

template<typename impl_t , typename data_t , size_t streamsize = 0>
using utl::inbuf_dev< impl_t, data_t, streamsize >::data_type = data_t

Export types as input device concept demands

Definition at line 62 of file inbuf_dev.h.

◆ inbuf_dev_t

template<typename impl_t , typename data_t , size_t streamsize = 0>
using utl::inbuf_dev< impl_t, data_t, streamsize >::inbuf_dev_t = inbuf_dev <impl_t, data_t, streamsize>
private

class type syntactic sugar

Definition at line 57 of file inbuf_dev.h.

◆ iterator

template<typename impl_t , typename data_t , size_t streamsize = 0>
using utl::inbuf_dev< impl_t, data_t, streamsize >::iterator = indev_it <inbuf_dev_t, data_t*, streamsize>

Iterator.

Definition at line 161 of file inbuf_dev.h.

◆ pointer_type

template<typename impl_t , typename data_t , size_t streamsize = 0>
using utl::inbuf_dev< impl_t, data_t, streamsize >::pointer_type = data_t*

Definition at line 63 of file inbuf_dev.h.

◆ type

template<typename impl_t , typename data_t , size_t streamsize = 0>
using utl::inbuf_dev< impl_t, data_t, streamsize >::type = inbuf_dev_t

Export type as identity meta-function.

Definition at line 65 of file inbuf_dev.h.

Constructor & Destructor Documentation

◆ ~inbuf_dev()

template<typename impl_t , typename data_t , size_t streamsize = 0>
utl::inbuf_dev< impl_t, data_t, streamsize >::~inbuf_dev ( )
protecteddefault

Allow destructor from derived only.

◆ inbuf_dev() [1/2]

template<typename impl_t , typename data_t , size_t streamsize = 0>
utl::inbuf_dev< impl_t, data_t, streamsize >::inbuf_dev ( )
protecteddefault

A default constructor from derived only.

◆ inbuf_dev() [2/2]

template<typename impl_t , typename data_t , size_t streamsize = 0>
utl::inbuf_dev< impl_t, data_t, streamsize >::inbuf_dev ( const inbuf_dev_t )
protecteddelete

No copies.

Member Function Documentation

◆ _CRTP_IMPL()

template<typename impl_t , typename data_t , size_t streamsize = 0>
utl::inbuf_dev< impl_t, data_t, streamsize >::_CRTP_IMPL ( impl_t  )
private

◆ begin() [1/2]

template<typename impl_t , typename data_t , size_t streamsize = 0>
iterator utl::inbuf_dev< impl_t, data_t, streamsize >::begin ( )
inlinenoexcept

.begin implementation

Definition at line 165 of file inbuf_dev.h.

◆ begin() [2/2]

template<typename impl_t , typename data_t , size_t streamsize = 0>
const_iterator utl::inbuf_dev< impl_t, data_t, streamsize >::begin ( ) const
inlinenoexcept

Definition at line 166 of file inbuf_dev.h.

◆ cbegin()

template<typename impl_t , typename data_t , size_t streamsize = 0>
const_iterator utl::inbuf_dev< impl_t, data_t, streamsize >::cbegin ( ) const
inlinenoexcept

Definition at line 167 of file inbuf_dev.h.

◆ cend()

template<typename impl_t , typename data_t , size_t streamsize = 0>
const_iterator utl::inbuf_dev< impl_t, data_t, streamsize >::cend ( ) const
inlinenoexcept

Definition at line 172 of file inbuf_dev.h.

◆ end() [1/2]

template<typename impl_t , typename data_t , size_t streamsize = 0>
iterator utl::inbuf_dev< impl_t, data_t, streamsize >::end ( )
inlinenoexcept

.end implementation

Definition at line 170 of file inbuf_dev.h.

◆ end() [2/2]

template<typename impl_t , typename data_t , size_t streamsize = 0>
const_iterator utl::inbuf_dev< impl_t, data_t, streamsize >::end ( ) const
inlinenoexcept

Definition at line 171 of file inbuf_dev.h.

◆ get() [1/2]

template<typename impl_t , typename data_t , size_t streamsize = 0>
size_t utl::inbuf_dev< impl_t, data_t, streamsize >::get ( data_t &  data)
inline

The base get interface. This function should read a single data_t object from device usually in non-blocking mode.

Parameters
dataReference to data output from device.
Returns
Number of data read from device
Note
A successful call should return 1

Definition at line 108 of file inbuf_dev.h.

◆ get() [2/2]

template<typename impl_t , typename data_t , size_t streamsize = 0>
size_t utl::inbuf_dev< impl_t, data_t, streamsize >::get ( data_t *  data,
size_t  n 
)
inline

Old stile get functionality using free standing data_t*. This function should return a stream of data from device.

Parameters
dataPointer to buffer to write the data from device.
nThe number of data of type data_t to read
Returns
The read data items.

Definition at line 120 of file inbuf_dev.h.

◆ get_() [1/2]

template<typename impl_t , typename data_t , size_t streamsize = 0>
size_t utl::inbuf_dev< impl_t, data_t, streamsize >::get_ ( data_t &  data)
inlineprivate

Definition at line 82 of file inbuf_dev.h.

◆ get_() [2/2]

template<typename impl_t , typename data_t , size_t streamsize = 0>
size_t utl::inbuf_dev< impl_t, data_t, streamsize >::get_ ( data_t *  data,
size_t  n 
)
inlineprivate

Definition at line 83 of file inbuf_dev.h.

◆ in_avail()

template<typename impl_t , typename data_t , size_t streamsize = 0>
size_t utl::inbuf_dev< impl_t, data_t, streamsize >::in_avail ( )
inline
Returns
The available data_t typed items in input buffer.

Definition at line 95 of file inbuf_dev.h.

◆ in_avail_()

template<typename impl_t , typename data_t , size_t streamsize = 0>
size_t utl::inbuf_dev< impl_t, data_t, streamsize >::in_avail_ ( )
inlineprivate

Definition at line 81 of file inbuf_dev.h.

◆ operator=()

template<typename impl_t , typename data_t , size_t streamsize = 0>
inbuf_dev_t& utl::inbuf_dev< impl_t, data_t, streamsize >::operator= ( const inbuf_dev_t )
protecteddelete

No copy assignments

◆ operator>>() [1/3]

template<typename impl_t , typename data_t , size_t streamsize = 0>
template<typename _Dst_t >
inbuf_dev_t& utl::inbuf_dev< impl_t, data_t, streamsize >::operator>> ( _Dst_t &  dst)
inline

Template operator >> implementation for for all by value/ref parameters.

Note
In the case _Dst_t size is not a integer multiple of device's data size this will fail by static assertion
Parameters
dstReference to destination
Returns
Reference to this device for chaining

Definition at line 140 of file inbuf_dev.h.

◆ operator>>() [2/3]

template<typename impl_t , typename data_t , size_t streamsize = 0>
template<typename _Dst_t >
inbuf_dev_t& utl::inbuf_dev< impl_t, data_t, streamsize >::operator>> ( _Dst_t *  dst)
delete

Specialization to disallow pointer types as destination.

◆ operator>>() [3/3]

template<typename impl_t , typename data_t , size_t streamsize = 0>
inbuf_dev_t& utl::inbuf_dev< impl_t, data_t, streamsize >::operator>> ( data_t &  dst)
inline

Overload for single data_t object.

Definition at line 151 of file inbuf_dev.h.


The documentation for this class was generated from the following file: