cpp-stat-bench 0.24.0
Benchmark library with statistics for C++.
Loading...
Searching...
No Matches
parameter_config.h
Go to the documentation of this file.
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 */
20#pragma once
21
22#include <algorithm>
23#include <memory>
24#include <utility>
25#include <vector>
26
30
31namespace stat_bench {
32namespace param {
33
38public:
42 ParameterConfig() = default;
43
51 template <typename T>
52 [[nodiscard]] auto add(const ParameterName& param_name)
53 -> std::shared_ptr<ParameterValueVector<T>> {
54 auto vec = std::make_shared<ParameterValueVector<T>>();
55 params_.emplace_back(param_name, vec);
56 return vec;
57 }
58
65 [[nodiscard]] auto has(const ParameterName& param_name) const -> bool {
66 return std::find_if(params_.begin(), params_.end(),
67 [&param_name](const std::pair<ParameterName,
68 std::shared_ptr<IParameterValueVector>>& pair) {
69 return pair.first == param_name;
70 }) != params_.end();
71 }
72
78 [[nodiscard]] auto create_generator() const {
79 return ParameterGenerator(params_);
80 }
81
82private:
84 std::vector<
85 std::pair<ParameterName, std::shared_ptr<IParameterValueVector>>>
86 params_{};
87};
88
89} // namespace param
90} // namespace stat_bench
ParameterConfig()=default
Constructor.
auto create_generator() const
Create a generator of parameter dictionaries.
auto add(const ParameterName &param_name) -> std::shared_ptr< ParameterValueVector< T > >
Add a parameter.
auto has(const ParameterName &param_name) const -> bool
Check whether a parameter exists.
Class of generators of parameter dictionaries.
Class of names of parameters.
Namespace of parameters of benchmarks.
Namespace of stat_bench source codes.
Definition of ParameterGenerator class.
Definition of ParameterName class.
Definition of ParameterValueVector class.