Brenta Engine 1.2
Loading...
Searching...
No Matches
engine.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 <brenta/audio.hpp>
9#include <brenta/buffer.hpp>
10#include <brenta/camera.hpp>
11#include <brenta/frame_buffer.hpp>
12#include <brenta/gl.hpp>
13#include <brenta/gui.hpp>
14#include <brenta/input.hpp>
15#include <brenta/logger.hpp>
16#include <brenta/mesh.hpp>
17#include <brenta/model.hpp>
18#include <brenta/particles.hpp>
19#include <brenta/window.hpp>
20#include <brenta/shader.hpp>
21#include <brenta/text.hpp>
22#include <brenta/texture.hpp>
23#include <brenta/time.hpp>
24#include <brenta/translation.hpp>
25#include <brenta/vao.hpp>
26#include <brenta/subsystem.hpp>
27#include <brenta/ecs.hpp>
28
29#include <functional>
30
31namespace brenta
32{
33
45class engine : public subsystem
46{
47public:
48
49 class manager;
50 class builder;
51
52 static const std::string subsystem_name;
53
54 // Subsystem interface
55 std::expected<void, subsystem::error> initialize() override;
56 std::expected<void, subsystem::error> terminate() override;
57 std::string name() override;
58 bool is_initialized() override;
59
60 // Constructors / destructors
61 engine() = default;
62 ~engine() = default;
63
64 // Member functions
68 static engine &instance();
69 static engine::manager managed();
70
75 static std::expected<void, std::string>
77
78private:
79
80 static std::vector<std::reference_wrapper<subsystem>> subsystems;
81 static bool initialized;
82
83};
84
89{
90public:
94 manager();
98 ~manager();
99};
100
107{
108private:
109
110 std::vector<std::reference_wrapper<brenta::subsystem>> subsystems;
111
112public:
113
114 builder() = default;
115 ~builder() = default;
116
119 brenta::subsystem &build() override;
120
121};
122
123} // namespace brenta
Engine builder.
Definition engine.hpp:107
Automatically initialize and terminate engine with RAII.
Definition engine.hpp:89
~manager()
Terminates all subsystems.
Definition engine.cpp:107
manager()
Initializes all subsystems, throws and exeption in case of failure.
Definition engine.cpp:96
Engine class.
Definition engine.hpp:46
std::string name() override
Returns the name of the sybsystem.
Definition engine.cpp:61
static std::expected< void, std::string > with(subsystem::builder &&builder)
Initialize a subsystem and add it to the managed subsystems (will be terminated with the others).
Definition engine.cpp:87
bool is_initialized() override
Returns true if the subsystem is initialized.
Definition engine.cpp:66
static engine & instance()
Get a static object instance.
Definition engine.cpp:75
Builder interface.
Definition subsystem.hpp:49
Subsystem interface.
Definition subsystem.hpp:22