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

The key writer to write data elements associated with a given set of keys. More...

#include <DataStorm/DataStorm.h>

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

Public Member Functions

 MultiKeyWriter (const Topic< Key, Value, UpdateTag > &topic, const std::vector< Key > &keys, const std::string &name=std::string(), const WriterConfig &config=WriterConfig()) noexcept
 Construct a new writer for the given keys. More...
 
 MultiKeyWriter (MultiKeyWriter &&writer) noexcept
 Transfers the given writer to this writer. More...
 
MultiKeyWriteroperator= (MultiKeyWriter &&writer) noexcept
 Move assignement operator. More...
 
void add (const Key &key, const Value &value) noexcept
 Add the data element. More...
 
void update (const Key &key, const Value &value) noexcept
 Update the data element. More...
 
template<typename UpdateValue >
std::function< void(const Key &, const UpdateValue &)> partialUpdate (const UpdateTag &tag) noexcept
 Get a partial udpate generator function for the given partial update tag. More...
 
void remove (const Key &key) noexcept
 Remove the data element. More...
 
- Public Member Functions inherited from DataStorm::Writer< Key, Value, UpdateTag >
 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...
 

Additional Inherited Members

- Public Types inherited from DataStorm::Writer< Key, Value, UpdateTag >
using KeyType = Key
 The key type. More...
 
using ValueType = Value
 The value type. More...
 

Detailed Description

template<typename Key, typename Value, typename UpdateTag = std::string>
class DataStorm::MultiKeyWriter< Key, Value, UpdateTag >

The key writer to write data elements associated with a given set of keys.

Constructor & Destructor Documentation

◆ MultiKeyWriter() [1/2]

template<typename Key , typename Value , typename UpdateTag >
DataStorm::MultiKeyWriter< Key, Value, UpdateTag >::MultiKeyWriter ( const Topic< Key, Value, UpdateTag > &  topic,
const std::vector< Key > &  keys,
const std::string &  name = std::string(),
const WriterConfig config = WriterConfig() 
)
noexcept

Construct a new writer for the given keys.

The construction of the writer connects the writer to readers with matching keys. If an empty vector of keys is provided, the writer will connect to all the available readers.

Parameters
topicThe topic.
keysThe keys.
nameThe optional writer name.
configThe writer configuration.

◆ MultiKeyWriter() [2/2]

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

Transfers the given writer to this writer.

Parameters
writerThe writer.

Member Function Documentation

◆ add()

template<typename Key , typename Value , typename UpdateTag >
void DataStorm::MultiKeyWriter< Key, Value, UpdateTag >::add ( const Key &  key,
const Value &  value 
)
noexcept

Add the data element.

This generates an Add sample with the given value.

Parameters
keyThe key
valueThe data element value.

◆ operator=()

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

Move assignement operator.

Parameters
writerThe writer.

◆ partialUpdate()

template<typename Key , typename Value , typename UpdateTag >
template<typename UpdateValue >
std::function< void(const Key &, const UpdateValue &)> DataStorm::MultiKeyWriter< Key, Value, UpdateTag >::partialUpdate ( const UpdateTag &  tag)
noexcept

Get a partial udpate generator function for the given partial update tag.

When called, the returned function generates a PartialUpdate sample with the given partial update value.

The UpdateValue template parameter must match the UpdateValue type used to register the updater with the Topic::setUpdater method.

Parameters
tagThe partial update tag.

◆ remove()

template<typename Key , typename Value , typename UpdateTag >
void DataStorm::MultiKeyWriter< Key, Value, UpdateTag >::remove ( const Key &  key)
noexcept

Remove the data element.

This generates a Remove sample.

Parameters
keyThe key

◆ update()

template<typename Key , typename Value , typename UpdateTag >
void DataStorm::MultiKeyWriter< Key, Value, UpdateTag >::update ( const Key &  key,
const Value &  value 
)
noexcept

Update the data element.

This generates an Update sample with the given value.

Parameters
keyThe key
valueThe data element value.

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