uTL
micro Template library
utl::idx_dev< impl_t, data_t, idx_t, N > Class Template Reference

Abstract base class for indexed devices. More...

#include <idx_dev.h>

Public Types

using type = idx_dev_t
 Export type as identity meta-function. More...
 
using data_type = data_t
 Export types as index device concept demands. More...
 
using pointer_type = data_t *
 
using idx_type = idx_t
 

Public Member Functions

Public index device interface
size_t get (data_t &data, idx_t cursor)
 Get interface. This function should read a single data_t object from device in blocking mode. More...
 
size_t get (data_t *data, size_t n, idx_t cursor)
 Old stile get functionality using free standing data_t*. This function should return a stream of data from device. More...
 
size_t put (const data_t &data, idx_t cursor)
 Put interface. This function should send a single data_t object to device. More...
 
size_t put (const data_t *data, size_t n, idx_t cursor)
 Put interface. This function should send a stream of data_t objects to device. More...
 
idx_t cursor () const
 Return the current cursor position. More...
 
idx_t cursor (idx_t idx)
 Set the cursor position. More...
 
Stream operator >> interface
template<typename _Dst_t >
idx_dev_toperator>> (_Dst_t &dst)
 Template operator>> implementation for for all by value/ref parameters. More...
 
template<typename _Dst_t >
idx_dev_toperator>> (_Dst_t *dst)=delete
 Specialization to disallow pointer types as destination. More...
 
idx_dev_toperator>> (data_t &dst)
 Overload for single data_t object. More...
 
Stream operator<< interface
template<typename _Src_t >
idx_dev_toperator<< (_Src_t &src)
 Template operator<< implementation for for all by value/ref parameters. More...
 
template<typename _Src_t >
idx_dev_toperator<< (_Src_t *src)=delete
 specialization to disallow pointer types as source More...
 
idx_dev_toperator<< (const data_t &src)
 Overload for single data_t object. More...
 
Helper operators
data_t & operator[] (const idx_t idx)
 
iterator end () noexcept
 
const_iterator end () const noexcept
 
const_iterator cend () const noexcept
 

Protected Member Functions

Constructor / Destructor
 ~idx_dev ()=default
 Allow destructor from derived only. More...
 
 idx_dev ()=default
 A default constructor from derived only. More...
 
 idx_dev (const idx_dev_t &)=delete
 No copies. More...
 
idx_dev_toperator= (const idx_dev_t &)=delete
 

Private Types

using idx_dev_t = idx_dev< impl_t, data_t, idx_t, N >
 class type syntactic sugar More...
 

Private Member Functions

 _CRTP_IMPL (impl_t)
 
Common index device interface requirements
size_t get_ (data_t &data, idx_t idx)
 
size_t get_ (data_t *data, size_t n, idx_t idx)
 
size_t put_ (const data_t &data, idx_t idx)
 
size_t put_ (const data_t *data, size_t n, idx_t idx)
 
idx_t cursor_ () const
 
void cursor_ (idx_t idx)
 

STL-like Input iterator interface

using iterator = idxdev_it< idx_dev_t, data_t *, N >
 Iterator. More...
 
using const_iterator = idxdev_it< idx_dev_t, const data_t *, N >
 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, typename idx_t, size_t N>
class utl::idx_dev< impl_t, data_t, idx_t, N >

Abstract base class for indexed devices.

Template base class for indexed (I/O) devices. using CRTP

This class force a common interface for input, indexed (I/O) devices. By using this common interface the class implements

  • Stream-like extracting and insertion operator
  • Helper operators
  • 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
idx_tThe type to use for indexing
streamsizeThe number of elements to indicate eos.

Definition at line 56 of file idx_dev.h.

Member Typedef Documentation

◆ const_iterator

template<typename impl_t , typename data_t , typename idx_t , size_t N>
using utl::idx_dev< impl_t, data_t, idx_t, N >::const_iterator = idxdev_it <idx_dev_t, const data_t*, N>

Const iterator.

Definition at line 231 of file idx_dev.h.

◆ data_type

template<typename impl_t , typename data_t , typename idx_t , size_t N>
using utl::idx_dev< impl_t, data_t, idx_t, N >::data_type = data_t

Export types as index device concept demands.

Definition at line 62 of file idx_dev.h.

◆ idx_dev_t

