typedef void ( *sox )( QVariant );class CiControl : public QObject{...signals: void universalOut01(QVariant);...private: sox sigarray[32];}SEGINTERFACES* CiControl::getInterfaces(){... sigarray[0] = (sox) &universalOut01; // строка 93...}
SEGINTERFACES* CiControl::getInterfaces(){... sigarray[0] = (sox) &CiControl::universalOut01;...}
C++ (Qt)class CiControl : public QObject{public: signal<QVariant> sigarray[32]; }
C++ (Qt)#include <signal_slot.h> class CiControl{public: ssp::signal<int> sigarray[32];}; class A : public ssp::trackable{public: void slot1(int arg) { std::cout << "A::slot1(int arg); arg = " << arg << std::endl; } void slot2(int arg) { std::cout << "A::slot2(int arg); arg = " << arg << std::endl; }}; int main(){ CiControl ci_control; A a1, a2; ci_control.sigarray[0].connect(&a1, &A::slot1); ci_control.sigarray[0].connect(&a1, &A::slot2); ci_control.sigarray[1].connect(&a2, &A::slot1); ci_control.sigarray[1].connect(&a2, &A::slot2); ci_control.sigarray[0](1005001); ci_control.sigarray[1](1005002); return 0;}
C++ (Qt)QMetaMethod QMetaObject::method(int index) const
C++ (Qt)MethodType QMetaMethod::methodType() const
C++ (Qt) const QMetaObject* meta = decoratorProvider->metaObject(); int numMethods = meta->methodCount(); int startFrom = QObject::staticMetaObject.methodCount(); for (int i = startFrom; i < numMethods; i++) { QMetaMethod m = meta->method(i); if ((m.methodType() == QMetaMethod::Method || m.methodType() == QMetaMethod::Slot) && m.access() == QMetaMethod::Public) {
switch( i ) { case 0: emit universalOut01( container ); break; case 1: emit universalOut02( container ); break; .... }
C++ (Qt)class signal_wrapper : public QObject{...signals: void signal(QVariant); }; class CiControl : public QObject{public: signal_wrapper sigarray[32]; }
C++ (Qt)#ifndef OBJECT_H#define OBJECT_H #include <QObject>#include <QVector> class Object : public QObject{ Q_OBJECTpublic: explicit Object( QObject *parent = 0 ); void emitNum( int index, const QVariant &val ); signals: void sig0( const QVariant &val ); void sig1( const QVariant &val ); void sig2( const QVariant &val ); void sig3( const QVariant &val ); void sig4( const QVariant &val ); private: typedef void (Object::*signal_ptr)( const QVariant &val ); QVector<signal_ptr> m_sigs;}; #endif // OBJECT_H
C++ (Qt)#include "object.h" Object::Object( QObject *parent ) : QObject( parent ), m_sigs( 5 ){ m_sigs[ 0 ] = &Object::sig0; m_sigs[ 1 ] = &Object::sig1; m_sigs[ 2 ] = &Object::sig2; m_sigs[ 3 ] = &Object::sig3; m_sigs[ 4 ] = &Object::sig4;} void Object::emitNum( int index , const QVariant &val ){ Q_ASSERT( index >= 0 && index < m_sigs.size() ); signal_ptr func = m_sigs[ index ]; (this->*func)( val );}