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

The Topic class. More...

#include <DataStorm/DataStorm.h>

Public Types

using KeyType = Key
 The topic's key type. More...
 
using ValueType = Value
 The topic's value type. More...
 
using UpdateTagType = UpdateTag
 The topic's update tag type (defaults to std::string if not specified). More...
 
using WriterType = Writer< Key, Value, UpdateTag >
 The topic's writer type. More...
 
using ReaderType = Reader< Key, Value, UpdateTag >
 The topic's reader type. More...
 
using SampleType = Sample< Key, Value, UpdateTag >
 The topic's sample type. More...
 

Public Member Functions

 Topic (const Node &node, const std::string &name) noexcept
 Construct a new Topic for the topic with the given name. More...
 
 Topic (Topic &&topic) noexcept
 Construct a new Topic by taking ownership of the given topic. More...
 
 ~Topic ()
 Destruct the Topic. More...
 
Topicoperator= (Topic &&topic) noexcept
 Move assignement operator. More...
 
bool hasWriters () const noexcept
 Indicates whether or not data writers are online. More...
 
void waitForWriters (unsigned int count=1) const
 Wait for given number of data writers to be online. More...
 
void waitForNoWriters () const
 Wait for data writers to be offline. More...
 
void setWriterDefaultConfig (const WriterConfig &config) noexcept
 Set the default configuration used to construct readers. More...
 
bool hasReaders () const noexcept
 Indicates whether or not data readers are online. More...
 
void waitForReaders (unsigned int count=1) const
 Wait for given number of data readers to be online. More...
 
void waitForNoReaders () const
 Wait for data readers to be offline. More...
 
void setReaderDefaultConfig (const ReaderConfig &config) noexcept
 Set the default configuration used to construct readers. More...
 
template<typename UpdateValue >
void setUpdater (const UpdateTag &tag, std::function< void(Value &, UpdateValue)> updater) noexcept
 Set an updater function for the given update tag. More...
 
template<typename Criteria >
void setKeyFilter (const std::string &name, std::function< std::function< bool(const Key &)>(const Criteria &)> factory) noexcept
 Set a key filter factory. More...
 
template<typename Criteria >
void setSampleFilter (const std::string &name, std::function< std::function< bool(const SampleType &)>(const Criteria &)> factory) noexcept
 Set a sample filter factory. More...
 

Friends

template<typename , typename , typename >
class SingleKeyWriter
 
template<typename , typename , typename >
class MultiKeyWriter
 
template<typename , typename , typename >
class SingleKeyReader
 
template<typename , typename , typename >
class MultiKeyReader
 
template<typename , typename , typename >
class FilteredKeyReader
 

Detailed Description

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

The Topic class.

This class allows constructing reader and writer objects. It's also used to setup filter and updater functions.

Member Typedef Documentation

◆ KeyType

template<typename Key, typename Value, typename UpdateTag = std::string>
using DataStorm::Topic< Key, Value, UpdateTag >::KeyType = Key

The topic's key type.

◆ ReaderType

template<typename Key, typename Value, typename UpdateTag = std::string>
using DataStorm::Topic< Key, Value, UpdateTag >::ReaderType = Reader<Key, Value, UpdateTag>

The topic's reader type.

◆ SampleType

template<typename Key, typename Value, typename UpdateTag = std::string>
using DataStorm::Topic< Key, Value, UpdateTag >::SampleType = Sample<Key, Value, UpdateTag>

The topic's sample type.

◆ UpdateTagType

template<typename Key, typename Value, typename UpdateTag = std::string>
using DataStorm::Topic< Key, Value, UpdateTag >::UpdateTagType = UpdateTag

The topic's update tag type (defaults to std::string if not specified).

◆ ValueType

template<typename Key, typename Value, typename UpdateTag = std::string>
using DataStorm::Topic< Key, Value, UpdateTag >::ValueType = Value

The topic's value type.

◆ WriterType

template<typename Key, typename Value, typename UpdateTag = std::string>
using DataStorm::Topic< Key, Value, UpdateTag >::WriterType = Writer<Key, Value, UpdateTag>

The topic's writer type.

Constructor & Destructor Documentation

◆ Topic() [1/2]

