MIRA
Classes | Public Types | Public Member Functions | List of all members
ChannelSynchronizer< Ts > Class Template Reference

#include <filter/ChannelSynchronizer.h>

Inheritance diagram for ChannelSynchronizer< Ts >:
Inheritance graph
[legend]

Public Types

enum  SynchronizationMode { BY_TIMESTAMP, BY_SEQUENCE_ID }
 

Public Member Functions

 ChannelSynchronizer ()
 
void unsubscribe (Authority &authority)
 Call this instead of Authority::unsubscribe(...) to unsubscribe all the channels of the synchronizer. More...
 
void subscribe (Authority &authority, StringArgumentHelper< Ts >... channelIDs, const Duration &t=Duration::milliseconds(100))
 Call this instead of Authority::subscribe() Function provided for convenience (if no callback function is required). More...
 
void subscribe (Authority &authority, StringArgumentHelper< Ts >... channelIDs, std::function< void(ChannelRead< Ts >...)> fn, const Duration &t=Duration::milliseconds(100))
 Call this instead of Authority::subscribe() More...
 
void subscribe (Authority &authority, const std::vector< std::string > &channelIDs, std::function< void(ChannelRead< Ts >...)> fn, const Duration &t=Duration::milliseconds(100))
 Same as above but with the channel IDs as std::vector<std::string>. More...
 
template<typename Class >
void subscribe (Authority &authority, StringArgumentHelper< Ts >... channelIDs, void(Class::*f)(ChannelRead< Ts >...), Class *obj, const Duration &t=Duration::milliseconds(100))
 Same as above but with a function and object pointer. More...
 
template<typename Class >
void subscribe (Authority &authority, std::vector< std::string > channelIDs, void(Class::*f)(ChannelRead< Ts >...), Class *obj, const Duration &t=Duration::milliseconds(100))
 Same as above but with a function and object pointer. More...
 
std::tuple< ChannelRead< Ts >... > read ()
 Return (synchronized) ChannelRead objects. More...
 
bool isValid () const
 Return true if all ChannelRead objects contain valid data. More...
 
std::tuple< ChannelRead< Ts >... > waitForData (const Duration &timeout=Duration::infinity())
 Return the latest (synchronized) element once it is available. More...
 
bool waitForPublisher (const Duration &timeout=Duration::infinity()) const
 
void setSynchronizationMode (const SynchronizationMode &synchronizationMode)
 

Member Enumeration Documentation

◆ SynchronizationMode

enum SynchronizationMode
inherited
Enumerator
BY_TIMESTAMP 
BY_SEQUENCE_ID 

Constructor & Destructor Documentation

◆ ChannelSynchronizer()

ChannelSynchronizer ( )
inline

Member Function Documentation

◆ unsubscribe()

void unsubscribe ( Authority authority)
inline

Call this instead of Authority::unsubscribe(...) to unsubscribe all the channels of the synchronizer.

◆ subscribe() [1/5]

void subscribe ( Authority authority,
StringArgumentHelper< Ts >...  channelIDs,
const Duration t = Duration::milliseconds(100) 
)
inline

Call this instead of Authority::subscribe() Function provided for convenience (if no callback function is required).

Parameters
authorityThe authority that does the basic subscription
channelIDsThe IDs of the channels we are subscribing on
tMaximum time difference of the channels message timestamps for still being synchronous

◆ subscribe() [2/5]

void subscribe ( Authority authority,
StringArgumentHelper< Ts >...  channelIDs,
std::function< void(ChannelRead< Ts >...)>  fn,
const Duration t = Duration::milliseconds(100) 
)
inline

Call this instead of Authority::subscribe()

Parameters
authorityThe authority that does the basic subscription
channelIDsThe IDs of the channels we are subscribing on
fnThe function that should be called when the filter matches
tMaximum time difference of the channels message timestamps for still being synchronous

◆ subscribe() [3/5]

void subscribe ( Authority authority,
const std::vector< std::string > &  channelIDs,
std::function< void(ChannelRead< Ts >...)>  fn,
const Duration t = Duration::milliseconds(100) 
)
inline

Same as above but with the channel IDs as std::vector<std::string>.

◆ subscribe() [4/5]

void subscribe ( Authority authority,
StringArgumentHelper< Ts >...  channelIDs,
void(Class::*)(ChannelRead< Ts >...)  f,
Class obj,
const Duration t = Duration::milliseconds(100) 
)
inline

Same as above but with a function and object pointer.

Provided for convenience.

◆ subscribe() [5/5]

void subscribe ( Authority authority,
std::vector< std::string >  channelIDs,
void(Class::*)(ChannelRead< Ts >...)  f,
Class obj,
const Duration t = Duration::milliseconds(100) 
)
inline

Same as above but with a function and object pointer.

Provided for convenience.

◆ read()

std::tuple<ChannelRead<Ts>... > read ( )
inline

Return (synchronized) ChannelRead objects.

The ChannelRead objects are always synchronized by the channel with the lowest update frequency. Please note that the ChannelRead objects may be invalid if no data has been published yet.

◆ isValid()

bool isValid ( ) const
inline

Return true if all ChannelRead objects contain valid data.

◆ waitForData()

std::tuple< ChannelRead<Ts>... > waitForData ( const Duration timeout = Duration::infinity())
inline

Return the latest (synchronized) element once it is available.

If the function times out, invalid channelRead objects will be returned. Please note that the function does not regard synchronized elements that were available BEFORE this function was called.

◆ waitForPublisher()

bool waitForPublisher ( const Duration timeout = Duration::infinity()) const
inline

◆ setSynchronizationMode()

void setSynchronizationMode ( const SynchronizationMode synchronizationMode)
inline

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