//
// Statemachine code from reading SCXML file 'mediaplayer-cppdatamodel.scxml'
// Created by: The Qt SCXML Compiler version 1 (Qt 5.9.4)
// WARNING! All changes made in this file will be lost!
//

#include "mediaplayer-cppdatamodel.h"

#include <qscxmlinvokableservice.h>
#include <qscxmltabledata.h>
#include <thedatamodel.h>

#if !defined(Q_QSCXMLC_OUTPUT_REVISION)
#error "The header file 'mediaplayer-cppdatamodel.scxml' doesn't include <qscxmltabledata.h>."
#elif Q_QSCXMLC_OUTPUT_REVISION != 1
#error "This file was generated using the qscxmlc from 5.9.4. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The qscxmlc has changed too much.)"
#endif

struct MediaPlayerStateMachine::Data: private QScxmlTableData {
    Data(MediaPlayerStateMachine &stateMachine)
        : stateMachine(stateMachine)
    {}

    void init() {
        stateMachine.setTableData(this);
        // Data model TheDataModel is set from outside.
    }

    QString name() const Q_DECL_OVERRIDE Q_DECL_FINAL
    { return string(0); }

    QScxmlExecutableContent::ContainerId initialSetup() const Q_DECL_OVERRIDE Q_DECL_FINAL
    { return -1; }

    QScxmlExecutableContent::InstructionId *instructions() const Q_DECL_OVERRIDE Q_DECL_FINAL
    { return theInstructions; }

    QScxmlExecutableContent::StringId *dataNames(int *count) const Q_DECL_OVERRIDE Q_DECL_FINAL
    { *count = 0; return dataIds; }

    QScxmlExecutableContent::EvaluatorInfo evaluatorInfo(QScxmlExecutableContent::EvaluatorId evaluatorId) const Q_DECL_OVERRIDE Q_DECL_FINAL
    { Q_ASSERT(evaluatorId >= 0); Q_ASSERT(evaluatorId < 6); return evaluators[evaluatorId]; }

    QScxmlExecutableContent::AssignmentInfo assignmentInfo(QScxmlExecutableContent::EvaluatorId assignmentId) const Q_DECL_OVERRIDE Q_DECL_FINAL
    { Q_ASSERT(assignmentId >= 0); Q_ASSERT(assignmentId < 0); return assignments[assignmentId]; }

    QScxmlExecutableContent::ForeachInfo foreachInfo(QScxmlExecutableContent::EvaluatorId foreachId) const Q_DECL_OVERRIDE Q_DECL_FINAL
    { Q_ASSERT(foreachId >= 0); Q_ASSERT(foreachId < 0); return foreaches[foreachId]; }

    QString string(QScxmlExecutableContent::StringId id) const Q_DECL_OVERRIDE Q_DECL_FINAL
    {
        Q_ASSERT(id >= QScxmlExecutableContent::NoString); Q_ASSERT(id < 8);
        if (id == QScxmlExecutableContent::NoString) return QString();
        return QString({static_cast<QStringData*>(strings.data + id)});
    }

    const qint32 *stateMachineTable() const Q_DECL_OVERRIDE Q_DECL_FINAL
    { return theStateMachineTable; }

    QScxmlInvokableServiceFactory *serviceFactory(int id) const Q_DECL_OVERRIDE Q_DECL_FINAL;

    MediaPlayerStateMachine &stateMachine;
    // Data model TheDataModel is set from outside.

    static QScxmlExecutableContent::ParameterInfo param(QScxmlExecutableContent::StringId name,
                                                        QScxmlExecutableContent::EvaluatorId expr,
                                                        QScxmlExecutableContent::StringId location)
    {
        QScxmlExecutableContent::ParameterInfo p;
        p.name = name;
        p.expr = expr;
        p.location = location;
        return p;
    }

    static QScxmlExecutableContent::InvokeInfo invoke(
            QScxmlExecutableContent::StringId id,
            QScxmlExecutableContent::StringId prefix,
            QScxmlExecutableContent::EvaluatorId expr,
            QScxmlExecutableContent::StringId location,
            QScxmlExecutableContent::StringId context,
            QScxmlExecutableContent::ContainerId finalize,
            bool autoforward)
    {
        QScxmlExecutableContent::InvokeInfo i;
        i.id = id;
        i.prefix = prefix;
        i.expr = expr;
        i.location = location;
        i.context = context;
        i.finalize = finalize;
        i.autoforward = autoforward;
        return i;
    }

