コード例 #1
0
void Visitor<Writer<DataStream>>::writeTo(ScenarioModel& scenario)
{
    scenario.pluginModelList = new iscore::ElementPluginModelList{*this, &scenario};

    m_stream >> scenario.m_startTimeNodeId
             >> scenario.m_endTimeNodeId;
    m_stream >> scenario.m_startEventId
             >> scenario.m_endEventId;

    // Timenodes
    int timenode_count;
    m_stream >> timenode_count;

    for(; timenode_count -- > 0;)
    {
        auto tnmodel = new TimeNodeModel {*this, &scenario};
        scenario.addTimeNode(tnmodel);
    }

    // Events
    int event_count;
    m_stream >> event_count;

    for(; event_count -- > 0;)
    {
        auto evmodel = new EventModel {*this, &scenario};
        scenario.addEvent(evmodel);
    }

    // Events
    int state_count;
    m_stream >> state_count;

    for(; state_count -- > 0;)
    {
        auto stmodel = new StateModel {*this, &scenario};
        scenario.addDisplayedState(stmodel);
    }

    // Constraints
    int constraint_count;
    m_stream >> constraint_count;

    for(; constraint_count -- > 0;)
    {
        auto constraint = new ConstraintModel {*this, &scenario};
        scenario.addConstraint(constraint);
    }

    checkDelimiter();
}
コード例 #2
0
void Visitor<Writer<JSONObject>>::writeTo(ScenarioModel& scenario)
{
    Deserializer<JSONValue> elementPluginDeserializer(m_obj["PluginsMetadata"]);
    scenario.pluginModelList = new iscore::ElementPluginModelList{elementPluginDeserializer, &scenario};

    scenario.m_startTimeNodeId = fromJsonValue<id_type<TimeNodeModel>> (m_obj["StartTimeNodeId"]);
    scenario.m_endTimeNodeId = fromJsonValue<id_type<TimeNodeModel>> (m_obj["EndTimeNodeId"]);
    scenario.m_startEventId = fromJsonValue<id_type<EventModel>> (m_obj["StartEventId"]);
    scenario.m_endEventId = fromJsonValue<id_type<EventModel>> (m_obj["EndEventId"]);

    for(const auto& json_vref : m_obj["TimeNodes"].toArray())
    {
        auto tnmodel = new TimeNodeModel {
                       Deserializer<JSONObject>{json_vref.toObject() },
                       &scenario};

        scenario.addTimeNode(tnmodel);
    }

    for(const auto& json_vref : m_obj["Events"].toArray())
    {
        auto evmodel = new EventModel {
                       Deserializer<JSONObject>{json_vref.toObject() },
                       &scenario};

        scenario.addEvent(evmodel);
    }

    for(const auto& json_vref : m_obj["States"].toArray())
    {
        auto stmodel = new StateModel {
                       Deserializer<JSONObject>{json_vref.toObject() },
                       &scenario};

        scenario.addDisplayedState(stmodel);
    }

    for(const auto& json_vref : m_obj["Constraints"].toArray())
    {
        auto constraint = new ConstraintModel{
                Deserializer<JSONObject>{json_vref.toObject() },
                &scenario};
        scenario.addConstraint(constraint);
    }
}