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

The writer class is used to write samples for a data element. More...

#include <DataStorm/DataStorm.h>

Inheritance diagram for DataStorm::Writer< Key, Value, UpdateTag >:
DataStorm::MultiKeyWriter< Key, Value, UpdateTag > DataStorm::SingleKeyWriter< Key, Value, UpdateTag >

Public Types

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

Public Member Functions

 Writer (Writer &&writer) noexcept
 Transfers the given writer to this writer. More...
 
Writeroperator= (Writer &&writer) noexcept
 Move assignement operator. More...
 
 ~Writer ()
 Destruct the writer. More...
 
bool hasReaders () const noexcept
 Indicates whether or not readers are online. More...
 
void waitForReaders (unsigned int count=1) const
 Wait for given number of readers to be online. More...
 
void waitForNoReaders () const
 Wait for readers to be offline. More...
 
std::vector< std::string > getConnectedReaders () const noexcept
 Get the connected readers. More...
 
std::vector< Key > getConnectedKeys () const noexcept
 Get the keys for which readers are connected to this writer. More...
 
Sample< Key, Value, UpdateTag > getLast ()
 Get the last written sample. More...
 
std::vector< Sample< Key, Value, UpdateTag > > getAll () noexcept
 Get all the written sample kept in the writer history. 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 onConnectedReaders (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 readers and when a new reader connects or disconnects. More...
 

Detailed Description

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

The writer class is used to write samples for a data element.

Member Typedef Documentation

◆ KeyType

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

The key type.

◆ ValueType

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

The value type.

Constructor & Destructor Documentation

◆ Writer()

template<typename Key , typename Value , typename UpdateTag >
DataStorm::Writer< Key, Value, UpdateTag >::Writer ( Writer< Key, Value, UpdateTag > &&  writer)
noexcept

Transfers the given writer to this writer.

Parameters
writerThe writer.

◆ ~Writer()

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

Destruct the writer.

The destruction of the writer disconnects the writer from the readers.

Member Function Documentation

◆ getAll()

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

Get all the written sample kept in the writer history.

Returns
The sample history.

◆ getConnectedKeys()

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

Get the keys for which readers are connected to this writer.

Returns
The keys for which we have writers connected.

◆ getConnectedReaders()

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

Get the connected readers.

Returns
The names of the connected readers.

◆ getLast()

template<typename Key , typename Value , typename UpdateTag >
Sample< Key, Value, UpdateTag > DataStorm::Writer< Key, Value, UpdateTag >::getLast ( )

Get the last written sample.

If there's no sample, the std::logic_error exception is raised.

Returns
The last written sample.

◆ hasReaders()

template<typename Key , typename Value , typename UpdateTag >
bool DataStorm::Writer< Key, Value, UpdateTag >::hasReaders ( ) const
noexcept

Indicates whether or not readers are online.

Returns
True if readers are connected, false otherwise.

◆ onConnectedKeys()

template<typename Key , typename Value , typename UpdateTag >
void DataStorm::Writer< 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.

◆ onConnectedReaders()

template<typename Key , typename Value , typename UpdateTag >
void DataStorm::Writer< Key, Value, UpdateTag >::onConnectedReaders ( 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 readers and when a new reader 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 readers. The update callback is called when new readers connect or disconnect.

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

◆ operator=()

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

Move assignement operator.

Parameters
writerThe writer.

◆ waitForNoReaders()

template<typename Key , typename Value , typename UpdateTag >
void DataStorm::Writer< Key, Value, UpdateTag >::waitForNoReaders ( ) const

Wait for readers to be offline.

The node shutdown this method to raise NodeShutdownException.

◆ waitForReaders()

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

Wait for given number of readers to be online.

The node shutdown will cause this method to raise NodeShutdownException.

Parameters
countThe number of readers to wait.

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