IceShard 1
A personal game engine project, with development focused on 2D/2.5D games.
Loading...
Searching...
No Matches
module_register.hxx
Go to the documentation of this file.
1
3
4#pragma once
7#include <ice/string.hxx>
8#include <ice/stringid.hxx>
9#include <ice/array.hxx>
11#include <ice/module_query.hxx>
12#include <ice/module.hxx>
13
14namespace ice
15{
16
19 {
20 public:
21 virtual ~ModuleRegister() noexcept = default;
22
27 virtual bool load_module(
30 ) noexcept = 0;
31
37 virtual bool load_module(
39 ice::FnModuleLoad* load_fn,
40 ice::FnModuleUnload* unload_fn,
41 bool from_shared_library
42 ) noexcept = 0;
43
45 virtual bool load_module(ice::Allocator& alloc, ice::ModuleInfo const& module_info) noexcept
46 {
47 return this->load_module(alloc, module_info.fn_load, module_info.fn_unload, true);
48 }
49
51 template<typename T> requires (ice::concepts::ModuleType<T> || ice::concepts::ModuleLoadable<T>)
53 {
54 return this->load_module(alloc, T::module_info());
55 }
56 };
57
63 ice::ModuleRegister& modules_register
64 ) noexcept -> ice::u32;
65
71 bool load_global_modules = true
72 ) noexcept -> ice::UniquePtr<ice::ModuleRegister>;
73
74} // namespace ice
Type to manage loading and unloading of modules and their APIs.
Definition module_register.hxx:19
virtual ~ModuleRegister() noexcept=default
virtual bool load_module(ice::Allocator &alloc, ice::String path) noexcept=0
Loads a module from a given path.
bool load_module(ice::Allocator &alloc) noexcept
Loads a module using a module type. This is the preferred way of loading modules implicitly.
Definition module_register.hxx:52
Definition module_concepts.hxx:41
Definition module_concepts.hxx:54
Definition path_utils.hxx:10
SPDX-License-Identifier: MIT.
Definition array.hxx:12
ice::BasicString< char > String
Definition string.hxx:82
void(ice::Allocator *, ice::ModuleNegotiatorAPIContext *, ice::ModuleNegotiatorAPI *) FnModuleLoad
Definition module_types.hxx:23
auto alloc(ice::usize size) noexcept -> ice::AllocResult
auto load_global_modules(ice::Allocator &alloc, ice::ModuleRegister &modules_register) noexcept -> ice::u32
Loads all modules available in the current executable.
void(ice::Allocator *) FnModuleUnload
Definition module_types.hxx:24
std::uint32_t u32
Definition types.hxx:26
ice::AllocatorBase< ice::build::is_debug||ice::build::is_develop > Allocator
Definition mem_types.hxx:25
auto create_default_module_register(ice::Allocator &alloc, bool load_global_modules=true) noexcept -> ice::UniquePtr< ice::ModuleRegister >
Creates a default module register.
Stores information of module load and unload functions.
Definition module_info.hxx:12
Definition module_query.hxx:14
Definition mem_unique_ptr.hxx:25