    static qint32 theInstructions[];
    static QScxmlExecutableContent::StringId dataIds[];
    static QScxmlExecutableContent::EvaluatorInfo evaluators[];
    static QScxmlExecutableContent::AssignmentInfo assignments[];
    static QScxmlExecutableContent::ForeachInfo foreaches[];
    static const qint32 theStateMachineTable[];
    static struct Strings {
        QArrayData data[8];
        qunicodechar stringdata[117];
    } strings;
};

MediaPlayerStateMachine::MediaPlayerStateMachine(QObject *parent)
    : QScxmlStateMachine(&staticMetaObject, parent)
    , data(new Data(*this))
{ qRegisterMetaType<MediaPlayerStateMachine *>(); data->init(); }

MediaPlayerStateMachine::~MediaPlayerStateMachine()
{ delete data; }

QScxmlInvokableServiceFactory *MediaPlayerStateMachine::Data::serviceFactory(int id) const
{
    Q_UNUSED(id);
    Q_UNREACHABLE();
}

qint32 MediaPlayerStateMachine::Data::theInstructions[] = {
2, 1, 23, 1, 21, 6, 1, 3, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 1,
6, 2, -1, 2, 1, 21, 1, 19, 3, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
0, 1, 6, 3, -1
};

QScxmlExecutableContent::StringId MediaPlayerStateMachine::Data::dataIds[] = {
-1
};

QScxmlExecutableContent::EvaluatorInfo MediaPlayerStateMachine::Data::evaluators[] = {
{ 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }, { 0, 0 }
};

QScxmlExecutableContent::AssignmentInfo MediaPlayerStateMachine::Data::assignments[] = {
{ -1, -1, -1 }
};

QScxmlExecutableContent::ForeachInfo MediaPlayerStateMachine::Data::foreaches[] = {
{ -1, -1, -1, -1 }
};

#define STR_LIT(idx, ofs, len) \
    Q_STATIC_STRING_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
    qptrdiff(offsetof(Strings, stringdata) + ofs * sizeof(qunicodechar) - idx * sizeof(QArrayData)) \
    )
MediaPlayerStateMachine::Data::Strings MediaPlayerStateMachine::Data::strings = {{
STR_LIT(0, 0, 23), STR_LIT(1, 24, 7), STR_LIT(2, 32, 3), STR_LIT(3, 36, 7),
STR_LIT(4, 44, 33), STR_LIT(5, 78, 15), STR_LIT(6, 94, 5), STR_LIT(7, 100, 15)
},{
0x4d,0x65,0x64,0x69,0x61,0x50,0x6c,0x61,0x79,0x65,0x72,0x53,0x74,0x61,0x74,0x65,0x4d,0x61,0x63,0x68,0x69,0x6e,0x65,0, // 0: MediaPlayerStateMachine
0x73,0x74,0x6f,0x70,0x70,0x65,0x64,0, // 1: stopped
0x74,0x61,0x70,0, // 2: tap
0x70,0x6c,0x61,0x79,0x69,0x6e,0x67,0, // 3: playing
0x73,0x65,0x6e,0x64,0x20,0x69,0x6e,0x73,0x74,0x72,0x75,0x63,0x74,0x69,0x6f,0x6e,0x20,0x69,0x6e,0x20,0x73,0x74,0x61,0x74,0x65,0x20,0x70,0x6c,0x61,0x79,0x69,0x6e,0x67,0, // 4: send instruction in state playing
0x70,0x6c,0x61,0x79,0x62,0x61,0x63,0x6b,0x53,0x74,0x61,0x72,0x74,0x65,0x64,0, // 5: playbackStarted
0x6d,0x65,0x64,0x69,0x61,0, // 6: media
0x70,0x6c,0x61,0x79,0x62,0x61,0x63,0x6b,0x53,0x74,0x6f,0x70,0x70,0x65,0x64,0 // 7: playbackStopped
}};

