diff options
Diffstat (limited to 'src/scxml/qscxmlcppdatamodel.cpp')
-rw-r--r-- | src/scxml/qscxmlcppdatamodel.cpp | 83 |
1 files changed, 55 insertions, 28 deletions
diff --git a/src/scxml/qscxmlcppdatamodel.cpp b/src/scxml/qscxmlcppdatamodel.cpp index bc09d65..ba18cc7 100644 --- a/src/scxml/qscxmlcppdatamodel.cpp +++ b/src/scxml/qscxmlcppdatamodel.cpp @@ -52,7 +52,7 @@ using namespace QScxmlExecutableContent; \sa QScxmlStateMachine QScxmlDataModel - The C++ data model for SCXML that lets you write C++ code for \e expr attributes and \c <script> + The C++ data model for SCXML lets you write C++ code for \e expr attributes and \c <script> elements. The \e {data part} of the data model is backed by a subclass of QScxmlCppDataModel, for which the Qt SCXML compiler (\c qscxmlc) will generate the dispatch methods. It cannot be used when loading an SCXML file at runtime. @@ -69,6 +69,7 @@ using namespace QScxmlExecutableContent; class TheDataModel: public QScxmlCppDataModel { + Q_OBJECT Q_SCXML_DATAMODEL }; \endcode @@ -77,8 +78,6 @@ class TheDataModel: public QScxmlCppDataModel This macro expands to the declaration of some virtual methods whose implementation is generated by the Qt SCXML compiler. - \note You can of course inherit from both QScxmlCppDataModel and QObject. - The Qt SCXML compiler will generate the various \c evaluateTo methods, and convert expressions and scripts into lambdas inside those methods. For example: \code @@ -134,11 +133,6 @@ QScxmlCppDataModel::QScxmlCppDataModel(QObject *parent) : QScxmlDataModel(*(new QScxmlCppDataModelPrivate), parent) {} -/*! \internal */ -QScxmlCppDataModel::~QScxmlCppDataModel() -{ -} - /*! * Called during state machine initialization to set up a state machine using the initial values * for data model variables specified by their keys, \a initialDataValues. These @@ -153,33 +147,53 @@ bool QScxmlCppDataModel::setup(const QVariantMap &initialDataValues) return true; } -void QScxmlCppDataModel::evaluateAssignment(EvaluatorId id, bool *ok) +/*! + \reimp + + This method does not perform any action, ignores \a id, and sets \a ok to + \c false. Override it in your specific data model in order to implement + \c <assign>. + */ +void QScxmlCppDataModel::evaluateAssignment(QScxmlExecutableContent::EvaluatorId id, bool *ok) { Q_UNUSED(id); - Q_UNUSED(ok); - Q_UNREACHABLE(); + *ok = false; } -void QScxmlCppDataModel::evaluateInitialization(EvaluatorId id, bool *ok) +/*! + \reimp + + This method does not perform any action, ignores \a id, and sets \a ok to + \c false. Override it in your specific data model in order to implement + \c <data>. + */ +void QScxmlCppDataModel::evaluateInitialization(QScxmlExecutableContent::EvaluatorId id, bool *ok) { Q_UNUSED(id); - Q_UNUSED(ok); - Q_UNREACHABLE(); + *ok = false; } -bool QScxmlCppDataModel::evaluateForeach(EvaluatorId id, bool *ok, ForeachLoopBody *body) +/*! + \reimp + + This method does not perform any action, ignores \a id and \a body, and sets + \a ok to \c false. Override it in your specific data model in order to + implement \c <foreach>. + */ +void QScxmlCppDataModel::evaluateForeach(QScxmlExecutableContent::EvaluatorId id, bool *ok, + ForeachLoopBody *body) { Q_UNUSED(id); - Q_UNUSED(ok); Q_UNUSED(body); - Q_UNREACHABLE(); - return false; + *ok = false; } /*! - * Sets the \a event that will be processed next. - * - * \sa QScxmlCppDataModel::scxmlEvent + \reimp + + Sets the \a event that will be processed next. + + \sa QScxmlCppDataModel::scxmlEvent */ void QScxmlCppDataModel::setScxmlEvent(const QScxmlEvent &event) { @@ -206,7 +220,11 @@ const QScxmlEvent &QScxmlCppDataModel::scxmlEvent() const } /*! - * \reimp + \reimp + + This method always returns an empty QVariant and ignores \a name. + Override it to implement the lookup of data model properties via the + \c location attribute of various elements. */ QVariant QScxmlCppDataModel::scxmlProperty(const QString &name) const { @@ -215,7 +233,11 @@ QVariant QScxmlCppDataModel::scxmlProperty(const QString &name) const } /*! - * \reimp + \reimp + + This method always returns \c false and ignores \a name. + Override it to implement the lookup of data model properties via the + \c location attribute of various elements. */ bool QScxmlCppDataModel::hasScxmlProperty(const QString &name) const { @@ -224,20 +246,25 @@ bool QScxmlCppDataModel::hasScxmlProperty(const QString &name) const } /*! - * \reimp + \reimp + + This method always returns \c false and ignores \a name, \a value, and + \a context. + Override it to implement the lookup of data model properties via the + \c location attribute of various elements. */ -bool QScxmlCppDataModel::setScxmlProperty(const QString &name, const QVariant &value, const QString &context) +bool QScxmlCppDataModel::setScxmlProperty(const QString &name, const QVariant &value, + const QString &context) { Q_UNUSED(name); Q_UNUSED(value); Q_UNUSED(context); - Q_UNREACHABLE(); return false; } /*! - * Returns \c true if the state machine is in the state specified by \a stateName, \c false - * otherwise. + Returns \c true if the state machine is in the state specified by + \a stateName, \c false otherwise. */ bool QScxmlCppDataModel::inState(const QString &stateName) const { |