libqi-api  2.8.7.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | List of all members
qi::SignalSpy Class Reference

A tool to track signal emissions, specialized for testing. A signal spy can acknowledge every signal emission of a given signal, type-erased or not. Every emission is recorded, so that they can be compared to expectations, or to produce a history. More...

#include <signalspy.hpp>

Classes

struct  Record
 A record data, corresponding to one signal emission. More...
 

Public Member Functions

template<typename... Args>
 SignalSpy (SignalF< void(Args...)> &signal)
 
 SignalSpy (AnyObject &object, const std::string &signalOrPropertyName)
 Constructor taking a type-erased signal. More...
 
 SignalSpy (const SignalSpy &)=delete
 
SignalSpyoperator= (const SignalSpy &)=delete
 
 ~SignalSpy ()
 
std::vector< RecordallRecords () const
 Retrieve all the records in one shot. More...
 
Record record (size_t index) const
 Direct access to a record, by order of arrival. More...
 
Record lastRecord () const
 Direct access to last record. More...
 
size_t recordCount () const
 The number of records. More...
 
unsigned int getCounter () const
 
FutureSync< bool > waitUntil (size_t nofRecords, const Duration &timeout) const
 Waits for the given number of records to be reached, before the given timeout. More...
 
- Public Member Functions inherited from qi::Actor
 Actor ()=default
 
 Actor (const Actor &)=delete
 
 Actor (qi::ExecutionContext &ec)
 
virtual ~Actor ()=default
 
qi::Strandstrand () const
 
template<class... Args>
auto stranded (Args &&...args) const -> decltype(_strand.schedulerFor(std::forward< Args >(args)...))
 
template<class... Args>
auto strandedUnwrapped (Args &&...args) const -> decltype(_strand.unwrappedSchedulerFor(std::forward< Args >(args)...))
 
template<class... Args>
auto async (Args &&...args) const -> decltype(_strand.async(std::forward< Args >(args)...))
 
template<class... Args>
auto asyncDelay (Args &&...args) const -> decltype(_strand.asyncDelay(std::forward< Args >(args)...))
 
template<class... Args>
auto asyncAt (Args &&...args) const -> decltype(_strand.asyncAt(std::forward< Args >(args)...))
 
void joinTasks ()
 

Detailed Description

A tool to track signal emissions, specialized for testing. A signal spy can acknowledge every signal emission of a given signal, type-erased or not. Every emission is recorded, so that they can be compared to expectations, or to produce a history.

It could also be used in production code for the timeout mechanism implemented in waitUntil.

Definition at line 23 of file signalspy.hpp.

Constructor & Destructor Documentation

template<typename... Args>
qi::SignalSpy::SignalSpy ( SignalF< void(Args...)> &  signal)
inline

Constructor taking a signal instance. The signal instance must outlive the signal spy.

Definition at line 29 of file signalspy.hpp.

qi::SignalSpy::SignalSpy ( AnyObject object,
const std::string &  signalOrPropertyName 
)

Constructor taking a type-erased signal.

qi::SignalSpy::SignalSpy ( const SignalSpy )
delete
qi::SignalSpy::~SignalSpy ( )

Member Function Documentation

std::vector<Record> qi::SignalSpy::allRecords ( ) const

Retrieve all the records in one shot.

unsigned int qi::SignalSpy::getCounter ( ) const
Record qi::SignalSpy::lastRecord ( ) const

Direct access to last record.

SignalSpy& qi::SignalSpy::operator= ( const SignalSpy )
delete
Record qi::SignalSpy::record ( size_t  index) const

Direct access to a record, by order of arrival.

size_t qi::SignalSpy::recordCount ( ) const

The number of records.

FutureSync<bool> qi::SignalSpy::waitUntil ( size_t  nofRecords,
const Duration timeout 
) const

Waits for the given number of records to be reached, before the given timeout.


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