template<typename impl_t , typename data_t , typename idx_t , size_t N>
using utl::idx_dev< impl_t, data_t, idx_t, N >::idx_dev_t = idx_dev <impl_t, data_t, idx_t, N>
private

class type syntactic sugar

Definition at line 58 of file idx_dev.h.

◆ idx_type

template<typename impl_t , typename data_t , typename idx_t , size_t N>
using utl::idx_dev< impl_t, data_t, idx_t, N >::idx_type = idx_t

Definition at line 64 of file idx_dev.h.

◆ iterator

template<typename impl_t , typename data_t , typename idx_t , size_t N>
using utl::idx_dev< impl_t, data_t, idx_t, N >::iterator = idxdev_it <idx_dev_t, data_t*, N>

Iterator.

Definition at line 230 of file idx_dev.h.

◆ pointer_type

template<typename impl_t , typename data_t , typename idx_t , size_t N>
using utl::idx_dev< impl_t, data_t, idx_t, N >::pointer_type = data_t*

Definition at line 63 of file idx_dev.h.

◆ type

template<typename impl_t , typename data_t , typename idx_t , size_t N>
using utl::idx_dev< impl_t, data_t, idx_t, N >::type = idx_dev_t

Export type as identity meta-function.

Definition at line 66 of file idx_dev.h.

Constructor & Destructor Documentation

◆ ~idx_dev()

template<typename impl_t , typename data_t , typename idx_t , size_t N>
utl::idx_dev< impl_t, data_t, idx_t, N >::~idx_dev ( )
protecteddefault

Allow destructor from derived only.

