Sound Bakery  v0.1.0
Open-source audio middleware for games
Loading...
Searching...
No Matches
system.h
1#pragma once
2
3#include "sound_bakery/core/core_fwd.h"
4#include "sound_bakery/core/database/database.h"
5#include "sound_bakery/core/database/database_ptr.h"
6#include "sound_bakery/core/object/object_tracker.h"
7#include "spdlog/sinks/basic_file_sink.h"
8
9namespace sbk
10{
11 namespace core
12 {
13 class object_owner;
14 }
15
16 namespace editor
17 {
18 class project;
19 } // namespace editor
20
21 namespace engine
22 {
23 namespace profiling
24 {
25 class voice_tracker;
26 }
27
28 class bus;
29 class game_object;
30
38 class SB_CLASS system final : public sc_system,
42 public concurrencpp::runtime,
43 public boost::noncopyable
44 {
45 REGISTER_REFLECTION(system)
46 LEAK_DETECTOR(system)
47
48 public:
49 enum class operating_mode
50 {
51 unkown, //< Unkown/unset
52 editor, //< We have a project
53 runtime //< We are loading soundbanks
54 };
55
56 public:
57 system();
58 ~system();
59
60 static auto create() -> system*;
61 static auto init(const sb_system_config& config) -> sc_result;
62 static auto update() -> sc_result;
63 static auto destroy() -> void;
64
65 [[nodiscard]] static auto get() -> system*;
66 [[nodiscard]] static auto get_operating_mode() -> operating_mode;
67 [[nodiscard]] static auto get_project() -> sbk::editor::project*;
68 [[nodiscard]] static auto get_voice_tracker() -> sbk::engine::profiling::voice_tracker*;
69 [[nodiscard]] auto get_game_thread_executer() const -> std::shared_ptr<concurrencpp::manual_executor>;
70 [[nodiscard]] auto get_listener_game_object() const -> sbk::engine::game_object*;
71 [[nodiscard]] auto get_master_bus() const -> sbk::engine::bus*;
72 [[nodiscard]] auto get_current_object_owner() -> sbk::core::object_owner*; //< Either project for editor or system for runtime
73
77 static auto open_project(const std::filesystem::path& project_file) -> sc_result;
78
82 static auto create_project(const std::filesystem::directory_entry& projectDirectory,
83 const std::string& projectName) -> sc_result;
84
85 static auto load_soundbank(const std::filesystem::path& file) -> sb_result;
86
87 auto set_master_bus(const std::shared_ptr<sbk::engine::bus>& masterBus) -> void;
88
89 friend class boost::serialization::access;
90
91 template <class archive_class>
92 void serialize(archive_class& archive, const unsigned int version)
93 {
94 }
95
96 private:
97 bool m_registeredReflection = false;
98
99 std::shared_ptr<sbk::engine::game_object> m_listenerGameObject;
100 std::shared_ptr<sbk::engine::bus> m_masterBus;
101 std::unique_ptr<sbk::editor::project> m_project;
102 std::unique_ptr<profiling::voice_tracker> m_voiceTracker;
103 std::shared_ptr<concurrencpp::manual_executor> m_gameThreadExecuter;
104 std::shared_ptr<spdlog::logger> m_logger;
105 };
106 } // namespace engine
107} // namespace sbk
Runtime lookup of objects, using their ID or name.
Definition database.h:15
Creates, owns and tracks objects.
Definition object_owner.h:13
Tracks object categories and types.
Definition object_tracker.h:18
Manages a project file and the objects contained within it.
Definition project.h:19
Definition bus.h:10
Definition gameobject.h:14
Tracks every active voice with helper functions.
Definition voice_tracker.h:15
Manager of the whole Sound Bakery.
Definition system.h:44
Definition sound_bakery_common.h:24
Object that manages the node graph, sounds, output etc.
Definition sound_chef_common.h:239