QSignalSpy
クラスがあり、テストオブジェクトによって発行された特定の信号を監視し、この信号が呼び出された回数と値を記録します。
仕組みは次のとおりです。
// , MyClass "void someSignal(int, bool)". MyClass someObject; QSignalSpy spy(&someObject, SIGNAL(someSignal(int, bool))); // "someSignal". emit someObject.someSignal(58, true); emit someObject.someSignal(42, false); QList<QVariant> firstCallArgs = spy.at(0); QList<QVariant> secondCallArgs = spy.at(1);
最後の2行からわかるように、QSignalSpy自体は
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
-
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
-
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
-
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
-
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.
QList<QList > ( ), QList , - .
:
assert(2 == firstCallArgs.size()); assert(58 == firstCallArgs.at(0).toInt()); // assert(true == firstCallArgs.at(0).toBool()); assert(2 == secondCallArgs.size()); assert(42 == secondCallArgs.at(1).toInt()); assert(false == secondCallArgs.at(2).toBool());
, :
- someSignal, , SIGNAL(someSignal(int, bool)) - ( ). , , .
assert(0 == spy.size());
, , . QVariant ...toInt(), ...toBool() , QVariant . 0. , - int QString. , : QVariant' .
, , .
, ? , :
template <... ...> class SignalSpy;
, . . - :
SignalSpy<... -...> spy(&someObject, &MyClass::someSignal);
, , , , .
, QVariant', ? - :
std::tuple<FirstArgT, SecondArgT,..., LastArgT>
:
QList<std::tuple<FirstArgT, SecondArgT,..., LastArgT> >
, SignalSpy. . :
template <... ...> class SignalSpy { public: // SignalSpy(T* signalSource, ...- ) { … - , , , m_calls... } QList<std::tuple<... ...> > m_calls; };
. , , :
template<typename T, typename ArgT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ArgT)); // Method . std::list<std::tuple<ArgT> > m_calls; };
:
// SomeClass void someSignal(int); SomeClass myObject; SignalSpy<SomeClass, int> spy = SignalSpy<SomeClass, int>(&myObject, &SomeClass::someSignal);
SignalSpy<SomeClass, int> , - , , :
template<typename T, typename ArgT > SignalSpy<T, ArgT> createSignalSpy(T* signalSource, void (T::*Method)(ArgT)) { return SignalSpy<T, ArgT>(signalSource, Method); };
:
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal);
. , . , — lambda :
SignalSpy(T* signalSource, void (T::*Method)(ArgT)); { QObject::connect(signalSource, Method, [this](ArgT arg) { // . m_calls.push_back(std::make_tuple(arg)); }); }
, , . . - :
template<typename T, typename... ParamT> class SignalSpy { public : SignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { QObject::connect(signalSource, Method, [this](ParamT... args) { m_calls.push_back(std::make_tuple(args...)); }); } QList<std::tuple<ParamT...> > m_calls; }; // template<typename T,typename... ParamT> SignalSpy<T, ParamT...> createSignalSpy(T* signalSource, void (T::*Method)(ParamT...)) { return SignalSpy<T, ParamT...>(signalSource, Method); };
- :
auto spy = createSignalSpy(&signalSource, &SignalClass::someSignal); emit someObject.someSignal(58, true) emit someObject.someSignal(42,false); assert( 58, get<0>(spy.m_calls.at(0)) ); assert( true, get<1>(spy.m_calls.at(0)) ); assert( 42, get<0>(spy.m_calls.at(1)) ); assert( false, get<1>(spy.m_calls.at(1)) );
.