IceShard
1
A personal game engine project, with development focused on 2D/2.5D games.
Toggle main menu visibility
Loading...
Searching...
No Matches
modules
public
ice
module_query.hxx
Go to the documentation of this file.
1
3
4
#pragma once
5
#include <
ice/array.hxx
>
6
#include <
ice/stringid.hxx
>
7
#include <
ice/module_info.hxx
>
8
#include <
ice/module_concepts.hxx
>
9
10
namespace
ice
11
{
12
13
struct
ModuleQuery
14
{
15
virtual
~ModuleQuery
() noexcept = default;
16
22
virtual
bool
query_api
(
23
ice
::
StringID_Arg
api_name,
24
ice
::
u32
version,
25
ice
::
ModuleAPI
& out_api
26
) const noexcept;
27
35
virtual
bool
query_apis
(
36
ice
::
StringID_Arg
api_name,
37
ice
::
u32
version,
38
ice
::
ModuleAPI
* out_array,
39
ice
::
u32
* inout_array_size
40
) const noexcept = 0;
41
46
template<typename Type> requires (
ice
::
concepts
::APIType<Type>)
47
bool
query_api
(Type& api_struct) const noexcept;
48
55
template<typename Type> requires (
ice
::
concepts
::APIType<Type>)
56
bool
query_apis
(
ice
::
Array
<Type>& out_apis) const noexcept;
57
};
58
59
inline
bool
ModuleQuery
::
query_api
(
60
ice
::
StringID_Arg
api_name,
61
ice
::
u32
api_version,
62
ice
::
ModuleAPI
& out_api
63
) const noexcept
64
{
65
ice::u32
idx = 1;
66
return
query_apis
(api_name, api_version, &out_api, &idx);
67
}
68
69
template
<
typename
Type>
requires
(
ice::concepts::APIType<Type>
)
70
inline
bool
ModuleQuery::query_api
(Type& api_struct)
const
noexcept
71
{
72
ice::ModuleAPI
api_info;
73
bool
const
found = this->
query_api
(Type::Constant_APIName, Type::Constant_APIVersion, api_info);
74
if
(found)
75
{
76
api_struct = *
reinterpret_cast<
Type*
>
(api_info.
api_ptr
);
77
}
78
return
found;
79
}
80
81
template
<
typename
Type>
requires
(
ice::concepts::APIType<Type>
)
82
bool
ModuleQuery::query_apis
(
ice::Array<Type>
& out_apis)
const
noexcept
83
{
84
ice::u32
num_apis = 0;
85
if
(
query_apis
(Type::Constant_APIName, Type::Constant_APIVersion,
nullptr
, &num_apis))
86
{
87
// ICE_LOG_IF(
88
// num_apis > 10,
89
// ice::LogSeverity::Warning, ice::LogTag::Engine,
90
// "More than 10 APIs of type {} where queried ({}).\n"
91
// "Use 'query_apis(ice::StringID_Arg, ice::u32, ice::ModuleAPI*, ice::u32*)' instead to avoid truncating results.",
92
// num_apis, Type::Constant_APIName
93
// );
94
95
ice::ModuleAPI
temp_tab[10];
96
query_apis
(Type::Constant_APIName, Type::Constant_APIVersion, temp_tab, &num_apis);
97
98
// Fill the array with the found APIs
99
out_apis.
reserve
(num_apis);
100
for
(
ice::u32
idx = 0; idx < num_apis; ++idx)
101
{
102
out_apis.
push_back
(*
reinterpret_cast<
Type*
>
(temp_tab[idx].api_ptr));
103
}
104
}
105
return
num_apis > 0;
106
}
107
108
}
// namespace ice
array.hxx
ice::concepts::APIType
Definition
module_concepts.hxx:12
module_concepts.hxx
module_info.hxx
ice::concepts
Definition
container_concepts.hxx:12
ice
SPDX-License-Identifier: MIT.
Definition
array.hxx:12
ice::StringID_Arg
std::conditional_t< ice::build::Constant_StringID_DebugInfoEnabled, StringID const &, StringID > StringID_Arg
Argument type used to pass ice::StringID values to functions.
Definition
stringid.hxx:23
ice::u32
std::uint32_t u32
Definition
types.hxx:26
stringid.hxx
ice::Array
A simple container storing items in continuous memory.
Definition
array.hxx:24
ice::Array::push_back
void push_back(ItemType &&item) noexcept
Definition
array.hxx:322
ice::ModuleAPI
Stores information about a single API entry.
Definition
module_info.hxx:33
ice::ModuleAPI::api_ptr
void * api_ptr
Pointer to an API structure holding functions to be called.
Definition
module_info.hxx:35
ice::ModuleQuery
Definition
module_query.hxx:14
ice::ModuleQuery::query_api
virtual bool query_api(ice::StringID_Arg api_name, ice::u32 version, ice::ModuleAPI &out_api) const noexcept
Queries an API info for the given name and version.
Definition
module_query.hxx:59
ice::ModuleQuery::query_apis
virtual bool query_apis(ice::StringID_Arg api_name, ice::u32 version, ice::ModuleAPI *out_array, ice::u32 *inout_array_size) const noexcept=0
Queries all API infos for the given name and version.
ice::ModuleQuery::~ModuleQuery
virtual ~ModuleQuery() noexcept=default
ice::container::ResizableContainer::reserve
constexpr void reserve(this Self &self, ice::ncount min_capacity) noexcept
Definition
resizable_container.hxx:25
Generated by
1.18.0