Brenta Engine 1.2
Loading...
Searching...
No Matches
subsystem.hpp
1// SPDX-License-Identifier: MIT
2// Author: Giovanni Santini
3// Mail: giovanni.santini@proton.me
4// Github: @San7o
5
6#pragma once
7
8#include <expected>
9#include <string>
10
11namespace brenta
12{
13
14//
15// Subsystem interface
16// -------------------
17//
18// A subsistem is a static singleton that can be initialized and
19// terminated. The initialization settings should be passed via a
20// builder class.
21//
23{
24public:
25
26 using Error = std::string;
27
28 class Builder;
29
30 virtual ~Subsystem() = default;
31
32 virtual std::expected<void, Subsystem::Error> initialize() = 0;
33 virtual std::expected<void, Subsystem::Error> terminate() = 0;
34
35 // Returns the name of the sybsystem
36 virtual std::string name() = 0;
37 // Returns true if the subsystem is initialized
38 virtual bool is_initialized() = 0;
39};
40
41//
42// Builder interface
43//
44// Interface to build a subsystem. It does not initialize it.
45//
47{
48public:
49 virtual ~Builder() = default;
50
51 virtual Subsystem &build() = 0;
52};
53
54} // namepsace brenta