VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
LoadReport.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <chrono>
5#include <string>
6#include <string_view>
7#include <vector>
8
9namespace VoltMod
10{
11
12/** A check that failed while a plugin loaded. */
14{
15 std::string Name;
16 std::string Reason;
17 bool Required = false; ///< A required failure refuses the plugin.
18};
19
20/**
21 * What went wrong while one plugin loaded. The runtime checks its own services here, and plugin
22 * members and `Plugin::Load` add theirs. @ref Plugin logs @ref Summary and refuses the load with
23 * @ref AbortReason.
24 */
26{
27public:
28 /** Record @p result; a failure disables that feature. Returns whether it succeeded. */
29 bool Optional(std::string_view name, Status result);
30
31 /** Record @p result; a failure refuses the plugin. Returns whether it succeeded. */
32 bool Required(std::string_view name, Status result);
33
34 /** `Load took N ms`, then one line per failure. */
35 std::string Summary() const;
36
37 /** `<name>: <reason>` for the first required failure; empty when none failed. */
38 std::string AbortReason() const;
39
40 const std::vector<FailedCheck>& Failures() const { return _failures; }
41
42private:
43 bool Record(std::string_view name, Status result, bool required);
44
45 std::vector<FailedCheck> _failures;
46 std::chrono::steady_clock::time_point _started = std::chrono::steady_clock::now();
47};
48
49} // namespace VoltMod
std::string Summary() const
std::string AbortReason() const
bool Optional(std::string_view name, Status result)
Definition LoadReport.cpp:9
const std::vector< FailedCheck > & Failures() const
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
std::expected< void, Error > Status
Definition Result.hpp:67
std::false_type Required
Definition Table.hpp:13