Hi devs,

I'd like to get some feedback on a new feature for moc before we take it any further than mild musing. The context is Qt3D has some frontend QObject subclass types, and corresponding backend, non-QObject subclass types for reasons of allowing us to process data on the backend without blocking the main thread or locking it.

To get the property values from the frontend objects to the backend we wrap the data up in QScenePropertyChange and in the backend object we unpack the data and handle it with code something like this:

    if (e->type() == NodeUpdated) {
const QScenePropertyChangePtr &propertyChange = qSharedPointerCast<QScenePropertyChange>(e); if (propertyChange->propertyName() == QByteArrayLiteral("scale3D")) {
            m_scale = propertyChange->value().value<QVector3D>();
            updateMatrix();
} else if (propertyChange->propertyName() == QByteArrayLiteral("rotation")) {
            m_rotation = propertyChange->value().value<QQuaternion>();
            updateMatrix();
} else if (propertyChange->propertyName() == QByteArrayLiteral("translation")) {
            m_translation = propertyChange->value().value<QVector3D>();
            updateMatrix();
} else if (propertyChange->propertyName() == QByteArrayLiteral("enabled")) {
            m_enabled = propertyChange->value().toBool();
        }
    }

Not too bad in this case but those cascaded if-else if blocks are not good when the number of properties is large.

This is where the proposed new feature of moc would come in. If moc were able to generate an enum where each enum value corresponds to a static property we would be able to use a switch in the above code.

Is such a feature feasible? Are there reasons why it couldn't work?

Thanks in advance for any feedback.

Cheers,

Sean

--
Dr Sean Harmer | sean.har...@kdab.com | Managing Director UK
KDAB (UK) Ltd, a KDAB Group company
Tel. +44 (0)1625 809908; Sweden (HQ) +46-563-540090
Mobile: +44 (0)7545 140604
KDAB - Qt Experts

_______________________________________________
Development mailing list
Development@qt-project.org
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to