C++ (Qt) switch (header->id) { case ind::Start: emit start(header->data); break; } case ind::Stop: emit stop(header->data); break; } case ind::Pause: emit pause(header->data); break; } default: qWarning() << tr("Unknown command: id = %1, size = %2").arg(header->id).arg(header->data->size)); }
C++ (Qt) if (m_hash.contains(header->id)) QMetaObject::invokeMethod(this, m_hash.value(header->id), QT_ARG(QByteArray, header->data));
C++ (Qt)typedef MyHandler ... *handler(...); static const MyHandler table[3] = { start, stop, pause }; ...emit table[header->id](header->data);...