コード例 #1
0
SerializedConstraintViewModels serializeConstraintViewModels(
        const ConstraintModel& constraint,
        const ScenarioModel& scenario)
{
    SerializedConstraintViewModels map;
    // The other constraint view models are in their respective scenario view models
    for(const auto& viewModel : layers(scenario))
    {
        const ConstraintViewModel& cstrVM = viewModel->constraint(constraint.id());

        auto lm_id = iscore::IDocument::path(*viewModel);
        QByteArray arr;

        if(const auto& temporalCstrVM = dynamic_cast<const TemporalConstraintViewModel*>(&cstrVM))
        {
            Serializer<DataStream> cvmReader{&arr};
            cvmReader.readFrom(*temporalCstrVM);
        }
        else
        {
            ISCORE_TODO;
        }

        map.append({lm_id, {cstrVM.type(), arr}});
    }

    return map;
}
SerializedConstraintViewModels serializeConstraintViewModels(
        const ConstraintModel& constraint,
        const ScenarioModel& scenario)
{
    SerializedConstraintViewModels map;
    // The other constraint view models are in their respective scenario view models
    for(const auto& viewModel : layers(scenario))
    {
        // TODO we need to know its concrete type in order to serialize it correctly.
        const auto& cstrVM = viewModel->constraint(constraint.id());
        if(const auto& temporalCstrVM = dynamic_cast<const TemporalConstraintViewModel*>(&cstrVM))
        {
            auto lm_id = iscore::IDocument::path(viewModel);

            QByteArray arr;
            Serializer<DataStream> cvmReader{&arr};
            cvmReader.readFrom(*temporalCstrVM);

            map.append({lm_id, {"Temporal", arr}});
        }
        else
        {
            ISCORE_TODO
        }
    }

    return map;
}