const qint32 MediaPlayerStateMachine::Data::theStateMachineTable[] = {
	0x1, // version
	0, // name
	2, // data-model
	17, // child states array offset
	3, // transition to initial states
	-1, // initial setup
	0, // binding
	-1, // maxServiceId
	14, 2, // state offset and count
	36, 4, // transition offset and count
	60, 22, // array offset and size

	// States:
	1, -1, 0, -1, -1, -1, -1, -1, -1, 4, -1,
	3, -1, 0, -1, -1, 0, 26, -1, -1, 14, -1,

	// Transitions:
	2, 0, 1, 0, 0, -1, 
	8, 4, 1, 1, 6, -1, 
	12, 5, 1, 1, 10, -1, 
	-1, -1, 2, -1, 20, -1, 

	// Arrays:
	1, 1, 
	1, 2, 
	1, 0, 
	1, 0, 
	1, 2, 
	1, 1, 
	1, 2, 
	2, 1, 2, 
	2, 0, 1, 
	1, 0, 

	0xc0ff33 // terminator
};

struct qt_meta_stringdata_MediaPlayerStateMachine_t {
    QByteArrayData data[8];
    unsigned char stringdata0[85];
};
#define QT_MOC_LITERAL(idx, ofs, len) \
    Q_STATIC_BYTE_ARRAY_DATA_HEADER_INITIALIZER_WITH_OFFSET(len, \
    qptrdiff(offsetof(qt_meta_stringdata_MediaPlayerStateMachine_t, stringdata0) + ofs \
        - idx * sizeof(QByteArrayData)) \
    )
static const qt_meta_stringdata_MediaPlayerStateMachine_t qt_meta_stringdata_MediaPlayerStateMachine = {
    {
QT_MOC_LITERAL(0, 0, 23), // "MediaPlayerStateMachine"
QT_MOC_LITERAL(1, 24, 14), // "stoppedChanged"
QT_MOC_LITERAL(2, 39, 0), // ""
QT_MOC_LITERAL(3, 40, 6), // "active"
QT_MOC_LITERAL(4, 47, 14), // "playingChanged"
QT_MOC_LITERAL(5, 62, 6), // "parent"
QT_MOC_LITERAL(6, 69, 7), // "stopped"
QT_MOC_LITERAL(7, 77, 7) // "playing"
    },{
0x4d,0x65,0x64,0x69,0x61,0x50,0x6c,0x61,0x79,0x65,0x72,0x53,0x74,0x61,0x74,0x65,0x4d,0x61,0x63,0x68,0x69,0x6e,0x65,0, // 0: MediaPlayerStateMachine
0x73,0x74,0x6f,0x70,0x70,0x65,0x64,0x43,0x68,0x61,0x6e,0x67,0x65,0x64,0, // 1: stoppedChanged
0, // 2: 
0x61,0x63,0x74,0x69,0x76,0x65,0, // 3: active
0x70,0x6c,0x61,0x79,0x69,0x6e,0x67,0x43,0x68,0x61,0x6e,0x67,0x65,0x64,0, // 4: playingChanged
0x70,0x61,0x72,0x65,0x6e,0x74,0, // 5: parent
0x73,0x74,0x6f,0x70,0x70,0x65,0x64,0, // 6: stopped
0x70,0x6c,0x61,0x79,0x69,0x6e,0x67,0 // 7: playing
    }};
#undef QT_MOC_LITERAL

static const uint qt_meta_data_MediaPlayerStateMachine[] = {

 // content:
       7,       // revision
       0,       // classname
       0,    0, // classinfo
       2,   14, // methods
       2,   33, // properties
       0,    0, // enums/sets
       1,   41, // constructors
       0,       // flags
       2,       // signalCount

 // signals: name, argc, parameters, tag, flags
       1,    1,   24,    2, 0x06 /* Public */,
       4,    1,   27,    2, 0x06 /* Public */,

 // signals: parameters
    QMetaType::Void, QMetaType::Bool,    3,
    QMetaType::Void, QMetaType::Bool,    3,

 // constructors: parameters
    0x80000000 | 2, QMetaType::QObjectStar,    5,

 // properties: name, type, flags
       6, QMetaType::Bool, 0x006a6001,
       7, QMetaType::Bool, 0x006a6001,

 // properties: notify_signal_id
       0,
       1,

 // constructors: name, argc, parameters, tag, flags
       0,    1,   30,    2, 0x0e /* Public */,

       0        // eod
};

