DataStorm  0.1
Data Distribution Service
Public Types | Public Member Functions | List of all members
DataStorm::Reader< Key, Value, UpdateTag > Class Template Reference

The Reader class is used to retrieve samples for a data element. More...

#include <DataStorm/DataStorm.h>

Inheritance diagram for DataStorm::Reader< Key, Value, UpdateTag >:
DataStorm::FilteredKeyReader< Key, Value, UpdateTag > DataStorm::MultiKeyReader< Key, Value, UpdateTag > DataStorm::SingleKeyReader< Key, Value, UpdateTag >

Public Types

using KeyType = Key
 The key type. More...
 
using ValueType = Value
 The value type. More...
 

Public Member Functions

 Reader (Reader &&reader) noexcept
 Transfers the given reader to this reader. More...
 
 ~Reader ()
 Destruct the reader. More...
 
Readeroperator= (Reader &&reader) noexcept
 Move assignement operator. More...
 
bool hasWriters () const noexcept
 Indicates whether or not writers are online. More...
 
void waitForWriters (unsigned int count=1) const
 Wait for given number of writers to be online. More...
 
void waitForNoWriters () const
 Wait for readers to be offline. More...
 
std::vector< std::string > getConnectedWriters () const noexcept
 Get the connected writers. More...
 
std::vector< Key > getConnectedKeys () const noexcept
 Get the keys for which writers are connected to this reader. More...
 
std::vector< Sample< Key, Value, UpdateTag > > getAllUnread () noexcept
 Returns all the unread samples. More...
 
void waitForUnread (unsigned int count=1) const
 Wait for given number of unread samples to be available. More...
 
bool hasUnread () const noexcept
 Returns wether or not unread samples are available. More...
 
Sample< Key, Value, UpdateTag > getNextUnread ()
 Returns the next unread sample. More...
 
void onConnectedKeys (std::function< void(std::vector< Key >)> init, std::function< void(CallbackReason, Key)> update) noexcept
 Calls the given functions to provide the initial set of connected keys and when a key is added or removed from the set of connected keys. More...
 
void onConnectedWriters (std::function< void(std::vector< std::string >)> init, std::function< void(CallbackReason, std::string)> update) noexcept
 Calls the given functions to provide the initial set of connected writers and when a new writer connects or disconnects. More...
 
void onSamples (std::function< void(std::vector< Sample< Key, Value, UpdateTag >>)> init, std::function< void(Sample< Key, Value, UpdateTag >)> queue) noexcept
 Calls the given function to provide the initial set of unread samples and when new samples are queued. More...
 

Detailed Description

template<typename Key, typename Value, typename UpdateTag>
class DataStorm::Reader< Key, Value, UpdateTag >

The Reader class is used to retrieve samples for a data element.

Member Typedef Documentation

◆ KeyType

template<typename Key , typename Value , typename UpdateTag >
using DataStorm::Reader< Key, Value, UpdateTag >::KeyType = Key

The key type.

◆ ValueType

template<typename Key , typename Value , typename UpdateTag >
using DataStorm::Reader< Key, Value, UpdateTag >::ValueType = Value

The value type.

Constructor & Destructor Documentation

◆ Reader()

template<typename Key , typename Value , typename UpdateTag >
DataStorm::Reader< Key, Value, UpdateTag >::Reader ( Reader< Key, Value, UpdateTag > &&  reader)
noexcept

Transfers the given reader to this reader.

Parameters
readerThe reader.

◆ ~Reader()

template<typename Key , typename Value , typename UpdateTag >
DataStorm::Reader< Key, Value, UpdateTag >::~Reader ( )

Destruct the reader.

The destruction of the reader disconnects the reader from the writers.

Member Function Documentation

◆ getAllUnread()

template<typename Key , typename Value , typename UpdateTag >
std::vector< Sample< Key, Value, UpdateTag > > DataStorm::Reader< Key, Value, UpdateTag >::getAllUnread ( )
noexcept

Returns all the unread samples.

Returns
The unread samples.

◆ getConnectedKeys()

template<typename Key , typename Value , typename UpdateTag >
std::vector< Key > DataStorm::Reader< Key, Value, UpdateTag >::getConnectedKeys ( ) const
noexcept

Get the keys for which writers are connected to this reader.

Returns
The keys for which we have writers connected.

◆ getConnectedWriters()

