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

The key writer to write the data element associated with a given key. More...

#include <DataStorm/DataStorm.h>

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

Public Member Functions

 SingleKeyWriter (const Topic< Key, Value, UpdateTag > &topic, const Key &key, const std::string &name=std::string(), const WriterConfig &config=WriterConfig()) noexcept
 Construct a new writer for the given key. More...
 
 SingleKeyWriter (SingleKeyWriter &&writer) noexcept
 Move constructor. More...
 
SingleKeyWriteroperator= (SingleKeyWriter &&writer) noexcept
 Move assignement operator. More...
 
void add (const Value &value) noexcept
 Add the data element. More...
 
void update (const Value &value) noexcept
 Update the data element. More...
 
template<typename UpdateValue >
std::function< void(const UpdateValue &)> partialUpdate (const UpdateTag &tag) noexcept
 Get a partial udpate generator function for the given partial update tag. More...
 
void remove () 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::SingleKeyWriter< Key, Value, UpdateTag >

The key writer to write the data element associated with a given key.

Constructor & Destructor Documentation

◆ SingleKeyWriter() [1/2]

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

Construct a new writer for the given key.

The construction of the writer connects the writer to readers with a matching key.

Parameters
topicThe topic.
keyThe key of the data element to write.
nameThe optional writer name.
configThe writer configuration.

◆ SingleKeyWriter() [2/2]

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

Move constructor.

Parameters
writerThe writer.

Member Function Documentation

◆ add()

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

Add the data element.

This generates an Add sample with the given value.

Parameters
valueThe data element value.

◆ operator=()

template<typename Key , typename Value , typename UpdateTag >
SingleKeyWriter< Key, Value, UpdateTag > & DataStorm::SingleKeyWriter< Key, Value, UpdateTag >::operator= ( SingleKeyWriter< 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 UpdateValue &)> DataStorm::SingleKeyWriter< 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::SingleKeyWriter< Key, Value, UpdateTag >::remove ( )
noexcept

Remove the data element.

This generates a Remove sample.

◆ update()

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

Update the data element.

This generates an Update sample with the given value.

Parameters
valueThe data element value.

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