void MediaPlayerStateMachine::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
    if (_c == QMetaObject::CreateInstance) {
        switch (_id) {
        case 0: { MediaPlayerStateMachine *_r = new MediaPlayerStateMachine((*reinterpret_cast< QObject **>(_a[1])));
            if (_a[0]) *reinterpret_cast<QObject**>(_a[0]) = _r; } break;
        default: break;
        }
    } else if (_c == QMetaObject::InvokeMetaMethod) {
        MediaPlayerStateMachine *_t = static_cast<MediaPlayerStateMachine *>(_o);
        Q_UNUSED(_t)
        switch (_id) {
        case 0: QMetaObject::activate(_o, &staticMetaObject, 0, _a); break;
        case 1: QMetaObject::activate(_o, &staticMetaObject, 1, _a); break;
        default: ;
        }
    } else if (_c == QMetaObject::IndexOfMethod) {
        int *result = reinterpret_cast<int *>(_a[0]);
        void **func = reinterpret_cast<void **>(_a[1]);
        Q_UNUSED(result);
        Q_UNUSED(func);
    }
#ifndef QT_NO_PROPERTIES
    else if (_c == QMetaObject::ReadProperty) {
        MediaPlayerStateMachine *_t = static_cast<MediaPlayerStateMachine *>(_o);
        Q_UNUSED(_t)
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< bool*>(_v) = _t->isActive(0); break;
        case 1: *reinterpret_cast< bool*>(_v) = _t->isActive(1); break;
        default: break;
        }
    } else if (_c == QMetaObject::WriteProperty) {
    } else if (_c == QMetaObject::ResetProperty) {
    }
#endif // QT_NO_PROPERTIES
}

const QMetaObject MediaPlayerStateMachine::staticMetaObject = {
    { &QScxmlStateMachine::staticMetaObject, qt_meta_stringdata_MediaPlayerStateMachine.data,
      qt_meta_data_MediaPlayerStateMachine,  qt_static_metacall, Q_NULLPTR, Q_NULLPTR}
};


const QMetaObject *MediaPlayerStateMachine::metaObject() const
{
    return QObject::d_ptr->metaObject ? QObject::d_ptr->dynamicMetaObject() : &staticMetaObject;
}

void *MediaPlayerStateMachine::qt_metacast(const char *_clname)
{
    if (!_clname) return Q_NULLPTR;
    if (!strcmp(_clname, reinterpret_cast<const char *>(
            qt_meta_stringdata_MediaPlayerStateMachine.stringdata0)))
        return static_cast<void*>(const_cast< MediaPlayerStateMachine*>(this));
    return QScxmlStateMachine::qt_metacast(_clname);
}

int MediaPlayerStateMachine::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QScxmlStateMachine::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 2)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 2;
    } else if (_c == QMetaObject::RegisterMethodArgumentMetaType) {
        if (_id < 2)
            *reinterpret_cast<int*>(_a[0]) = -1;
        _id -= 2;
    }
#ifndef QT_NO_PROPERTIES
   else if (_c == QMetaObject::ReadProperty || _c == QMetaObject::WriteProperty
            || _c == QMetaObject::ResetProperty || _c == QMetaObject::RegisterPropertyMetaType) {
        qt_static_metacall(this, _c, _id, _a);
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 2;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 2;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}


QString TheDataModel::evaluateToString(QScxmlExecutableContent::EvaluatorId id, bool *ok)
{
    *ok = true;
    Q_UNUSED(id);
    Q_UNREACHABLE();
    *ok = false;
    return QString();
}

bool TheDataModel::evaluateToBool(QScxmlExecutableContent::EvaluatorId id, bool *ok)
{
    *ok = true;
    switch (id) {
    case 5:
        return [this]()->bool{ return isValidMedia() && media != eventData().value(QStringLiteral("media")); }();
    case 4:
        return [this]()->bool{ return !isValidMedia() || media == eventData().value(QStringLiteral("media")); }();
    case 0:
        return [this]()->bool{ return isValidMedia(); }();
    default: break;
    }
    Q_UNREACHABLE();
    *ok = false;
    return false;
}

QVariant TheDataModel::evaluateToVariant(QScxmlExecutableContent::EvaluatorId id, bool *ok)
{
    *ok = true;
    switch (id) {
    case 2:
        return [this]()->QVariant{ return media; }();
    case 3:
        return [this]()->QVariant{ return media; }();
    default: break;
    }
    Q_UNREACHABLE();
    *ok = false;
    return QVariant();
}

void TheDataModel::evaluateToVoid(QScxmlExecutableContent::EvaluatorId id, bool *ok)
{
    *ok = true;
    switch (id) {
    case 1:
        [this]()->void{ media = eventData().value(QStringLiteral("media")).toString(); }();
        return;
    default: break;
    }
    Q_UNREACHABLE();
    *ok = false;
}
