Simo 0.0.1
Loading...
Searching...
No Matches
Statistic.h
1/*
2 * Copyright 2026 Matteo Fusi and Contributors
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#ifndef SIMO_STATISTIC_HH
18#define SIMO_STATISTIC_HH
19
20#include <Simo/compiler/BoostTypeIndexRuntimeCast.h>
21
22#include <glaze/glaze.hpp>
23
24namespace Simo::Statistics {
26class Statistic {
27 public:
28 virtual ~Statistic() = default;
29 BOOST_TYPE_INDEX_REGISTER_RUNTIME_CLASS()
30
31 Statistic() = default;
32
34 [[nodiscard]] virtual std::unique_ptr<Statistic> clone() const = 0;
35
38 [[nodiscard]] virtual std::unique_ptr<Statistic> compute_delta(
39 const Statistic& other) const = 0;
40
41 virtual void assign_from(const Statistic& other) = 0;
42
43 [[nodiscard]] std::string_view name() const { return name_; }
44 void name(std::string_view new_name) { name_ = new_name; }
45
46 [[nodiscard]] virtual glz::generic_u64 dump_representation() const = 0;
47
48 protected:
49 std::string name_;
50
51 explicit Statistic(const std::string_view name) : name_(name) {}
52};
53} // namespace Simo::Statistics
54
55#endif // SIMO_STATISTIC_HH
virtual std::unique_ptr< Statistic > compute_delta(const Statistic &other) const =0
virtual std::unique_ptr< Statistic > clone() const =0
Create a new copy of this statistic.