FireSTARR
Loading...
Searching...
No Matches
LogPoints.h
1/* SPDX-License-Identifier: AGPL-3.0-or-later */
2#ifndef FS_LOG_POINTS_H
3#define FS_LOG_POINTS_H
4#include "stdafx.h"
5namespace fs
6{
7constexpr auto STAGE_CONDENSE = 'C';
8constexpr auto STAGE_NEW = 'N';
9constexpr auto STAGE_SPREAD = 'S';
10constexpr auto STAGE_INVALID = 'X';
12{
13public:
14 ~LogPoints();
15 LogPoints() noexcept = default;
17 const string_view output_directory,
18 bool do_log,
19 size_t id,
20 DurationSize start_time
21 ) noexcept;
22 bool isLogging() const noexcept;
23 void log(size_t step, const char stage, const DurationSize time, const XYSize x, const XYSize y)
24 const noexcept;
25 template <std::ranges::forward_range R>
26 void log(size_t step, const char stage, const DurationSize time, const R& points) const noexcept
27 {
28 assert(!points.empty() && "Logging empty points");
29 // don't loop if not logging
30 if (isLogging())
31 {
32 for (const auto& p : points)
33 {
34 log_unchecked(step, stage, time, p.x.value, p.y.value);
35 }
36 }
37 }
38 void log(size_t step, const char stage, const DurationSize time, const auto& points)
39 const noexcept
40 {
41 // don't loop if not logging
42 if (isLogging())
43 {
44 log(step, stage, time, points.unique());
45 }
46 };
47
48protected:
49 void log_unchecked(
50 size_t step,
51 const char stage,
52 const DurationSize time,
53 const XYSize x,
54 const XYSize y
55 ) const noexcept;
56
57private:
58 size_t id_{};
59 DurationSize start_time_{};
60 mutable char last_stage_{};
61 mutable size_t last_step_{};
62#ifdef DEBUG_POINTS
63 mutable DurationSize last_time_{};
64#endif
65 mutable string stage_id_{};
66 mutable ofstream log_points_{};
67 mutable ofstream log_stages_{};
68};
69};
70#endif
Definition LogPoints.h:12