Sound Bakery  v0.1.0
Open-source audio middleware for games
Loading...
Searching...
No Matches
database.h
1#pragma once
2
3#include "sound_bakery/core/database/database_object.h"
4
5namespace sbk::core
6{
14 class SB_CLASS database
15 {
16 public:
17 void add_object_to_database(const std::shared_ptr<database_object>& object);
18 void remove_object_from_database(sbk_id objectID);
19
20 [[nodiscard]] std::weak_ptr<database_object> try_find(sbk_id objectID) const;
21 [[nodiscard]] std::weak_ptr<database_object> try_find(std::string_view name) const;
22
23 [[nodiscard]] std::vector<std::weak_ptr<database_object>> get_all() const;
24
25 void clear_database() noexcept;
26
27 private:
28 static sbk_id create_new_id();
29 static std::string create_new_name(const rttr::type& type);
30
31 void update_id(sbk_id oldID, sbk_id newID);
32 void update_name(std::string_view oldName, std::string_view newName);
33 void on_object_destroyed(object* object);
34
35 std::unordered_map<sbk_id, std::weak_ptr<database_object>> m_idToPointerMap;
36 std::unordered_map<std::string, sbk_id> m_nameToIdMap;
37 };
38} // namespace sbk::core
Runtime lookup of objects, using their ID or name.
Definition database.h:15