3 #ifndef _QI_SIGNALSPY_HPP_
4 #define _QI_SIGNALSPY_HPP_
28 template<
typename... Args>
32 SignalLink link = signal.connect(stranded([
this](
const Args&... args)
34 this->recordCallback(args...);
36 _disconnect = [link, &signal]{ signal.disconnect(link); };
52 std::vector<qi::AnyValue>
args;
56 const T&
arg(
int index)
const
58 return args[index].asReference().as<T>();
63 std::vector<Record> allRecords()
const;
66 Record record(
size_t index)
const;
69 Record lastRecord()
const;
72 size_t recordCount()
const;
75 unsigned int getCounter()
const;
82 std::function<void()> _disconnect;
85 std::vector<Record> _records;
91 template <
typename... Args>
92 void recordCallback(
const Args&... args)
95 _records.emplace_back(Record{{AnyValue::from<Args>(args)...}});
104 #endif // _QI_SIGNALSPY_HPP_
A tool to track signal emissions, specialized for testing. A signal spy can acknowledge every signal ...
#define QI_ASSERT(expr__)
dll import/export and compiler message
std::vector< AnyReference > AnyReferenceVector
#define QI_API_DEPRECATED_MSG(msg__)
Compiler flags to mark a function as deprecated. It will generate a compiler warning.
SignalSpy(SignalF< void(Args...)> &signal)
std::vector< qi::AnyValue > args
Signal arguments are stored here, in a type-erased way for compatibility.
A record data, corresponding to one signal emission.
const T & arg(int index) const
Use this to access an argument in the type you expect it.