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#include <brenta/renderer.hpp>
29
30#include <functional>
31
32namespace brenta
33{
34
46class engine : public subsystem
47{
48public:
49
50 class manager;
51 class builder;
52
53 static const std::string subsystem_name;
54
55 // Subsystem interface
56 std::expected<void, subsystem::error> initialize() override;
57 std::expected<void, subsystem::error> terminate() override;
58 std::string name() override;
59 bool is_initialized() override;
60
61 // Constructors / destructors
62 engine() = default;
63 ~engine() = default;
64
65 // Member functions
69 static engine &instance();
70 static engine::manager managed();
71
76 static std::expected<void, std::string>
78
79private:
80
81 static std::vector<std::reference_wrapper<subsystem>> subsystems;
82 static bool initialized;
83
84};
85
90{
91public:
95 manager();
99 ~manager();
100};
101
108{
109private:
110
111 std::vector<std::reference_wrapper<brenta::subsystem>> subsystems;
112
113public:
114
115 builder() = default;
116 ~builder() = default;
117
120 brenta::subsystem &build() override;
121
122};
123
124} // namespace brenta
Engine builder.
Definition engine.hpp:108
Automatically initialize and terminate engine with RAII.
Definition engine.hpp:90
~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:47
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