template<typename Key , typename Value , typename UpdateTag >
DataStorm::Topic< Key, Value, UpdateTag >::Topic ( const Node node,
const std::string &  name 
)
noexcept

Construct a new Topic for the topic with the given name.

Parameters
nodeThe node.
nameThe name of the topic.

◆ Topic() [2/2]

template<typename Key , typename Value , typename UpdateTag >
DataStorm::Topic< Key, Value, UpdateTag >::Topic ( Topic< Key, Value, UpdateTag > &&  topic)
noexcept

Construct a new Topic by taking ownership of the given topic.

Parameters
topicThe topic to transfer ownership from.

◆ ~Topic()

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

Destruct the Topic.

This disconnects the topic from peers.

Member Function Documentation

◆ hasReaders()

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

Indicates whether or not data readers are online.

Returns
True if data readers are connected, false otherwise.

◆ hasWriters()

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

Indicates whether or not data writers are online.

Returns
True if data writers are connected, false otherwise.

◆ operator=()

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

Move assignement operator.

Parameters
topicThe topic.

◆ setKeyFilter()

template<typename Key , typename Value , typename UpdateTag >
template<typename Criteria >
void DataStorm::Topic< Key, Value, UpdateTag >::setKeyFilter ( const std::string &  name,
std::function< std::function< bool(const Key &)>(const Criteria &)>  factory 
)
noexcept

Set a key filter factory.

The given factory function must return a filter function that returns true if the key matches the filter criteria, false otherwise.

Parameters
nameThe name of the key filter.
factoryThe filter factory function.

◆ setReaderDefaultConfig()

template<typename Key , typename Value , typename UpdateTag >
void DataStorm::Topic< Key, Value, UpdateTag >::setReaderDefaultConfig ( const ReaderConfig config)
noexcept

Set the default configuration used to construct readers.

Parameters
configThe default reader configuration.

◆ setSampleFilter()

template<typename Key , typename Value , typename UpdateTag >
template<typename Criteria >
void DataStorm::Topic< Key, Value, UpdateTag >::setSampleFilter ( const std::string &  name,
std::function< std::function< bool(const SampleType &)>(const Criteria &)>  factory 
)
noexcept

Set a sample filter factory.

The given factory function must return a filter function that returns true if the sample matches the filter criteria, false otherwise.

Parameters
nameThe name of the sample filter.
factoryThe filter factory function.

◆ setUpdater()

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

Set an updater function for the given update tag.

The function is called when a partial update is received or sent to compute the new value. The function is provided the latest value and the partial update. It should return the new value.

Parameters
tagThe update tag.
updaterThe updater function.

◆ setWriterDefaultConfig()

template<typename Key , typename Value , typename UpdateTag >
void DataStorm::Topic< Key, Value, UpdateTag >::setWriterDefaultConfig ( const WriterConfig config)
noexcept

Set the default configuration used to construct readers.

Parameters
configThe default writer configuration.

◆ waitForNoReaders()

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

Wait for data readers to be offline.

The node shutdown will cause this method to raise NodeShutdownException.

◆ waitForNoWriters()

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

Wait for data writers to be offline.

The node shutdown will cause this method to raise NodeShutdownException.

◆ waitForReaders()

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

Wait for given number of data readers to be online.

The node shutdown will cause this method to raise NodeShutdownException.

Parameters
countThe number of data readers to wait.

◆ waitForWriters()

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

Wait for given number of data writers to be online.

The node shutdown will cause this method to raise NodeShutdownException.

Parameters
countThe number of date writers to wait.

Friends And Related Function Documentation

◆ FilteredKeyReader

template<typename Key, typename Value, typename UpdateTag = std::string>
template<typename , typename , typename >
friend class FilteredKeyReader
friend

◆ MultiKeyReader

template<typename Key, typename Value, typename UpdateTag = std::string>
template<typename , typename , typename >
friend class MultiKeyReader
friend

◆ MultiKeyWriter

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

◆ SingleKeyReader

template<typename Key, typename Value, typename UpdateTag = std::string>
template<typename , typename , typename >
friend class SingleKeyReader
friend

◆ SingleKeyWriter

template<typename Key, typename Value, typename UpdateTag = std::string>
template<typename , typename , typename >
friend class SingleKeyWriter
friend

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