libqi-api  release-2.5.3-2016-11-18
 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)
 Constructor taking a signal instance. More...
 
 SignalSpy (qi::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
 
qi::FutureSync< bool > waitUntil (unsigned int nofRecords, const qi::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 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 21 of file signalspy.hpp.

Constructor & Destructor Documentation

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

Constructor taking a signal instance.

Definition at line 26 of file signalspy.hpp.

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

Constructor taking a type-erased signal.

Definition at line 36 of file signalspy.hpp.

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

Definition at line 52 of file signalspy.hpp.

Member Function Documentation

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

Retrieve all the records in one shot.

Definition at line 72 of file signalspy.hpp.

unsigned int qi::SignalSpy::getCounter ( ) const
inline

Definition at line 114 of file signalspy.hpp.

Record qi::SignalSpy::lastRecord ( ) const
inline

Direct access to last record.

Definition at line 93 of file signalspy.hpp.

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

Direct access to a record, by order of arrival.

Definition at line 80 of file signalspy.hpp.

size_t qi::SignalSpy::recordCount ( ) const
inline

The number of records.

Definition at line 102 of file signalspy.hpp.

qi::FutureSync<bool> qi::SignalSpy::waitUntil ( unsigned int  nofRecords,
const qi::Duration timeout 
) const
inline

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

Definition at line 120 of file signalspy.hpp.


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