Coverage Report

Created: 2025-07-06 13:16

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/builds/MusicScience37Projects/utility-libraries/cpp-stat-bench/src/stat_bench/param/parameter_generator.cpp
Line
Count
Source
1
/*
2
 * Copyright 2021 MusicScience37 (Kenta Kabashima)
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
/*!
17
 * \file
18
 * \brief Implementation of ParameterGenerator class.
19
 */
20
#include "stat_bench/param/parameter_generator.h"
21
22
#include "stat_bench/param/parameter_name.h"
23
#include "stat_bench/param/parameter_value.h"
24
#include "stat_bench/util/ordered_map.h"
25
26
namespace stat_bench {
27
namespace param {
28
29
ParameterGenerator::ParameterGenerator(const std::vector<
30
64
    std::pair<ParameterName, std::shared_ptr<IParameterValueVector>>>& params) {
31
64
    params_.reserve(params.size());
32
64
    for (const auto& param : params) {
33
48
        if (param.second->size() == 0) {
34
0
            continue;
35
0
        }
36
48
        params_.push_back(ParamData{param.first, param.second,
37
48
            param.second->begin(), param.second->begin(), param.second->end()});
38
48
    }
39
64
}
40
41
264
auto ParameterGenerator::iterate() -> bool {
42
384
    for (auto iter = params_.rbegin(); iter != params_.rend(); ++iter) {
43
320
        ++(iter->next);
44
320
        if (iter->next != iter->end) {
45
200
            return true;
46
200
        }
47
120
        iter->next = iter->begin;
48
120
    }
49
64
    return false;
50
264
}
51
52
264
auto ParameterGenerator::generate() const -> ParameterDict {
53
264
    util::OrderedMap<ParameterName, ParameterValue> data;
54
264
    data.reserve(params_.size());
55
636
    for (const auto& param : params_) {
56
636
        data.try_emplace(param.name, *param.next);
57
636
    }
58
264
    return ParameterDict(data);
59
264
}
60
61
}  // namespace param
62
}  // namespace stat_bench