◆ idx_dev() [1/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
utl::idx_dev< impl_t, data_t, idx_t, N >::idx_dev ( )
protecteddefault

A default constructor from derived only.

◆ idx_dev() [2/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
utl::idx_dev< impl_t, data_t, idx_t, N >::idx_dev ( const idx_dev_t )
protecteddelete

No copies.

Member Function Documentation

◆ _CRTP_IMPL()

template<typename impl_t , typename data_t , typename idx_t , size_t N>
utl::idx_dev< impl_t, data_t, idx_t, N >::_CRTP_IMPL ( impl_t  )
private

◆ begin() [1/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
iterator utl::idx_dev< impl_t, data_t, idx_t, N >::begin ( )
inlinenoexcept

.begin implementation

Definition at line 234 of file idx_dev.h.

◆ begin() [2/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
const_iterator utl::idx_dev< impl_t, data_t, idx_t, N >::begin ( ) const
inlinenoexcept

Definition at line 235 of file idx_dev.h.

◆ cbegin()

template<typename impl_t , typename data_t , typename idx_t , size_t N>
const_iterator utl::idx_dev< impl_t, data_t, idx_t, N >::cbegin ( ) const
inlinenoexcept

Definition at line 236 of file idx_dev.h.

◆ cend()

template<typename impl_t , typename data_t , typename idx_t , size_t N>
const_iterator utl::idx_dev< impl_t, data_t, idx_t, N >::cend ( ) const
inlinenoexcept

Definition at line 241 of file idx_dev.h.

◆ cursor() [1/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
idx_t utl::idx_dev< impl_t, data_t, idx_t, N >::cursor ( ) const
inline

Return the current cursor position.

Definition at line 149 of file idx_dev.h.

◆ cursor() [2/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
idx_t utl::idx_dev< impl_t, data_t, idx_t, N >::cursor ( idx_t  idx)
inline

Set the cursor position.

Parameters
idxCursor address to set
Returns
The current cursor

Definition at line 156 of file idx_dev.h.

◆ cursor_() [1/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
idx_t utl::idx_dev< impl_t, data_t, idx_t, N >::cursor_ ( ) const
inlineprivate

Definition at line 86 of file idx_dev.h.

◆ cursor_() [2/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
void utl::idx_dev< impl_t, data_t, idx_t, N >::cursor_ ( idx_t  idx)
inlineprivate

Definition at line 87 of file idx_dev.h.

◆ end() [1/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
iterator utl::idx_dev< impl_t, data_t, idx_t, N >::end ( )
inlinenoexcept

.end implementation

Definition at line 239 of file idx_dev.h.

◆ end() [2/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
const_iterator utl::idx_dev< impl_t, data_t, idx_t, N >::end ( ) const
inlinenoexcept

Definition at line 240 of file idx_dev.h.

◆ get() [1/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
size_t utl::idx_dev< impl_t, data_t, idx_t, N >::get ( data_t &  data,
idx_t  cursor 
)
inline

Get interface. This function should read a single data_t object from device in 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 104 of file idx_dev.h.

◆ get() [2/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
size_t utl::idx_dev< impl_t, data_t, idx_t, N >::get ( data_t *  data,
size_t  n,
idx_t  cursor 
)
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 116 of file idx_dev.h.

◆ get_() [1/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
size_t utl::idx_dev< impl_t, data_t, idx_t, N >::get_ ( data_t &  data,
idx_t  idx 
)
inlineprivate

Definition at line 82 of file idx_dev.h.

◆ get_() [2/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
size_t utl::idx_dev< impl_t, data_t, idx_t, N >::get_ ( data_t *  data,
size_t  n,
idx_t  idx 
)
inlineprivate

Definition at line 83 of file idx_dev.h.

◆ operator<<() [1/3]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
template<typename _Src_t >
idx_dev_t& utl::idx_dev< impl_t, data_t, idx_t, N >::operator<< ( _Src_t &  src)
inline

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

Parameters
srcReference to source data
Returns
Reference to this device for chaining

Definition at line 198 of file idx_dev.h.

◆ operator<<() [2/3]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
template<typename _Src_t >
idx_dev_t& utl::idx_dev< impl_t, data_t, idx_t, N >::operator<< ( _Src_t *  src)
delete

specialization to disallow pointer types as source

◆ operator<<() [3/3]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
idx_dev_t& utl::idx_dev< impl_t, data_t, idx_t, N >::operator<< ( const data_t &  src)
inline

Overload for single data_t object.

Definition at line 209 of file idx_dev.h.

◆ operator=()

template<typename impl_t , typename data_t , typename idx_t , size_t N>
idx_dev_t& utl::idx_dev< impl_t, data_t, idx_t, N >::operator= ( const idx_dev_t )
protecteddelete

No copy assignments

◆ operator>>() [1/3]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
template<typename _Dst_t >
idx_dev_t& utl::idx_dev< impl_t, data_t, idx_t, N >::operator>> ( _Dst_t &  dst)
inline

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

Parameters
dstReference to destination
Returns
Reference to this device for chaining

Definition at line 170 of file idx_dev.h.

◆ operator>>() [2/3]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
template<typename _Dst_t >
idx_dev_t& utl::idx_dev< impl_t, data_t, idx_t, N >::operator>> ( _Dst_t *  dst)
delete

Specialization to disallow pointer types as destination.

◆ operator>>() [3/3]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
idx_dev_t& utl::idx_dev< impl_t, data_t, idx_t, N >::operator>> ( data_t &  dst)
inline

Overload for single data_t object.

Definition at line 181 of file idx_dev.h.

◆ operator[]()

template<typename impl_t , typename data_t , typename idx_t , size_t N>
data_t& utl::idx_dev< impl_t, data_t, idx_t, N >::operator[] ( const idx_t  idx)
inline

Definition at line 219 of file idx_dev.h.

◆ put() [1/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
size_t utl::idx_dev< impl_t, data_t, idx_t, N >::put ( const data_t &  data,
idx_t  cursor 
)
inline

Put interface. This function should send a single data_t object to device.

Parameters
dataThe data to send
Returns
The number of transmitted data items
Note
A successful call should return 1

Definition at line 129 of file idx_dev.h.

◆ put() [2/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
size_t utl::idx_dev< impl_t, data_t, idx_t, N >::put ( const data_t *  data,
size_t  n,
idx_t  cursor 
)
inline

Put interface. This function should send a stream of data_t objects to device.

Parameters
dataPointer to buffer indenting write to device.
nThe number of data of type data_t to send
Returns
The number of transmitted items.

Definition at line 141 of file idx_dev.h.

◆ put_() [1/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
size_t utl::idx_dev< impl_t, data_t, idx_t, N >::put_ ( const data_t &  data,
idx_t  idx 
)
inlineprivate

Definition at line 84 of file idx_dev.h.

◆ put_() [2/2]

template<typename impl_t , typename data_t , typename idx_t , size_t N>
size_t utl::idx_dev< impl_t, data_t, idx_t, N >::put_ ( const data_t *  data,
size_t  n,
idx_t  idx 
)
inlineprivate

Definition at line 85 of file idx_dev.h.


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