Ejemplo n.º 1
0
void InputBinder::bind_scene_entity_inputs(
    const Scene&                    scene,
    const SymbolTable&              scene_symbols,
    const char*                     entity_type,
    ConnectableEntity&              entity)
{
    const string entity_path = entity.get_path();
    const ParamArray& entity_params = entity.get_parameters();

    for (each<InputArray> i = entity.get_inputs(); i; ++i)
    {
        InputArray::iterator& input = *i;
        string param_value;

        if (entity_params.strings().exist(input.name()))
        {
            // A value is assigned to this input, retrieve it.
            param_value = entity_params.get<string>(input.name());
        }
        else if (input.type() == InputTypeOptional)
        {
            // This input is optional, use its default value.
            param_value = input.default_value();
            if (param_value.empty())
                continue;
        }
        else
        {
            // This input is required but has no value, this is an error.
            RENDERER_LOG_ERROR(
                "while defining %s \"%s\": required parameter \"%s\" missing.",
                entity_type,
                entity_path.c_str(),
                input.name());
            ++m_error_count;
            continue;
        }

        if (try_bind_scene_entity_to_input(
                scene,
                scene_symbols,
                entity_type,
                entity_path.c_str(),
                param_value.c_str(),
                input))
            continue;

        if (try_bind_scalar_to_input(param_value, input))
            continue;

        RENDERER_LOG_ERROR(
            "while defining %s \"%s\": cannot bind \"%s\" to parameter \"%s\".",
            entity_type,
            entity_path.c_str(),
            param_value.c_str(),
            input.name());

        ++m_error_count;
    }
}
Ejemplo n.º 2
0
    void collect_relations_from_entity(ConnectableEntity& entity)
    {
        for (const auto& input : entity.get_inputs())
        {
            const auto referenced_entity =
                m_input_binder.find_referenced_entity(entity, input);

            if (referenced_entity.m_entity != nullptr)
                insert_relation(referenced_entity, entity, input.name());
        }
    }