template<typename Key , typename Value , typename UpdateTag >
std::vector< std::string > DataStorm::Reader< Key, Value, UpdateTag >::getConnectedWriters ( ) const
noexcept

Get the connected writers.

Returns
The names of the connected writers.

◆ getNextUnread()

template<typename Key , typename Value , typename UpdateTag >
Sample< Key, Value, UpdateTag > DataStorm::Reader< Key, Value, UpdateTag >::getNextUnread ( )

Returns the next unread sample.

The node shutdown will cause this method to raise NodeShutdownException.

Returns
The unread sample.

◆ hasUnread()

template<typename Key , typename Value , typename UpdateTag >
bool DataStorm::Reader< Key, Value, UpdateTag >::hasUnread ( ) const
noexcept

Returns wether or not unread samples are available.

Returns
True if there unread samples are queued, false otherwise.

◆ hasWriters()

template<typename Key , typename Value , typename UpdateTag >
bool DataStorm::Reader< Key, Value, UpdateTag >::hasWriters ( ) const
noexcept

Indicates whether or not writers are online.

Returns
True if writers are connected, false otherwise.

◆ onConnectedKeys()

template<typename Key , typename Value , typename UpdateTag >
void DataStorm::Reader< Key, Value, UpdateTag >::onConnectedKeys ( std::function< void(std::vector< Key >)>  init,
std::function< void(CallbackReason, Key)>  update 
)
noexcept

Calls the given functions to provide the initial set of connected keys and when a key is added or removed from the set of connected keys.

If callback functions are already set, they will be replaced.

The connected keys represent the set of keys for which writers are connected to this reader.

The init callback is always called after this method returns to provide the initial set of connected keys. The update callback is called when new keys are added or removed from the set of connected keys.

Parameters
initThe function to call with the initial set of connected keys.
updateThe function to call when a key is added or removed from the set.

◆ onConnectedWriters()

template<typename Key , typename Value , typename UpdateTag >
void DataStorm::Reader< Key, Value, UpdateTag >::onConnectedWriters ( std::function< void(std::vector< std::string >)>  init,
std::function< void(CallbackReason, std::string)>  update 
)
noexcept

Calls the given functions to provide the initial set of connected writers and when a new writer connects or disconnects.

If callback functions are already set, they will be replaced.

The init callback is always called after this method returns to provide the initial set of connected writers. The update callback is called when new writers connect or disconnect.

Parameters
initThe function to call with the initial set of connected writers.
updateThe function to call when a new writer connects or disconnects.

◆ onSamples()

template<typename Key , typename Value , typename UpdateTag >
void DataStorm::Reader< Key, Value, UpdateTag >::onSamples ( std::function< void(std::vector< Sample< Key, Value, UpdateTag >>)>  init,
std::function< void(Sample< Key, Value, UpdateTag >)>  queue 
)
noexcept

Calls the given function to provide the initial set of unread samples and when new samples are queued.

If a function is already set, it will be replaced.

The init callback is always called after this method returns to provide the initial set of unread samples. The queue callback is called when a new sample is received.

Parameters
initThe function to call with the initial set of unread samples.
queueThe function to call when a new sample is received.

◆ operator=()

template<typename Key , typename Value , typename UpdateTag >
Reader< Key, Value, UpdateTag > & DataStorm::Reader< Key, Value, UpdateTag >::operator= ( Reader< Key, Value, UpdateTag > &&  reader)
noexcept

Move assignement operator.

Parameters
readerThe reader.

◆ waitForNoWriters()

template<typename Key , typename Value , typename UpdateTag >
void DataStorm::Reader< Key, Value, UpdateTag >::waitForNoWriters ( ) const

Wait for readers to be offline.

The node shutdown will cause this method to raise NodeShutdownException.

◆ waitForUnread()

template<typename Key , typename Value , typename UpdateTag >
void DataStorm::Reader< Key, Value, UpdateTag >::waitForUnread ( unsigned int  count = 1) const

Wait for given number of unread samples to be available.

The node shutdown will cause this method to raise NodeShutdownException.

◆ waitForWriters()

template<typename Key , typename Value , typename UpdateTag >
void DataStorm::Reader< Key, Value, UpdateTag >::waitForWriters ( unsigned int  count = 1) const

Wait for given number of writers to be online.

The node shutdown will cause this method to raise NodeShutdownException.

Parameters
countThe number of writers to wait.

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