API Reference#
-
namespace Hush#
-
Enums
-
enum class ELogLevel : uint32_t#
Log level.
Values:
-
enumerator Trace#
-
enumerator Debug#
-
enumerator Info#
-
enumerator Warn#
-
enumerator Error#
-
enumerator Critical#
-
enumerator Trace#
-
enum class EAlphaBlendMode : uint32_t#
Values:
-
enumerator None#
-
enumerator OneMinusSrcAlpha#
-
enumerator OneMinusDestAlpha#
-
enumerator ConstAlpha#
-
enumerator DestAlpha#
-
enumerator SrcAlpha#
-
enumerator None#
-
enum class ECullMode : uint32_t#
Values:
-
enumerator None#
-
enumerator Front#
-
enumerator Back#
-
enumerator FrontAndBack#
-
enumerator None#
-
enum class EMaterialPass : uint8_t#
Values:
-
enumerator MainColor#
-
enumerator Transparent#
-
enumerator Mask#
-
enumerator Other#
-
enumerator MainColor#
Functions
-
std::unique_ptr<IApplication> LoadApplication(HushEngine *engine)#
Loads an application. The method to load an application depends on each platform and if shared library loading is enabled.
If HUSH_STATIC_APP definition is set to true, Hush won’t try to load an application hosted in a shared library. This only applies on platforms that support shared libraries.
If a static application is bundled with the engine, it won’t attempt to load a shared library.
- Returns:
A pointer to the loaded application.
-
void Log(ELogLevel logLevel, std::string_view message)#
Logs a message.
- Parameters:
logLevel – level to log the message
message – message to log
-
template<class ...Args>
void LogFormat(ELogLevel logLevel, fmt::format_string<Args...> format, Args&&... args)# Logs a message with a given format.
-
inline void LogTrace(std::string_view message)#
Logs a trace message.
- Parameters:
message – message to log
-
inline void LogDebug(std::string_view message)#
Logs a debug message.
- Parameters:
message – message to log
-
inline void LogInfo(std::string_view message)#
Logs an info message.
- Parameters:
message – message to log
-
inline void LogWarn(std::string_view message)#
Logs a warning message.
- Parameters:
message – message to log
-
inline void LogError(std::string_view message)#
Logs an error message.
- Parameters:
message – message to log
-
inline void LogCritical(std::string_view message)#
Logs a critical message.
- Parameters:
message – message to log
-
inline void ClearLogs()#
-
void Serialize(DirectionalLight *component)#
-
void Serialize(IMaterial3D *component, const char *uniqueName)#
-
template<BitMaskEnum Enum>
constexpr bool HasFlag(Enum value, Enum flag)# Check if an enum value has a flag.
- Template Parameters:
Enum – Enum type.
- Parameters:
value – Value to check.
flag – Flag to check.
- Returns:
True if the value has the flag, false otherwise.
-
template<BitMaskEnum Enum>
constexpr bool HasAnyFlag(Enum value, Enum flag)# Check if an enum value has any of the flags.
- Template Parameters:
Enum – Enum type.
- Parameters:
value – Value to check.
flag – Flag to check.
- Returns:
True if the value has any of the flags, false otherwise.
-
template<BitMaskEnum Enum>
constexpr bool HasAllFlags(Enum value, Enum flags)# Check if an enum value has all the flags.
- Template Parameters:
Enum – Enum type.
- Parameters:
value – Value to check.
flags – Flags to check.
- Returns:
True if the value has all the flags, false otherwise.
-
inline auto Success()#
Variables
-
template<typename Enum>
constexpr bool HAS_BIT_MASK_OPERATORS = EnableBitMaskOperators<Enum>::value# Helper variable template to check if an enum has bit mask operators.
- Template Parameters:
Enum – Enum type to check if it has bit mask operators.
-
class Camera#
Subclassed by Hush::EditorCamera
Public Functions
-
Camera() = default#
-
Camera(const glm::mat4 &projectionMat, const glm::mat4 &unreversedProjectionMat) noexcept#
-
Camera(float degFov, float width, float height, float nearP, float farP) noexcept#
-
virtual ~Camera() = default#
-
inline glm::mat4 GetProjectionMatrix() const noexcept#
-
const glm::mat4 &GetUnreversedProjectionMatrix() const noexcept#
-
void SetProjectionMatrix(glm::mat4 projection, glm::mat4 unReversedProjection)#
-
void SetPerspectiveProjectionMatrix(const float radFov, const float width, const float height, const float nearP, const float farP)#
-
float GetFarPlane() const noexcept#
-
Camera() = default#
-
class CFile : public Hush::IFile#
Public Functions
-
inline CFile(FILE *file, FileMetadata &&fileMetadata)#
-
~CFile() override#
-
virtual Result<std::size_t> Read(std::span<std::byte> data) override#
Reads the file.
- Parameters:
data – Span to the buffer to read the data into.
- Returns:
Result with the number of bytes read.
-
virtual Result<std::span<std::byte>> Read(std::size_t size) override#
Specialized read function that reads a specific amount of bytes. This is used when reading mmaped files. This might not be supported by all implementations.
- Parameters:
size – Size to read.
- Returns:
Result with the data read.
-
virtual Result<void> Write(std::span<const std::byte> data) override#
Writes the file.
- Parameters:
data – Data to write to the file.
- Returns:
Result with the error that occurred.
-
virtual Result<void> Seek(std::size_t position) override#
Seeks to a specific position in the file.
- Parameters:
position – Position to seek to.
- Returns:
Result with the error that occurred.
-
virtual void Close() override#
Closes the file.
-
inline virtual const FileMetadata &GetMetadata() const override#
-
inline CFile(FILE *file, FileMetadata &&fileMetadata)#
-
class CFileSystem : public Hush::IFileSystem#
- #include <CFileSystem.hpp>
Loads data using C APIs. This, however, is not efficient as it loads the whole file into memory. For more complex scenarios, look at memory mapped sources.
Public Functions
-
CFileSystem(std::string_view root)#
-
CFileSystem(const CFileSystem&) = delete#
-
inline CFileSystem(CFileSystem &&rhs) noexcept#
-
CFileSystem &operator=(const CFileSystem&) = delete#
-
inline CFileSystem &operator=(CFileSystem &&rhs) noexcept#
-
~CFileSystem() override = default#
-
virtual Result<std::unique_ptr<IFile>, IFile::EError> OpenFile(std::filesystem::path vfsPath, std::filesystem::path path, EFileOpenMode mode) override#
Opens a file from a specific path.
- Parameters:
path – Path of the file to open
mode – Mode to open the file
- Returns:
A result with a pointer to the file.
-
CFileSystem(std::string_view root)#
-
class Color#
Public Types
-
enum class EFormat : uint32_t#
Values:
-
enumerator Unknown#
-
enumerator R8Unorm#
-
enumerator RG8Unorm#
-
enumerator RGB8Unorm#
-
enumerator RGBA8Unorm#
-
enumerator R16Float#
-
enumerator RG16Float#
-
enumerator RGB16Float#
-
enumerator RGBA16Float#
-
enumerator R32Float#
-
enumerator RG32Float#
-
enumerator RGB32Float#
-
enumerator RGBA32Float#
-
enumerator D32Float#
-
enumerator D24S8Unorm#
-
enumerator Unknown#
Public Functions
-
Color() = default#
-
inline constexpr Color(float red, float green, float blue, float alpha)#
-
inline constexpr Color(float red, float green, float blue)#
-
inline constexpr Color(glm::vec3 rgb)#
-
inline constexpr Color(glm::vec4 rgba)#
-
inline constexpr const glm::vec4 &GetRGBA32F() const#
-
inline glm::vec4 &GetRGBA32F()#
-
inline constexpr uint32_t ToColor32() const#
-
enum class EFormat : uint32_t#
-
class CommandPanel : public Hush::IEditorPanel#
Public Types
-
class CommandSystem : public Hush::ISystem#
Public Functions
-
virtual void OnShutdown() override#
OnShutdown() is called when the system is shutting down.
-
virtual void OnUpdate(float delta) override#
OnRender() is called when the system should render.
- Parameters:
delta – Time since last frame
-
virtual void OnFixedUpdate(float delta) override#
OnFixedUpdate() is called when the system should update its state.
- Parameters:
delta – Time since last fixed frame
-
virtual void OnRender() override#
OnRender() is called when the system should render.
-
virtual void OnPreRender() override#
OnPreRender() is called before rendering.
-
virtual void OnPostRender() override#
OnPostRender() is called after rendering.
-
virtual void OnShutdown() override#
-
class ContentPanel : public Hush::IEditorPanel#
-
class DebugTooltip : public Hush::IEditorPanel#
Public Functions
-
virtual void OnRender() noexcept override#
-
const glm::vec3 &GetScale() const#
-
const glm::vec3 &GetRotation() const#
-
const glm::vec3 &GetTranslation() const#
Public Static Attributes
-
static DebugTooltip *s_debugTooltip = nullptr#
-
virtual void OnRender() noexcept override#
-
class DebugUI : public Hush::IEditorPanel#
-
class DefaultImageProvider#
Public Functions
-
inline const GpuAllocatedImage &GetWhiteImage() const#
-
inline const GpuAllocatedImage &GetBlackImage() const#
-
inline const GpuAllocatedImage &GetNormalImage() const#
-
inline const GpuAllocatedImage &GetTransparentImage() const#
-
inline const GpuAllocatedImage &GetWhiteImage() const#
-
struct DescriptorAllocator#
Public Functions
-
void InitPool(VkDevice device, uint32_t maxSets, const std::vector<PoolSizeRatio> &poolRatios) noexcept#
-
void ClearDescriptors(VkDevice device) const#
-
void DestroyPool(VkDevice device) const#
-
VkDescriptorSet Allocate(VkDevice device, VkDescriptorSetLayout layout) const#
Public Members
-
VkDescriptorPool pool = {}#
-
struct PoolSizeRatio#
-
void InitPool(VkDevice device, uint32_t maxSets, const std::vector<PoolSizeRatio> &poolRatios) noexcept#
-
struct DescriptorAllocatorGrowable#
Public Functions
-
void Init(VkDevice device, uint32_t initialSets, const std::vector<PoolSizeRatio> &poolRatios)#
-
void ClearPool(VkDevice device)#
-
void DestroyPool(VkDevice device)#
-
VkDescriptorSet Allocate(VkDevice device, VkDescriptorSetLayout layout, void *pNext = nullptr)#
-
struct PoolSizeRatio#
-
void Init(VkDevice device, uint32_t initialSets, const std::vector<PoolSizeRatio> &poolRatios)#
-
struct DescriptorLayoutBuilder#
Public Functions
-
void AddBinding(uint32_t binding, VkDescriptorType type, uint32_t stageFlags = 0)#
-
void Clear()#
-
VkDescriptorSetLayout Build(VkDevice device, VkShaderStageFlags shaderStages, void *pNext = nullptr, VkDescriptorSetLayoutCreateFlags flags = 0)#
Public Members
-
std::vector<VkDescriptorSetLayoutBinding> bindings#
-
void AddBinding(uint32_t binding, VkDescriptorType type, uint32_t stageFlags = 0)#
-
struct DescriptorWriter#
Public Functions
-
void WriteImage(int32_t binding, VkImageView image, VkSampler sampler, VkImageLayout layout, VkDescriptorType type)#
-
void WriteBuffer(int32_t binding, VkBuffer buffer, size_t size, size_t offset, VkDescriptorType type)#
-
void Clear()#
-
void UpdateSet(VkDevice device, VkDescriptorSet set)#
-
void WriteImage(int32_t binding, VkImageView image, VkSampler sampler, VkImageLayout layout, VkDescriptorType type)#
-
struct DirectionalLight#
-
class DotnetHost#
- #include <DotnetHost.hpp>
hold references to all .NET function pointers with a valid initialization, to pass onto ScriptingManager
Public Functions
-
DotnetHost(const char *dotnetPath)#
Creates a new .NET host using hostfxr with the provided path of the runtime.
-
DotnetHost(const DotnetHost &other) = default#
-
DotnetHost(DotnetHost &&other) = default#
-
DotnetHost &operator=(const DotnetHost&) = default#
-
DotnetHost &operator=(DotnetHost&&) = default#
-
~DotnetHost()#
-
get_function_pointer_fn GetFunctionGetterFuncPtr()#
-
DotnetHost(const char *dotnetPath)#
-
struct DrawContext#
Public Members
-
std::vector<VkRenderObject> opaqueSurfaces#
-
std::vector<VkRenderObject> transparentSurfaces#
-
std::vector<VkRenderObject> opaqueSurfaces#
-
class EditorCamera : public Hush::Camera#
Public Functions
-
EditorCamera() = default#
-
EditorCamera(float degFov, float width, float height, float nearP, float farP)#
-
glm::mat4 GetViewMatrix() const noexcept#
-
glm::mat4 GetOrientationMatrix() const noexcept#
-
const glm::vec3 &GetPosition() const noexcept#
-
glm::vec3 &GetPosition() noexcept#
-
float &GetPitch() noexcept#
-
float &GetYaw() noexcept#
-
EditorCamera() = default#
-
class EditorCameraSystem : public Hush::ISystem#
Public Functions
-
EditorCameraSystem(const EditorCameraSystem&) = delete#
-
EditorCameraSystem(EditorCameraSystem&&) = delete#
-
EditorCameraSystem &operator=(const EditorCameraSystem&) = delete#
-
EditorCameraSystem &operator=(EditorCameraSystem&&) = delete#
-
~EditorCameraSystem() override = default#
-
virtual void OnShutdown() override#
OnShutdown() is called when the system is shutting down.
-
virtual void OnUpdate(float delta) override#
OnRender() is called when the system should render.
- Parameters:
delta – Time since last frame
-
virtual void OnFixedUpdate(float delta) override#
OnFixedUpdate() is called when the system should update its state.
- Parameters:
delta – Time since last fixed frame
-
virtual void OnRender() override#
OnRender() is called when the system should render.
-
virtual void OnPreRender() override#
OnPreRender() is called before rendering.
-
virtual void OnPostRender() override#
OnPostRender() is called after rendering.
-
EditorCameraSystem(const EditorCameraSystem&) = delete#
-
template<typename Enum>
struct EnableBitMaskOperators : public std::false_type# - #include <EnumFlags.hpp>
Trait to enable bit mask operators for an enum. To implement this trait, specialize the EnableBitMaskOperators struct for the enum. There’s a helper macro to do this in the EnumFlags.hpp file. Use HUSH_ENABLE_BITMASK_OPERATORS(Enum) However, we recommend implementing it manually to avoid macros.
-
template<>
struct EnableBitMaskOperators<ComponentTraits::EComponentOpsFlags> : public std::true_type#
-
class Entity#
- #include <Entity.hpp>
Describes an entity in the scene. An entity is something that exists in the scene. It can have components attached to it. Entities are not meant to be created directly, but through the scene.
Creating components requires the component to be registered in the scene. This is done automatically when any of the component functions are called. If the component is not registered, it will be registered in the scene.
For scripting, this class exposes
*ComponentRaw
functions that are used to interact with components using raw component ids. These functions are not meant to be used directly, and, while you can, they’re inconvenient. The*Component
functions are the ones that should be used.Public Types
-
using EntityId = std::uint64_t#
Public Functions
-
~Entity() noexcept = default#
Entity destructor. It does not destroy the entity. For that, use
Scene::DestroyEntity
.
-
template<typename T>
inline bool HasComponent()# Checks if the entity has a component of the given type.
- Template Parameters:
T – Type of the component.
- Returns:
True if the entity has the component, false otherwise.
-
template<typename T>
inline std::remove_cvref_t<T> &AddComponent()# Add a component to the entity. If the component is already added, it will return a reference to the existing component.
- Template Parameters:
T – Type of the component.
- Returns:
Reference to the added component.
-
template<typename T, typename ...Args>
inline std::remove_cvref_t<T> &EmplaceComponent(Args&&... args)# Emplace a component to the entity. If the component is already added, it will return a reference to the existing component.
- Template Parameters:
T – Type of the component.
Args – Arguments to pass to the constructor of the component.
- Parameters:
args – Arguments to pass to the constructor of the component.
- Returns:
Reference to the added component.
-
template<typename T>
inline std::remove_cvref_t<T> *GetComponent()# Get a component from the entity.
- Template Parameters:
T – Type of the component.
- Returns:
Pointer to the component, or nullptr if the component is not found.
-
template<typename T>
inline const std::remove_cvref_t<T> *GetComponent() const# Get a component from the entity.
- Template Parameters:
T – Type of the component.
- Returns:
Pointer to the component, or nullptr if the component is not found.
-
template<typename T>
inline bool RemoveComponent()# Remove a component from the entity.
- Template Parameters:
T – Type of the component.
- Returns:
True if the component was removed, false otherwise.
-
template<typename T>
inline void RegisterComponent() const# Register a component to the entity.
- Template Parameters:
T – Type to register.
-
EntityId RegisterComponentRaw(const ComponentTraits::ComponentInfo &desc) const#
Register a component.
- Parameters:
desc – Component description.
- Returns:
Id of the component.
-
void *AddComponentRaw(EntityId componentId)#
Add a component to the entity.
- Parameters:
componentId – Id of the component.
- Returns:
Pointer to the component.
-
void *GetComponentRaw(EntityId componentId)#
Get a component from the entity.
- Parameters:
componentId – Id of the component.
- Returns:
Pointer to the component.
-
void *GetComponentRaw(EntityId componentId) const#
Get a component from the entity.
- Parameters:
componentId – Id of the component.
- Returns:
Pointer to the component.
-
bool HasComponentRaw(EntityId componentId)#
Check if the entity has a component.
- Parameters:
componentId – Id of the component.
- Returns:
True if the entity has the component, false otherwise.
-
void *EmplaceComponentRaw(EntityId componentId, bool &isNew)#
Emplace a component to the entity. If the component is already added, it will return a reference to the existing component. If the component is new, the user is in charge of constructing it. Not constructing it is undefined behavior.
- Parameters:
componentId – Id of the component.
isNew – Flag to indicate if the component is new. If it is new, user is in charge of constructing it.
- Returns:
Pointer to the component.
-
bool RemoveComponentRaw(EntityId componentId)#
Remove a component from the entity.
- Parameters:
componentId – Id of the component.
- Returns:
True if the component was removed, false otherwise.
-
std::optional<std::string_view> GetName() const#
Get the name of the entity.
- Returns:
Name of the entity.
-
using EntityId = std::uint64_t#
-
struct FileMetadata#
- #include <IFile.hpp>
Metadata for a file.
Public Members
-
std::filesystem::path path#
-
std::size_t size#
-
std::uint64_t lastModified#
-
EFileOpenMode mode#
-
std::filesystem::path path#
-
struct FrameData#
- #include <FrameData.hpp>
Definition of the frame data structure to pass in Vulkan’s dynamic rendering from VKGuide (https://vkguide.dev/docs/new_chapter_1/vulkan_mainloop_code/)
Public Members
-
VkSemaphore swapchainSemaphore#
Used for making the render commands wait for the swapchain image.
-
VkSemaphore renderSemaphore#
Controls presenting the image to the OS once drawing is finished.
-
VkFence renderFence#
Lets us wait for the draw commands of a given frame to be finished.
-
VkCommandBuffer mainCommandBuffer#
-
VkCommandPool commandPool#
-
VulkanDeletionQueue deletionQueue#
-
DescriptorAllocatorGrowable frameDescriptors#
-
VkSemaphore swapchainSemaphore#
-
struct GeoSurface#
-
class GLTFMetallicRoughness : public Hush::IMaterial3D#
Public Functions
- HUSH_STATIC_ASSERT (sizeof(MaterialConstants) % 16==0, "Metallic Roughness size mismatch!")
-
GLTFMetallicRoughness() = default#
-
void ClearResources(VkDevice device)#
-
virtual EAlphaBlendMode GetAlphaBlendMode() const noexcept override#
-
virtual void SetAlphaBlendMode(EAlphaBlendMode blendMode) noexcept override#
-
virtual EMaterialPass GetMaterialPass() const noexcept override#
-
virtual void SetMaterialPass(EMaterialPass pass) override#
-
void GenerateMaterialInstance(DescriptorAllocatorGrowable *descriptorAllocator)#
-
const glm::vec4 &GetAlbedo() const noexcept#
-
glm::vec4 &GetAlbedo() noexcept#
-
void SetAlbedo(const glm::vec4 &color) noexcept#
-
const glm::vec3 &GetEmissionColor() const noexcept#
-
glm::vec3 &GetEmissionColor() noexcept#
-
void SetEmissionColor(const glm::vec3 &color) noexcept#
-
const float &EmissionFactor() const noexcept#
-
void SetEmissionFactor(float emissionFactor) noexcept#
-
const float &GetMetallicFactor() const noexcept#
-
void SetMetallicFactor(float factor) noexcept#
-
const float &GetRoughnessFactor() const noexcept#
-
void SetRoughnessFactor(float factor) noexcept#
-
const float &GetAlphaThreshold() const noexcept#
-
void SetAlphaThreshold(float alphaThreshold) noexcept#
-
virtual GraphicsApiMaterialInstance *GetInternalMaterial() override#
-
MaterialResources &GetMaterialResources()#
-
MaterialConstants &GetMaterialConstants() noexcept#
-
void SetMaterialConstants(const MaterialConstants &values)#
-
inline EPbrOptions GetPbrOptions() const#
-
inline void SetPbrOptions(EPbrOptions options)#
-
inline virtual void SetName(const std::string_view &name) override#
-
inline virtual const std::string &GetName() const noexcept override#
Public Members
-
DescriptorWriter writer#
-
struct MaterialConstants#
-
struct MaterialResources#
Public Members
-
GpuAllocatedImage colorImage#
-
VkSampler colorSampler#
-
GpuAllocatedImage metalRoughImage#
-
VkSampler metalRoughSampler#
-
GpuAllocatedImage normalImage#
-
VkSampler normalSampler#
-
GpuAllocatedImage emissiveImage#
-
VkSampler emissiveSampler#
-
GpuAllocatedBuffer gpuDataBuffer#
-
uint32_t dataBufferOffset#
-
GpuAllocatedImage colorImage#
-
class GpuAllocatedBuffer#
Public Types
Public Functions
-
GpuAllocatedBuffer() = default#
-
GpuAllocatedBuffer(size_t size, EBufferUsage usage, EMemoryUsage memoryUsage, void *allocator)#
-
void Dispose(void *allocator)#
-
size_t GetSize() const noexcept#
-
const OpaqueAllocationData *GetAllocationData()#
-
void *GetBuffer()#
-
void *GetMappedData()#
-
GpuAllocatedBuffer() = default#
-
struct GpuAllocatedImage#
Public Members
-
ImageExtent3D imageExtent#
-
ImageExtent3D imageExtent#
-
struct GraphicsApiMaterialInstance#
Public Members
-
EMaterialPass passType#
-
EMaterialPass passType#
-
class HierarchyPanel : public Hush::IEditorPanel#
-
class HushEngine#
Public Functions
-
HushEngine()#
Initializes the HushEngine with all its properties.
-
HushEngine(const HushEngine&) = delete#
-
HushEngine &operator=(const HushEngine&) = delete#
-
HushEngine(HushEngine&&) noexcept = default#
-
HushEngine &operator=(HushEngine&&) noexcept = default#
-
void AddSystem(ISystem *system)#
Intended to be used for engine systems, user-defined systems should be added using
Hush::Scene::AddSystem()
-
~HushEngine()#
-
void Quit()#
Disposes of the HushEngine.
-
inline Threading::Executors::ThreadPool *GetEngineThreadPool() noexcept#
Returns the engine’s default thread pool. The default threadpool contains a number of threads equal to the number of hardware threads available on the system, and each thread is pinned to a core.
- Returns:
A pointer to the engine’s thread pool.
-
HushEngine()#
-
class IApplication#
Subclassed by EditorApp
Public Functions
-
IApplication() = default#
-
IApplication(const IApplication&) = delete#
-
IApplication(IApplication&&) = delete#
-
IApplication &operator=(const IApplication&) = default#
-
IApplication &operator=(IApplication&&) = default#
-
virtual ~IApplication() = default#
-
virtual void Init() = 0#
-
virtual void Update(float delta) = 0#
-
virtual void FixedUpdate(float delta) = 0#
-
virtual void OnPreRender() = 0#
-
virtual void OnRender() = 0#
-
virtual void OnPostRender() = 0#
-
virtual std::string_view GetAppName() const noexcept = 0#
-
IApplication() = default#
-
class IEditorPanel#
Subclassed by Hush::CommandPanel, Hush::ContentPanel, Hush::DebugTooltip, Hush::DebugUI, Hush::HierarchyPanel, Hush::InspectorPanel, Hush::ScenePanel, Hush::StatsPanel, Hush::TitleBarMenuPanel
Public Functions
-
IEditorPanel() noexcept = default#
-
IEditorPanel(const IEditorPanel &other) = default#
-
IEditorPanel(IEditorPanel &&other) = default#
-
IEditorPanel &operator=(const IEditorPanel&) = default#
-
IEditorPanel &operator=(IEditorPanel&&) = default#
-
virtual ~IEditorPanel() = default#
-
virtual void OnRender() = 0#
-
IEditorPanel() noexcept = default#
-
class IFile#
- #include <IFile.hpp>
File interface for the VFS. A file is a resource that maps to a specific path in the VFS. Files support reading, writing, and reading metadata. Not all the VFS implementations will support all the operations, and, in those cases, the implementation will return a “OperationNotSupported” error. TODO: async interfaces.
Subclassed by Hush::CFile
Public Types
Public Functions
-
IFile() = default#
-
virtual ~IFile() = default#
-
virtual const FileMetadata &GetMetadata() const = 0#
-
virtual Result<void> Write(std::span<const std::byte> data) = 0#
Writes the file.
- Parameters:
data – Data to write to the file.
- Returns:
Result with the error that occurred.
-
virtual Result<std::size_t> Read(std::span<std::byte> data) = 0#
Reads the file.
- Parameters:
data – Span to the buffer to read the data into.
- Returns:
Result with the number of bytes read.
-
virtual Result<std::span<std::byte>> Read(std::size_t size) = 0#
Specialized read function that reads a specific amount of bytes. This is used when reading mmaped files. This might not be supported by all implementations.
- Parameters:
size – Size to read.
- Returns:
Result with the data read.
-
virtual Result<void> Seek(std::size_t position) = 0#
Seeks to a specific position in the file.
- Parameters:
position – Position to seek to.
- Returns:
Result with the error that occurred.
-
virtual void Close() = 0#
Closes the file.
-
IFile() = default#
-
class IFileSystem#
- #include <FileSystem.hpp>
A resource loader is an interface meant to be implemented by classes that load things from a specific source (i.e. a ZIP file). This means that they must implement a way to load resources from an underlying sources, both in an async and a sync way. Some resource sources do not support a Resource sources must live until all of their children are deleted.
Subclassed by Hush::CFileSystem
Public Types
Public Functions
-
IFileSystem() = default#
-
IFileSystem(const IFileSystem&) = delete#
-
IFileSystem(IFileSystem&&) = default#
-
IFileSystem &operator=(const IFileSystem&) = delete#
-
IFileSystem &operator=(IFileSystem&&) = default#
-
virtual ~IFileSystem() = default#
-
virtual Result<std::unique_ptr<IFile>, IFile::EError> OpenFile(std::filesystem::path vfsPath, std::filesystem::path path, EFileOpenMode mode = EFileOpenMode::Read) = 0#
Opens a file from a specific path.
- Parameters:
path – Path of the file to open
mode – Mode to open the file
- Returns:
A result with a pointer to the file.
-
IFileSystem() = default#
-
class IImGuiForwarder#
Subclassed by Hush::VulkanImGuiForwarder
Public Functions
-
IImGuiForwarder() = default#
-
virtual ~IImGuiForwarder() = default#
-
IImGuiForwarder(const IImGuiForwarder&) = default#
-
IImGuiForwarder(IImGuiForwarder&&) = default#
-
IImGuiForwarder &operator=(const IImGuiForwarder&) = default#
-
IImGuiForwarder &operator=(IImGuiForwarder&&) = default#
-
virtual void NewFrame() = 0#
-
virtual void EndFrame() = 0#
-
virtual void HandleEvent(const SDL_Event*) noexcept = 0#
-
virtual void Dispose() noexcept = 0#
-
IImGuiForwarder() = default#
-
struct ImageExtent3D#
-
class ImageTexture#
-
class IMaterial3D#
Subclassed by Hush::GLTFMetallicRoughness, Hush::ShaderMaterial
Public Functions
-
virtual EAlphaBlendMode GetAlphaBlendMode() const noexcept = 0#
-
virtual void SetAlphaBlendMode(EAlphaBlendMode blendMode) noexcept = 0#
-
virtual EMaterialPass GetMaterialPass() const noexcept = 0#
-
virtual void SetMaterialPass(EMaterialPass pass) = 0#
-
virtual GraphicsApiMaterialInstance *GetInternalMaterial() = 0#
-
virtual void SetName(const std::string_view &name) = 0#
-
virtual const std::string &GetName() const noexcept = 0#
-
virtual EAlphaBlendMode GetAlphaBlendMode() const noexcept = 0#
-
class InputManager#
Public Static Functions
-
static bool IsKeyDown(EKeyCode key)#
Evaluates to true whilst the key is pressed down.
-
static bool IsKeyDownThisFrame(EKeyCode key)#
Evaluates to true the frame the key is identified as EKeyState::Pressed.
-
static bool IsKeyUp(EKeyCode key)#
Evaluates to true the frame the key is identified as EKeyState::Release.
-
static bool IsKeyHeld(EKeyCode key)#
Evaluates to true as long as the key is identified asEKeyState::Held.
-
static bool GetMouseButtonPressed(EMouseButton button)#
Evaluates to true for as long as the mouse button is pressed.
-
static bool FetchCharThisFrame(char *outChar)#
-
static glm::vec2 GetMousePosition()#
Gets the vector of the mouse’s position in pixels.
-
static glm::vec2 GetMouseAcceleration()#
Gets the vector of the mouse’s acceleration in pixels/s^2.
-
static const glm::vec2 &GetMouseScrollAcceleration()#
-
static void SendKeyEvent(KeyCode key, EKeyState state)#
-
static void SendMouseButtonEvent(MouseButton mouseButton, EKeyState state)#
-
static void SendMouseMovementEvent(int32_t posX, int32_t posY, int32_t accelerationX, int32_t accelerationY)#
-
static void SendWheelEvent(float posX, float posY)#
-
static void ResetMouseAcceleration()#
-
static void ResetCharData()#
-
static void SendCharEvent(char pressedChar)#
-
static void SetCursorLock(ECursorLockMode lockMode)#
-
static bool IsKeyDown(EKeyCode key)#
-
class InspectorPanel : public Hush::IEditorPanel#
-
class IRenderer#
- #include <Renderer.hpp>
A common interface for renderers, Hush supports many graphics APIs, and this is the interface that allows us to standardize all of them… All renderers MUST bind to SDL and ImGUI, the latter can be done through the IImGuiForwarder interface.
Subclassed by Hush::VulkanRenderer
Public Functions
-
inline IRenderer(void *windowContext)#
-
virtual ~IRenderer() = default#
-
virtual void CreateSwapChain(uint32_t width, uint32_t height) = 0#
-
virtual void InitImGui() = 0#
-
virtual void DestroyMesh(const std::string_view &name) = 0#
-
virtual void Draw(float delta) = 0#
-
virtual void UpdateSceneObjects(float delta) = 0#
Each renderer will have to implement a way of updating all the objects inside of the scene, these are instances of the IRenderableNode, which is a common interface for all renderers, but additional render data (i.e drawContext) might be needed by their underlying implementation (see VulkanMeshNode for an example)
-
virtual void InitRendering() = 0#
Initializes all the internal structures needed to begin rendering, call after a swapchain has been created!
-
virtual void NewUIFrame() const noexcept = 0#
-
virtual void EndUIFrame() const noexcept = 0#
-
virtual void HandleEvent(const SDL_Event *event) noexcept = 0#
-
virtual void SetDirectionalLight(DirectionalLight *light) noexcept = 0#
-
virtual GpuAllocatedImage CreateImage(const void *data, const ImageExtent3D &size, Color::EFormat format, uint32_t usage, bool mipmapped = false) = 0#
-
virtual void DestroyImage(GpuAllocatedImage *image) = 0#
-
virtual void AddToDeletionQueue(std::function<void()> &&deleteFunc) = 0#
-
virtual const DefaultImageProvider *GetDefaultImageProvider() const noexcept = 0#
-
virtual void *GetWindowContext() const noexcept = 0#
-
virtual const EditorCamera &GetEditorCamera() const noexcept = 0#
-
virtual EditorCamera *GetEditorCamera() noexcept = 0#
-
inline IRenderer(void *windowContext)#
-
class ISystem#
- #include <ISystem.hpp>
ISystem is the base interface for all systems in the engine It implements helper functions that all systems should implement.
The lifecycle of a system is as follows:
Constructor: Called when the system is created, could be used for some early initialization
Init: Called when the system is initialized, at this point all the systems are created.
OnUpdate: Called every frame, this is where the system should update its state.
OnFixedUpdate: Called every fixed frame, this is where the system should update its state. Usually helpful for physics.
OnShutdown: Called when the system is shutting down, could be used for some cleanup.
OnRender: Called when the system should render, could be used for rendering.
Destructor: Called when the system is destroyed, could be used for some cleanup.
Hooks are provided for all the lifecycle events, so the system can implement them as needed.
Systems provide a member function called
Order
that should return the order in which the system should be updated. The game engine will sort the systems based on this value. Every time a new system is added, the engine will sort the systems based on this value. The engine provides 255 order slots, so the system can return any value between 0 and 255. Systems that belong to the same order will be updated concurrently.The systems will be bucketed BEFORE init is called, so the order of the systems should be set in the constructor.
Subclassed by Hush::CommandSystem, Hush::EditorCameraSystem, Hush::TransformationSystem
Public Functions
-
virtual ~ISystem() = default#
-
virtual void OnShutdown() = 0#
OnShutdown() is called when the system is shutting down.
-
virtual void OnUpdate(float delta) = 0#
OnRender() is called when the system should render.
- Parameters:
delta – Time since last frame
-
virtual void OnFixedUpdate(float delta) = 0#
OnFixedUpdate() is called when the system should update its state.
- Parameters:
delta – Time since last fixed frame
-
virtual void OnRender() = 0#
OnRender() is called when the system should render.
-
virtual void OnPreRender() = 0#
OnPreRender() is called before rendering.
-
virtual void OnPostRender() = 0#
OnPostRender() is called after rendering.
-
inline std::uint16_t Order() const#
Order() is used to get the order in which the system should be updated
- Returns:
Order in which the system should be updated
Public Static Attributes
-
static constexpr std::uint16_t MAX_ORDER = 255#
-
class Mesh#
- #include <Mesh.hpp>
Simple CPU representation of a mesh “component”, holds index and vertex buffers, as well as the RenderingAPI specific buffer data.
Public Functions
-
inline std::vector<uint32_t> &GetIndexBuffer()#
-
void CalculateTangentBasis()#
-
inline const std::vector<GeoSurface> &GetSurfaces() const#
-
inline void AddSurface(GeoSurface &&surface)#
-
inline void SetName(const std::string_view &name)#
-
inline const std::string &GetName() const#
-
inline void SetMeshBuffers(GPUMeshBuffers buffers)#
-
inline GPUMeshBuffers &GetMeshBuffers()#
-
inline const GPUMeshBuffers &GetMeshBuffers() const#
-
void CalculateNormals()#
-
struct Vertex#
-
inline std::vector<uint32_t> &GetIndexBuffer()#
-
struct MouseData#
-
struct OpaqueMaterialData#
Public Members
-
VkMaterialPipeline pipeline#
-
VkDescriptorSetLayout descriptorLayout#
-
DescriptorWriter writer#
-
VkBufferCreateInfo uniformBufferCreateInfo#
-
VkMaterialPipeline pipeline#
-
template<typename ...Components>
class Query : public Hush::impl::QueryImpl# - #include <Query.hpp>
Query for entities. This wraps the raw query and allows getting components in a type-safe way.
It allows iterating using two methods:
Accessing directly to the component arrays, to do this, use the
begin
andend
functions. This also can be iterated using range-based for loops.Using the
Each
function, which allows applying a function to each entity in the query. This is a simple way of iterating over the entities.
Example using the first method:
Query<Position, Velocity> query = scene.CreateQuery<Position, Velocity>(); auto it = query.begin(); for (; it != query.end(); ++it) { auto [positions, velocities] = *it; for (auto position : positions) { // Do something with the position } for (auto velocity : velocities) { // Do something with the velocity } // Or for (std::size_t i = 0; i < it.Size(); ++i) { Position& position = positions[i]; Velocity& velocity = velocities[i]; Hush::Entity entity = it.GetEntity(i); } }
Example using the second method:
Query<Position, Velocity> query = scene.CreateQuery<Position, Velocity>(); query.Each([](Position &position, Velocity &velocity) { }); query.Each([](Entity::EntityId entityId, Position &position, Velocity &velocity) { }); query.Each([](Hush::Entity &entity, Position &position, Velocity &velocity) { });
- Template Parameters:
Components – Components to query.
Public Types
-
using ECacheMode = RawQuery::ECacheMode#
-
using ComponentTuple = std::tuple<std::span<std::remove_reference_t<Components>>...>#
-
using ConstComponentTuple = std::tuple<std::span<std::add_const_t<std::remove_reference_t<Components>>>...>#
Public Functions
-
inline QueryIterator begin()#
Get an iterator to iterate over the entities in the query.
- Returns:
Iterator to iterate over the entities in the query.
-
inline SentinelQueryIterator end()#
Get the sentinel iterator. This is used to check if the iterator is finished.
- Returns:
-
inline QueryIterator begin() const#
Const version of the begin function.
- Returns:
Const query iterator
-
inline SentinelQueryIterator end() const#
Const version of the end function.
- Returns:
-
template<typename Func>
inline void Each(Func &&func)# Apply a function to each entity in the query. This version of the function will only pass the components as arguments. Order is as the query was created.
- Template Parameters:
Func – Function type.
- Parameters:
func – Function to apply to each entity.
-
template<typename Func>
inline void Each(Func &&func) Apply a function to each entity in the query. This version of the function also provides the entity id as the first argument.
- Template Parameters:
Func – Function type.
- Parameters:
func – Function to apply to each entity.
-
template<typename Func>
inline void Each(Func &&func) Apply a function to each entity in the query. This version of the function will pass the entity as the first argument.
- Template Parameters:
Func – Function type.
- Parameters:
func – Function to apply to each entity.
-
struct QueryIterator#
- #include <Query.hpp>
Query iterator. This allows using for-range loops to iterate over the array of components.
Public Functions
-
inline QueryIterator(RawQuery::QueryIterator iter)#
-
QueryIterator(const QueryIterator&) = delete#
-
QueryIterator &operator=(const QueryIterator&) = delete#
-
inline QueryIterator(QueryIterator &&rhs) noexcept#
-
inline QueryIterator &operator=(QueryIterator &&rhs) noexcept#
-
~QueryIterator() = default#
-
inline QueryIterator &operator++()#
Move to the next table.
- Returns:
self
-
inline ComponentTuple operator*()#
Get the next table of components. For instance, for a Query<Position, Velocity>, this will return a std::tuple<std::span<Position>, std::span<Velocity>>.
- Returns:
A std::tuple of spans of the components.
-
inline ConstComponentTuple operator*() const#
Get the next table of components. For instance, for a const Query<Position, Velocity>, this will return a std::tuple<std::span<const
Position>, std::span<const Velocity>>.
- Returns:
A std::tuple of spans of the components.
-
inline bool operator==(const SentinelQueryIterator&) const#
Returns true if the iterator is finished.
- Returns:
True if the iterator is finished, false otherwise.
-
inline bool operator!=(const SentinelQueryIterator&) const#
Returns true if the iterator is not finished.
- Returns:
True if the iterator is not finished, false otherwise.
-
inline RawQuery::QueryIterator &GetRawIterator()#
Get the underlying raw iterator.
Note: Advancing the raw iterator will also advance this iterator.
- Returns:
The raw iterator.
-
inline std::size_t Size() const#
Get the number of entities in the current table.
- Returns:
The number of entities in the current table.
-
inline QueryIterator(RawQuery::QueryIterator iter)#
-
struct SentinelQueryIterator#
- #include <Query.hpp>
This is a sentinel iterator that is used to signal the end of the query.
-
class RawQuery#
- #include <Query.hpp>
Low-level query for entities. This allows getting raw void pointers to components. To iterate, this class provides a Hush::RawQuery::GetIterator function that returns an iterator. For more information about the iterator, see QueryIterator.
Public Types
Public Functions
-
RawQuery() = delete#
-
RawQuery &operator=(RawQuery &&rhs) noexcept#
Move assignment operator.
- Parameters:
rhs – Other query to move from.
- Returns:
self
-
~RawQuery() noexcept#
-
Scene *GetScene() const noexcept#
Get the scene where the query is running.
- Returns:
Scene where the query is running.
-
QueryIterator GetIterator()#
Get an iterator to iterate over the entities in the query.
- Returns:
Iterator to iterate over the entities in the query.
Public Static Attributes
-
static constexpr std::uint32_t MAX_COMPONENTS = 32#
-
struct QueryIterator#
- #include <Query.hpp>
Raw query iterator. This allows iterating over the entities in the query.
This iterator works by giving direct access to the arrays of components in the query. So, this doesn’t give an array of |Component1, Component2, …|, but instead gives n arrays of |Component1, Component1, …|, |Component2, Component2, …|, etc. Keep this in mind when using this iterator.
For end-users (not scripting), it is recommended to use the Hush::Query class instead.
Public Functions
-
QueryIterator(const QueryIterator&) = delete#
-
QueryIterator &operator=(const QueryIterator&) = delete#
-
QueryIterator(QueryIterator &&rhs) noexcept#
-
QueryIterator &operator=(QueryIterator &&rhs) noexcept#
-
~QueryIterator()#
-
bool Next()#
Move to the next entity.
- Returns:
True if there is a next entity, false otherwise.
-
void Skip()#
Skip the current entity.
-
bool Finished() const#
Check if the iterator has been finished.
- Returns:
True if the iterator has been finished. False otherwise.
-
std::size_t Size() const#
Gives the number of entities in the current table. This number is updated when using Next.
- Returns:
The number of entities in the query.
-
void *GetComponentAt(std::int8_t index, std::size_t size) const#
Get an array of components at the given index. Index is given by the order of the components in the query. For instance, if the query was creating with a list of components [Position, Velocity], then Position would be at index 0 and Velocity at index 1.
The length of the array is given by Size.
- Parameters:
index – Index of the component.
size – Size of the component.
- Returns:
Pointer to the component.
-
std::uint64_t GetEntityAt(std::size_t index) const#
Get the entity id at the given index.
-
QueryIterator(const QueryIterator&) = delete#
-
RawQuery() = delete#
-
class Scene#
Public Functions
-
Scene(HushEngine *engine, Hush::Threading::Executors::ThreadPool *threadPool)#
Constructor.
- Parameters:
engine – Game engine
-
~Scene()#
-
void Init()#
Init is called when the scene is initialized.
-
void Update(float delta)#
Update is called every frame.
-
void FixedUpdate(float delta)#
FixedUpdate is called every fixed frame.
-
void PreRender()#
PreRender is called before rendering.
-
void Render()#
Render is called when the scene should render.
-
void PostRender()#
PostRender is called after rendering.
-
void Shutdown()#
Shutdown is called when the scene is shutting down.
-
template<typename S>
inline void AddSystem()# - Template Parameters:
S – Add a system to the scene
-
void RemoveSystem(std::string_view name)#
Remove a system from the scene by name.
- Parameters:
name – Name of the system to remove.
-
Entity CreateEntityWithName(std::string_view name)#
Creates an entity with a name
- Parameters:
name – Unique name of the entity
- Returns:
-
std::optional<std::uint64_t> GetRegisteredComponentId(std::string_view name)#
Get the component registered id by name
- Parameters:
name – Component name
- Returns:
The component id if it exists, std::nullopt otherwise
-
void RegisterComponentId(std::string_view name, Entity::EntityId id)#
Register a component id
- Parameters:
name – Name of the component
id – Id of the component
-
EntityId RegisterComponentRaw(const ComponentTraits::ComponentInfo &desc) const#
-
template<typename ...Components>
inline Query<Components...> CreateQuery(RawQuery::ECacheMode cacheMode = RawQuery::ECacheMode::Default)#
-
void AddEngineSystem(ISystem *system)#
Add an engine system to the scene
- Parameters:
system – System to add
-
RawQuery CreateRawQuery(std::span<Entity::EntityId> components, RawQuery::ECacheMode cacheMode = RawQuery::ECacheMode::Default)#
Friends
- friend class impl::QueryImpl
-
Scene(HushEngine *engine, Hush::Threading::Executors::ThreadPool *threadPool)#
-
class ScenePanel : public Hush::IEditorPanel#
-
class ScriptingManager#
- #include <ScriptingManager.hpp>
Class for bridging with .NET using hostfxr.
Public Functions
Creates a new scripting manager to invoke C# methods.
- Parameters:
host – The host connected to the C# runtime
m_targetAssembly – The desired assembly this manager is going to invoke methods from, THIS SHOULD BE CONSTANT WHEN POSSIBLE
-
struct ShaderBindings#
Public Types
-
enum class EBindingType#
Values:
-
enumerator Unknown#
-
enumerator PushConstant#
-
enumerator InputVariable#
-
enumerator UniformBuffer#
-
enumerator StorageBuffer#
-
enumerator Sampler#
-
enumerator Texture#
-
enumerator CombinedImageSampler#
-
enumerator StorageImage#
-
enumerator UniformTexelBuffer#
-
enumerator StorageTexelBuffer#
-
enumerator UniformBufferDynamic#
-
enumerator StorageBufferDynamic#
-
enumerator InputAttachment#
-
enumerator InlineUniformBlock#
-
enumerator AccelerationStructure#
-
enumerator UniformBufferMember#
-
enumerator Unknown#
Public Members
-
uint32_t bindingIndex = {}#
-
uint32_t size = {}#
-
uint32_t offset = {}#
-
uint32_t stageFlags = {}#
-
uint32_t setIndex = {}#
-
EBindingType type = EBindingType::Unknown#
-
enum class EBindingType#
-
class ShaderMaterial : public Hush::IMaterial3D#
- #include <ShaderMaterial.hpp>
Represents a material created by a custom shader with dynamic mappings and reflections The performance impact of this class is considerable since it needs to keep track of the bindings in both RAM and GPU, as well as process the shader initially with Reflection (initialization cost) This class’s interface is Rendering API agnostic.
Public Types
Public Functions
-
ShaderMaterial() = default#
-
~ShaderMaterial()#
-
EError LoadShaders(IRenderer *renderer, const std::filesystem::path &fragmentShaderPath, const std::filesystem::path &vertexShaderPath)#
Will create and bind pipelines for both shaders.
-
void GenerateMaterialInstance(OpaqueDescriptorAllocator *descriptorAllocator)#
-
OpaqueMaterialData *GetMaterialData()#
-
virtual EAlphaBlendMode GetAlphaBlendMode() const noexcept override#
-
virtual void SetAlphaBlendMode(EAlphaBlendMode blendMode) noexcept override#
-
virtual EMaterialPass GetMaterialPass() const noexcept override#
-
virtual void SetMaterialPass(EMaterialPass pass) override#
-
inline virtual void SetName(const std::string_view &name) override#
-
inline virtual const std::string &GetName() const noexcept override#
-
virtual GraphicsApiMaterialInstance *GetInternalMaterial() override#
-
ShaderMaterial() = default#
-
class ShaderModuleLoader#
Public Functions
-
bool LoadShaderModule(const std::string_view &filePath, VkDevice device, VkShaderModule *outShaderModule, std::vector<uint32_t> *outBuffer = nullptr)#
-
bool LoadShaderModule(const std::string_view &filePath, VkDevice device, VkShaderModule *outShaderModule, std::vector<uint32_t> *outBuffer = nullptr)#
Public Types
SharedLibrary error.
Values:
Public Functions
Gets a pointer to a symbol. This call does not check if the pointer is null.
- Template Parameters:
T – Type of the symbol
- Parameters:
symbolName – Name of the symbol
- Returns:
A pointer to the symbol
Gets a pointer to a symbol.
- Template Parameters:
T – Type of the symbol
- Parameters:
symbolName – Name of the symbol
- Returns:
A result with the symbol, or an error if it can’t be found
Public Static Functions
Opens a shared library and returns a handle to it.
- Parameters:
libraryName – Shared Library name.
- Returns:
A handle to the shared library
-
class StatsPanel : public Hush::IEditorPanel#
-
class Timer#
- #include <Timer.hpp>
Measures REAL TIME differences.
-
class TitleBarMenuPanel : public Hush::IEditorPanel#
-
struct Transform#
Subclassed by Hush::LocalTransform, Hush::WorldTransform
Public Functions
-
Transform() = default#
-
Transform(const glm::vec3 &position, const glm::vec3 &scale = Vector3Math::ONE, const glm::quat &rotation = {})#
-
void SetPosition(const glm::vec3 &position) noexcept#
-
const glm::vec3 *GetPosition() const noexcept#
-
glm::vec3 *GetPosition() noexcept#
-
void SetScale(const glm::vec3 &scale) noexcept#
-
const glm::vec3 &GetScale() const noexcept#
-
glm::vec3 &GetScale() noexcept#
-
void SetRotationQuat(const glm::quat &rotationQuat) noexcept#
-
glm::quat GetRotationQuat() const noexcept#
-
void SetEulerAngles(const glm::vec3 &euler) noexcept#
-
glm::vec3 GetEulerAngles() const noexcept#
-
glm::mat3 GetRotationMatrix() const noexcept#
-
glm::vec3 Forward() const noexcept#
-
glm::vec3 Up() const noexcept#
-
glm::vec3 Right() const noexcept#
-
void SetTransformationMatrix(const glm::mat4 &xform)#
-
glm::mat4 GetTransformationMatrix() const#
-
Transform() = default#
-
class TransformationSystem : public Hush::ISystem#
Public Functions
-
virtual void OnShutdown() override#
OnShutdown() is called when the system is shutting down.
-
virtual void OnUpdate(float delta) override#
OnRender() is called when the system should render.
- Parameters:
delta – Time since last frame
-
virtual void OnFixedUpdate(float delta) override#
OnFixedUpdate() is called when the system should update its state.
- Parameters:
delta – Time since last fixed frame
-
virtual void OnRender() override#
OnRender() is called when the system should render.
-
virtual void OnPreRender() override#
OnPreRender() is called before rendering.
-
virtual void OnPostRender() override#
OnPostRender() is called after rendering.
-
virtual void OnShutdown() override#
-
class UI#
Public Types
Public Static Functions
-
static bool Spinner(const char *label, float radius, int thickness, const uint32_t &color = 3435973836u)#
-
static bool InputTextWithHint(const char *label, const char *hint, char *buffer, size_t size, bool focusOnInput)#
-
static bool BeginCenterPopup(const char *label, bool transparent = false)#
-
static bool CustomSelectable(const char *label, bool *isHovered, ImDrawList *drawList, bool forceHover = false)#
-
static bool BeginToolBar()#
-
static ImGuiID DockSpace(const char *dockspaceId, const char *name, ImGuiDockNodeFlags additionalFlags = 0)#
-
static bool Spinner(const char *label, float radius, int thickness, const uint32_t &color = 3435973836u)#
-
class VirtualFilesystem#
- #include <VirtualFilesystem.hpp>
The VFS allows to manage paths as virtual locations (that might not refer to the real filesystem). For instance, to access an asset, we could use rs://myasset.txt, instead of referring to the physical location of the file. This, while introducing overhead, allows to manage more complex scenarios such as having the game files in a ZIP or a tar file. Or some other format. To use it, you must instantiate it
Public Types
Public Functions
-
VirtualFilesystem()#
-
~VirtualFilesystem()#
-
VirtualFilesystem(const VirtualFilesystem&) = delete#
-
VirtualFilesystem &operator=(const VirtualFilesystem&) = delete#
-
VirtualFilesystem(VirtualFilesystem &&rhs) noexcept#
-
VirtualFilesystem &operator=(VirtualFilesystem &&rhs) noexcept#
-
void Unmount(std::string_view virtualPath)#
-
std::vector<std::string_view> ListPath(std::string_view virtualPath, EListOptions options = EListOptions::None)#
-
Result<std::unique_ptr<IFile>, IFile::EError> OpenFile(std::string_view virtualPath, EFileOpenMode mode = EFileOpenMode::Read)#
-
VirtualFilesystem()#
-
struct VkMaterialPipeline#
-
struct VkRenderObject#
-
class VulkanFullScreenPass#
Public Functions
-
VulkanFullScreenPass() = default#
-
void RecordCommands(VkCommandBuffer cmd, VkDescriptorSet globalDescriptorSet)#
-
ShaderMaterial *GetMaterial()#
-
VulkanFullScreenPass() = default#
-
class VulkanHelper#
Public Static Functions
-
static bool LoadShaderModule(const std::string_view &filePath, VkDevice device, VkShaderModule *outShaderModule, std::vector<uint32_t> *outBuffer = nullptr)#
-
static bool LoadShaderModule(const std::string_view &filePath, VkDevice device, VkShaderModule *outShaderModule, std::vector<uint32_t> *outBuffer = nullptr)#
-
class VulkanImGuiForwarder : public Hush::IImGuiForwarder#
-
class VulkanLoader#
Public Types
Public Static Functions
-
static Result<std::vector<Entity>, EError> LoadGltfMeshes(VulkanRenderer *engine, std::filesystem::path filePath, Scene *activeScene)#
-
static GpuAllocatedImage LoadTexture(VulkanRenderer *engine, const ImageTexture &texture)#
-
static Result<std::vector<Entity>, EError> LoadGltfMeshes(VulkanRenderer *engine, std::filesystem::path filePath, Scene *activeScene)#
-
class VulkanPipelineBuilder#
Public Functions
-
VulkanPipelineBuilder(VkPipelineLayout pipelineLayout)#
-
void Clear()#
-
VkPipeline Build(VkDevice device)#
-
VulkanPipelineBuilder &SetShaders(VkShaderModule vertexShader, VkShaderModule fragmentShader)#
-
VulkanPipelineBuilder &SetInputTopology(VkPrimitiveTopology topology)#
-
VulkanPipelineBuilder &SetPolygonMode(VkPolygonMode mode)#
-
VulkanPipelineBuilder &SetCullMode(VkCullModeFlags cullMode, VkFrontFace frontFace)#
-
VulkanPipelineBuilder &SetMultiSamplingNone()#
-
VulkanPipelineBuilder &DisableBlending()#
-
VulkanPipelineBuilder &EnableBlendingAdditive()#
-
VulkanPipelineBuilder &EnableBlendingAlphaBlend()#
-
VulkanPipelineBuilder &SetAlphaBlendMode(EAlphaBlendMode blendMode)#
-
VulkanPipelineBuilder &DisableDepthTest()#
-
VulkanPipelineBuilder &EnableDepthTest(bool depthWriteEnable, VkCompareOp op)#
-
VulkanPipelineBuilder &SetColorAttachmentFormat(VkFormat format)#
-
VulkanPipelineBuilder &SetDepthFormat(VkFormat format)#
-
VulkanPipelineBuilder(VkPipelineLayout pipelineLayout)#
-
class VulkanRenderer : public Hush::IRenderer#
Public Functions
-
VulkanRenderer(void *windowContext)#
Creates a new vulkan renderer from a given window context.
- Parameters:
windowContext – opaque pointer to the window context
-
VulkanRenderer(const VulkanRenderer&) = delete#
-
VulkanRenderer &operator=(const VulkanRenderer&) = delete#
-
VulkanRenderer(VulkanRenderer &&rhs) noexcept#
-
VulkanRenderer &operator=(VulkanRenderer &&rhs) noexcept#
-
~VulkanRenderer() override#
-
virtual void CreateSwapChain(uint32_t width, uint32_t height) override#
-
virtual void InitRendering() override#
Initializes all the internal structures needed to begin rendering, call after a swapchain has been created!
-
void InitializeCommands() noexcept#
-
virtual void InitImGui() override#
-
virtual void DestroyMesh(const std::string_view &name) override#
-
virtual void Draw(float delta) override#
-
virtual void NewUIFrame() const noexcept override#
-
virtual void EndUIFrame() const noexcept override#
-
virtual void HandleEvent(const SDL_Event *event) noexcept override#
-
virtual void UpdateSceneObjects(float delta) override#
Each renderer will have to implement a way of updating all the objects inside of the scene, these are instances of the IRenderableNode, which is a common interface for all renderers, but additional render data (i.e drawContext) might be needed by their underlying implementation (see VulkanMeshNode for an example)
-
void Dispose()#
-
void ImmediateSubmit(std::function<void(VkCommandBuffer cmd)> &&function) noexcept#
-
VkSampler GetDefaultSamplerLinear() noexcept#
-
VkSampler GetDefaultSamplerNearest() noexcept#
-
GLTFMetallicRoughness &GetMetalRoughMaterial() noexcept#
-
DescriptorAllocatorGrowable &GlobalDescriptorAllocator() noexcept#
-
VmaAllocator GetVmaAllocator() noexcept#
-
VkInstance GetVulkanInstance() noexcept#
-
VkDevice GetVulkanDevice() noexcept#
-
VkDescriptorSetLayout GetGpuSceneDataDescriptorLayout() noexcept#
-
const GpuAllocatedImage &GetDrawImage() const noexcept#
-
GpuAllocatedImage &GetDrawImage() noexcept#
-
const GpuAllocatedImage &GetDepthImage() const noexcept#
-
GpuAllocatedImage &GetDepthImage() noexcept#
-
VkPhysicalDevice GetVulkanPhysicalDevice() const noexcept#
-
VkQueue GetGraphicsQueue() const noexcept#
-
virtual void *GetWindowContext() const noexcept override#
-
virtual void SetDirectionalLight(DirectionalLight *light) noexcept override#
-
virtual const EditorCamera &GetEditorCamera() const noexcept override#
-
VulkanSwapchain &GetSwapchain()#
-
GPUMeshBuffers UploadMesh(const std::vector<uint32_t> &indices, const std::vector<Mesh::Vertex> &vertices)#
-
virtual GpuAllocatedImage CreateImage(const void *data, const ImageExtent3D &size, Color::EFormat format, uint32_t usage, bool mipmapped = false) override#
-
VkSurfaceKHR GetSurface() noexcept#
-
virtual void AddToDeletionQueue(std::function<void()> &&deleteFunc) override#
-
virtual const DefaultImageProvider *GetDefaultImageProvider() const noexcept override#
-
ShaderModuleLoader &GetShaderModuleLoader() noexcept#
-
virtual EditorCamera *GetEditorCamera() noexcept override#
Public Static Functions
-
static PFN_vkVoidFunction CustomVulkanFunctionLoader(const char *functionName, void *userData)#
-
VulkanRenderer(void *windowContext)#
-
class VulkanSwapchain#
Public Functions
-
void Recreate(uint32_t width, uint32_t height, VulkanRenderer *renderer)#
-
void Resize(uint32_t width, uint32_t height)#
-
void Destroy()#
-
void Present(VkCommandBuffer cmd, uint32_t *swapchainImageIndex, bool *shouldResize)#
-
uint32_t AcquireNextImage(VkSemaphore swapchainSemaphore, bool *shouldResize)#
-
const VkFormat &GetImageFormat() const noexcept#
-
const VkExtent2D &GetExtent() const noexcept#
-
const std::vector<VkImage> &GetImages() const noexcept#
-
const std::vector<VkImageView> &GetImageViews() const noexcept#
-
VkSwapchainKHR GetRawSwapchain() noexcept#
-
void Recreate(uint32_t width, uint32_t height, VulkanRenderer *renderer)#
-
class WindowManager#
Public Static Functions
-
static inline WindowRenderer *GetMainWindow()#
-
static inline void SetMainWindow(WindowRenderer *window)#
-
static inline WindowRenderer *GetMainWindow()#
-
class WindowRenderer#
Public Functions
-
WindowRenderer(WindowRenderer &&other) = default#
-
WindowRenderer(const WindowRenderer &other) = default#
-
WindowRenderer &operator=(const WindowRenderer&) = default#
-
WindowRenderer &operator=(WindowRenderer&&) = default#
-
void HandleEvents(bool *applicationRunning)#
-
~WindowRenderer()#
-
bool IsActive() const noexcept#
-
WindowRenderer(WindowRenderer &&other) = default#
-
struct WorldTransform : public Hush::Transform#
Public Functions
-
Transform() = default#
-
Transform(const glm::vec3 &position, const glm::vec3 &scale = Vector3Math::ONE, const glm::quat &rotation = {})#
-
Transform() = default#
-
namespace ArrayUtils#
Provides utility functions for handling Arrays and collection types.
Functions
-
template<class ArrayType, class ElementType>
inline std::vector<ElementType> FuzzyFind(const ArrayType &candidates, const std::string &query)#
-
template<class ArrayType, class ElementType>
-
namespace Bitwise#
Definitions and all that just to make everything type safe.
-
namespace ComponentTraits#
Typedefs
-
using ComponentCtor = void (*)(void *array, std::int32_t count, const void *componentInfo)#
-
using ComponentDtor = void (*)(void *array, std::int32_t count, const void *componentInfo)#
-
using ComponentCopy = void (*)(void *dst, const void *src, std::int32_t count, const void *componentInfo)#
-
using ComponentMove = void (*)(void *dst, void *src, std::int32_t count, const void *componentInfo)#
-
using ComponentCopyCtor = void (*)(void *dst, const void *src, std::int32_t count, const void *componentInfo)#
-
using ComponentMoveCtor = void (*)(void *dst, void *src, std::int32_t count, const void *componentInfo)#
Enums
-
enum class EComponentOpsFlags : std::uint32_t#
Values:
-
enumerator None#
-
enumerator HasCtor#
-
enumerator HasDtor#
-
enumerator HasCopy#
-
enumerator HasMove#
-
enumerator HasCopyCtor#
-
enumerator HasMoveCtor#
-
enumerator HasMoveDtor#
-
enumerator HasMoveAssignDtor#
-
enumerator NoCtor#
-
enumerator NoDtor#
-
enumerator NoCopy#
-
enumerator NoMove#
-
enumerator NoCopyCtor#
-
enumerator NoMoveCtor#
-
enumerator NoMoveDtor#
-
enumerator NoMoveAssignDtor#
-
enumerator None#
Functions
-
template<typename T>
void CtorImpl(void *array, std::int32_t count, const void*)#
-
template<typename T>
void DtorImpl(void *array, std::int32_t count, const void*)#
-
template<typename T>
void CopyImpl(void *dst, const void *src, std::int32_t count, const void*)#
-
template<typename T>
void MoveImpl(void *dst, void *src, std::int32_t count, const void*)#
-
template<typename T>
void CopyCtorImpl(void *dst, const void *src, std::int32_t count, const void*)#
-
template<typename T>
void MoveCtorImpl(void *dst, void *src, std::int32_t count, const void*)#
-
template<typename T>
void MoveCtorDtorImpl(void *dst, void *src, std::int32_t count, const void*)#
-
template<typename T>
void MoveAssignDtorImpl(void *dst, void *src, std::int32_t count, const void*)#
-
template<typename T>
constexpr ComponentCtor GetCtorImpl(EComponentOpsFlags&)# Get the constructor function for a component.
- Template Parameters:
T – Type of the component.
- Returns:
Function pointer to the function that will construct the component.
-
template<typename T>
constexpr ComponentCtor GetCtorImpl(EComponentOpsFlags&) Get the constructor function for a component that does not have a trivial constructor.
- Template Parameters:
T – Type of the component.
- Returns:
Nullptr
-
template<typename T>
constexpr ComponentCtor GetCtorImpl(EComponentOpsFlags &flags)
-
template<typename T>
constexpr ComponentDtor GetDtorImpl(EComponentOpsFlags&)#
-
template<typename T>
constexpr ComponentDtor GetDtorImpl(EComponentOpsFlags&)
-
template<typename T>
constexpr ComponentDtor GetDtorImpl(EComponentOpsFlags &flags)
-
template<typename T>
constexpr ComponentCopy GetCopyImpl(EComponentOpsFlags&)#
-
template<typename T>
constexpr ComponentCopy GetCopyImpl(EComponentOpsFlags&)
-
template<typename T>
constexpr ComponentCopy GetCopyImpl(EComponentOpsFlags &flags)
-
template<typename T>
constexpr ComponentMove GetMoveImpl(EComponentOpsFlags&)#
-
template<typename T>
constexpr ComponentMove GetMoveImpl(EComponentOpsFlags&)
-
template<typename T>
constexpr ComponentMove GetMoveImpl(EComponentOpsFlags &flags)
-
template<typename T>
constexpr ComponentCopyCtor GetCopyCtorImpl(EComponentOpsFlags&)#
-
template<typename T>
constexpr ComponentCopyCtor GetCopyCtorImpl(EComponentOpsFlags&)
-
template<typename T>
constexpr ComponentCopyCtor GetCopyCtorImpl(EComponentOpsFlags &flags)
-
template<typename T>
constexpr ComponentMoveCtor GetMoveCtorImpl(EComponentOpsFlags&)#
-
template<typename T>
constexpr ComponentMoveCtor GetMoveCtorImpl(EComponentOpsFlags&)
-
template<typename T>
constexpr ComponentMoveCtor GetMoveCtorImpl(EComponentOpsFlags &flags)
-
template<typename T>
constexpr ComponentMoveCtor GetMoveDtorImpl(EComponentOpsFlags&)#
-
template<typename T>
constexpr ComponentMoveCtor GetMoveDtorImpl(EComponentOpsFlags&)
-
template<typename T>
constexpr ComponentMoveCtor GetMoveDtorImpl(EComponentOpsFlags &flags)
-
template<typename T>
constexpr ComponentMoveCtor GetMoveAssignDtorImpl(EComponentOpsFlags&)#
-
template<typename T>
constexpr ComponentMoveCtor GetMoveAssignDtorImpl(EComponentOpsFlags &flags)
-
template<typename T>
constexpr ComponentMoveCtor GetMoveAssignDtorImpl(EComponentOpsFlags&)
-
template<typename T>
constexpr ComponentOps GetOps(EComponentOpsFlags &flags)# Get the operations for a component.
- Template Parameters:
T – Type of the component.
- Returns:
Operations for the component.
-
template<typename T>
ComponentInfo GetComponentInfo()#
-
struct ComponentInfo#
Public Members
-
std::size_t size#
-
std::size_t alignment#
-
const char *name#
-
ComponentOps ops#
-
EComponentOpsFlags opsFlags#
-
void *userCtx#
-
void (*userCtxFree)(void*)#
-
std::size_t size#
-
struct ComponentOps#
Public Members
-
ComponentCtor ctor#
-
ComponentDtor dtor#
-
ComponentCopy copy#
-
ComponentMove move#
-
ComponentCopyCtor copyCtor#
-
ComponentMoveCtor moveCtor#
-
ComponentMoveCtor moveDtor#
-
ComponentMoveCtor moveAssignDtor#
-
ComponentCtor ctor#
-
namespace detail#
-
Functions
-
template<typename T>
static std::pair<EEntityRegisterStatus, std::uint64_t*> GetEntityIdImpl(const void *worldPtr)# Get the entity id for a given entity type.
- Template Parameters:
T – Type of the entity, without cvref.
- Parameters:
worldPtr – Pointer to the world.
- Returns:
Pair with the status of the entity and the entity id.
-
template<typename T>
static std::pair<EEntityRegisterStatus, std::uint64_t*> GetEntityId(const void *worldPtr)# Get the entity id for a given entity type.
- Template Parameters:
T – Type of the entity.
- Parameters:
worldPtr – Pointer to the world.
- Returns:
Pair with the status of the entity and the entity id.
-
template<typename T>
-
using ComponentCtor = void (*)(void *array, std::int32_t count, const void *componentInfo)#
-
namespace DefaultObjects#
-
Functions
-
Entity::EntityId MakeDefault(Scene *activeScene, EDefaultObjectType objectType)#
-
Entity::EntityId MakeDefault(Scene *activeScene, EDefaultObjectType objectType)#
-
namespace Export#
Functions
-
template<std::size_t N>
constexpr void name(const char (&name)[N])# Renames a class or struct.
- Parameters:
name – The new name of the class or struct. For instance, given the following class: class [[hush::export(Hush::Export::name(“MyExportedClass”))]] MyClass2 { public: int myVariable; }; The generated C code will be: typedef struct MyExportedClass MyExportedClass;
Variables
-
constexpr bool asHandle = true#
Export a class or struct as a handle. This will generate a typedef for the class or struct. If not defined, the class or struct will be exported as a struct with all the members.
For instance, given the following class: class [[hush::export(Hush::Export::asHandle)]] MyClass { public: int myVariable; }; The generated C code will be: typedef struct MyClass MyClass;
-
constexpr bool ignore = true#
Ignores a member of a class or struct. It, however, will be exported as a buffer. For instance, given the following class: class [[hush::export(Hush::Export::ignore)]] MyClass { public: int myVariable; [[hush::export(Hush::Export::ignore)]] int myVariable2; }; The generated C code will be: typedef struct MyClass MyClass { int myVariable; alignas(4) char myVariable2[4]; };
-
template<std::size_t N>
-
namespace GltfLoadFunctions#
Enums
Functions
-
glm::mat4 GetNodeTransform(const fastgltf::Node &node)#
-
EMaterialPass GetMaterialPassFromFastGltfPass(fastgltf::AlphaMode pass)#
-
std::shared_ptr<ImageTexture> TextureFromImageDataSource(const fastgltf::Asset &asset, const fastgltf::Image &image)#
-
EError SetMaterialTextures(GLTFMetallicRoughness *outMaterialResources, const fastgltf::Asset &asset, const fastgltf::Material &material, const void *loadedTextures)#
-
template<class BufferType>
inline std::vector<BufferType> FindAttributeByName(const fastgltf::Primitive &primitive, const fastgltf::Asset &asset, const std::string_view &attributeName)#
-
glm::mat4 GetNodeTransform(const fastgltf::Node &node)#
-
namespace Hashing#
-
namespace impl#
-
class QueryImpl#
Subclassed by Hush::Query< Components >
-
class QueryImpl#
-
namespace Mat4Math#
-
namespace MathUtils#
-
namespace Networking#
-
namespace Reflection#
Functions
-
class FieldInfo#
Public Types
-
using EVariantError = Variant::EVariantError#
-
using Setter = std::function<EVariantError(std::span<const VariantView>)>#
-
using Getter = std::function<Result<Variant, EVariantError>(std::span<const VariantView>)>#
Public Functions
-
inline FieldInfo(TypeId typeId, std::string name, Setter setter, Getter getter, uint64_t offset = 0)#
-
inline std::string_view GetName() const#
-
inline Result<Variant, Variant::EVariantError> Get(std::span<const VariantView> args) const#
-
inline Result<Variant, Variant::EVariantError> Get(std::initializer_list<const VariantView> args) const#
-
inline EVariantError Set(const std::span<const VariantView> args) const#
-
inline EVariantError Set(std::initializer_list<VariantView> args) const#
-
inline uint64_t GetOffset() const#
-
using EVariantError = Variant::EVariantError#
-
class FunctionInfo#
Public Types
-
enum class EFunctionInfoError : uint8_t#
Values:
-
enumerator None#
-
enumerator InvalidType#
-
enumerator InvalidArgsCount#
-
enumerator InvalidArgsType#
-
enumerator NonMatchingArgs#
-
enumerator None#
-
using CallFunc = Result<Variant, EFunctionInfoError> (*)(std::span<const VariantView>)#
Public Functions
-
inline Result<Variant, EFunctionInfoError> Call(std::span<const VariantView> args) const#
Calls the function with the given arguments.
- Parameters:
returnVal – Return value type.
args – Arguments to the function.
- Returns:
Result with the return value or an error.
-
template<typename ...Args>
inline Result<Variant, EFunctionInfoError> Call(Args&&... args) const# Calls the function with the given arguments.
- Template Parameters:
Args – Arguments to the function.
- Parameters:
returnVal – Return value type.
args – Arguments to the function.
- Returns:
Result with the return value or an error.
-
inline std::uint64_t GetArgsCount() const#
-
inline bool IsCallableWith(std::span<const VariantView> args) const#
-
inline std::string_view GetName() const#
Public Static Functions
-
template<typename ...Args>
static inline FunctionInfo Create(CallFunc callFunc, std::string name)#
Public Static Attributes
-
static constexpr std::uint8_t MAX_ARGS = 16#
-
enum class EFunctionInfoError : uint8_t#
-
class ReflectionDB#
Public Functions
-
template<ReflectedType T>
inline RegisterClassBuilder<T> RegisterClass()#
-
template<typename T>
struct RegisterClassBuilder# Public Functions
-
inline explicit RegisterClassBuilder(ReflectionDB *reflectionDB)#
-
inline RegisterClassBuilder &AddConstructor(FunctionInfo constructor)#
-
inline RegisterClassBuilder &AddInPlaceConstructor(TypeInfo::InPlaceCtor ctor)#
-
inline RegisterClassBuilder &AddFunction(FunctionInfo function)#
-
inline RegisterClassBuilder &SizeOf(std::size_t size)#
-
inline RegisterClassBuilder &AlignmentOf(std::size_t alignment)#
-
inline RegisterClassBuilder &AddProperty(FieldInfo property)#
-
inline void Register()#
-
inline explicit RegisterClassBuilder(ReflectionDB *reflectionDB)#
-
template<ReflectedType T>
-
class TypeInfo#
Public Types
-
enum class EInPlaceConstructorError#
Values:
-
enumerator None#
-
enumerator InsufficientMemory#
-
enumerator NoInPlaceConstructors#
-
enumerator NonMatchingArgs#
-
enumerator InvalidType#
-
enumerator None#
-
using InPlaceCtorFunc = EInPlaceConstructorError (*)(void *mem, std::span<const VariantView>)#
Public Functions
-
inline void AddFunction(const FunctionInfo &function)#
-
inline std::span<const FunctionInfo> GetFunctions() const#
-
inline std::optional<std::reference_wrapper<const FieldInfo>> GetField(std::string_view name) const#
-
inline const std::string &GetName() const#
-
inline void SetName(std::string_view name)#
-
inline std::size_t GetSize() const#
-
inline void SetSize(std::size_t size)#
-
inline std::size_t GetAlignment() const#
-
inline void SetAlignment(std::size_t alignment)#
-
inline Result<Variant, FunctionInfo::EFunctionInfoError> CreateInstance(std::span<const VariantView> args) const#
Creates an instance of this type with the given arguments and returns it as a Variant. If you wish to create an instance in a specific memory location, or avoid heap allocation, use CreateInPlaceInstance(void *mem, size_t memSize, std::span<const VariantView> args) const instead.
Note
This function might allocate memory for the instance, depending on the size of the type. See Hush::Reflection::Variant::MAX_SIZE for the maximum size of a type that can be created without allocating in the heap.
- Parameters:
args – Arguments to pass to the constructor.
- Returns:
Result with the created instance or an error.
-
inline Result<Variant, FunctionInfo::EFunctionInfoError> CreateInstance(std::initializer_list<const VariantView> args) const#
Creates an instance of this type with the given arguments. See CreateInstance(std::span<constVariantView> args) const for more information.
- Parameters:
args – Arguments to pass to the constructor.
- Returns:
Result with the created instance or an error.
-
inline std::optional<EInPlaceConstructorError> CreateInPlaceInstance(void *mem, size_t memSize, std::span<const VariantView> args) const#
Creates an instance of this type in-place using the provided memory and arguments. This function checks if the provided memory is sufficient and if there are any in-place constructors available.
When using this function, ensure that the memory provided is properly aligned for the type being constructed. Also, the memory must be large enough to hold the type’s data.
Note
This function is designed for advanced use cases where you need to create an instance of a type in a specific memory location, This function never allocates memory for the instance.
Warning
Keep in mind that this function does not keep track of the lifetime of the created instance. You’re responsible for managing the memory and ensuring that the instance is destroyed properly.
- Parameters:
mem – Pointer to the memory where the instance should be created.
memSize – Size of the memory in bytes. Must be at least as large as the size of the type.
args – Arguments to pass to the in-place constructor.
- Returns:
An optional error if the in-place construction fails, or an empty optional if it succeeds.
-
inline std::optional<EInPlaceConstructorError> CreateInPlaceInstance(void *mem, size_t memSize, std::initializer_list<const VariantView> args) const#
Creates an instance of this type in-place using the provided memory and arguments. See CreateInPlaceInstance(void *mem, size_t memSize, std::span<const VariantView> args) const for more information.
- Parameters:
mem – Pointer to the memory where the instance should be created.
memSize – Size of the memory in bytes.
args – Arguments to pass to the in-place constructor.
- Returns:
An optional error if the in-place construction fails, or an empty optional if it succeeds.
-
inline Result<Variant, FunctionInfo::EFunctionInfoError> CallFunction(std::string_view name, std::span<const VariantView> args) const#
Calls a function with the given name and arguments. This helper function searches for a function in O(n) time, where n is the number of functions in this type. This also supports overloaded functions, as it checks the argument types to find a matching function.
- Parameters:
name – Name of the function to call.
args – Arguments to pass to the function.
- Returns:
Result with the return value or an error.
-
inline Result<Variant, FunctionInfo::EFunctionInfoError> CallFunction(std::string_view name, std::initializer_list<const VariantView> args) const#
Calls a function with the given name and arguments. This is a convenience overload that allows passing arguments as an initializer list. For more information, see the CallFunction(std::string_view name, std::span<const VariantView> args) const function.
- Parameters:
name – Name of the function to call.
args – Arguments to pass to the function.
- Returns:
Result with the return value or an error.
-
inline void SetConstructors(std::vector<FunctionInfo> &&constructors)#
-
inline void SetFunctions(std::vector<FunctionInfo> &&functions)#
-
inline void SetInPlaceCtors(std::vector<InPlaceCtor> &&inPlaceCtor)#
Sets the in-place constructors for this type.
- Parameters:
inPlaceCtor – A vector of in-place constructors to set.
-
struct InPlaceCtor#
Public Functions
-
inline InPlaceCtor(InPlaceCtorFunc callFunc, std::span<const TypeId> args)#
-
inline EInPlaceConstructorError ConstructUnchecked(void *mem, std::span<const VariantView> args) const#
-
inline bool IsCallableWith(std::span<const VariantView> args) const#
Public Members
-
std::array<TypeId, FunctionInfo::MAX_ARGS> m_argsType#
-
InPlaceCtorFunc m_func#
-
uint8_t m_argsCount = {}#
Public Static Functions
-
template<typename ...Args>
static inline InPlaceCtor Create(InPlaceCtorFunc callFunc)#
-
inline InPlaceCtor(InPlaceCtorFunc callFunc, std::span<const TypeId> args)#
-
enum class EInPlaceConstructorError#
-
class Variant#
Public Types
-
using EVariantError = VariantView::EVariantError#
-
using EVariantError = VariantView::EVariantError#
-
struct VariantView#
- #include <Variant.hpp>
A VariantView that holds a reference to any type.
-
class FieldInfo#
-
namespace Serialization#
Enums
-
enum class EFormatDescribingType#
Describing format type. A self-describing format is a format that includes the type information in the format itself. For instance, JSON contains the name of the field along with the value (which is of a specific type). A non-self-describing format is a format that does not include the type information in the format itself. For instance, a binary format may not include the name of the field along with the value.
Values:
-
enumerator SelfDescribing#
Self-describing format.
-
enumerator NonSelfDescribing#
Non-self-describing format.
-
enumerator SelfDescribing#
Functions
-
template<typename T>
inline Result<T, EDeserializationError> DeserializeJson(std::string_view json)#
-
template<typename T>
inline Result<std::string, ESerializationError> SerializeJson(const T &value)#
-
class IVisitor#
- #include <Deserialization.hpp>
Base class for visitors. A Serialization visitor is a class that implements the visitor pattern to visit the different types of data that a format passes. For instance, when a JSON parser sees a number, it will call the VisitInt method of the visitor.
TODO(Alan): how a non-self-describing format will work? We might need to implement a VisitRaw(const char* data,
size_t maxSize, size_t currentOffset)?
Subclassed by Hush::Serialization::BuiltinVisitors::FloatVisitor< double >, Hush::Serialization::BuiltinVisitors::FloatVisitor< float >, Hush::Serialization::BuiltinVisitors::IntVisitor< int16_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< int32_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< int64_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< int8_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< uint16_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< uint32_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< uint64_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< uint8_t >, Hush::Serialization::Visitor< T, typename >
Public Types
-
using Result = Hush::Result<IVisitor*, EDeserializationError>#
Public Functions
-
inline IVisitor(IVisitor *parent, EFormatDescribingType format)#
-
virtual ~IVisitor() = default#
-
inline virtual Result VisitInt8(std::int8_t value)#
Visit a signed 8-bit integer.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitInt16(std::int16_t value)#
Visit a signed 16-bit integer.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitInt32(std::int32_t value)#
Visit a signed 32-bit integer.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitInt64(std::int64_t value)#
Visit a signed 64-bit integer.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitUInt8(std::uint8_t value)#
Visit an unsigned 8-bit integer.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitUInt16(std::uint16_t value)#
Visit an unsigned 16-bit integer.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitUInt32(std::uint32_t value)#
Visit an unsigned 32-bit integer.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitUInt64(std::uint64_t value)#
Visit an unsigned 64-bit integer.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitFloat(float value)#
Visit a float value.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitDouble(double value)#
Visit a double value.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitBool(bool value)#
Visit a boolean value.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitString(std::string_view value)#
Visit a string value.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitNull()#
Visit a null value.
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitArrayStart()#
Visit an array start.
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitArrayEnd()#
Visit the end of an array.
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitObjectStart()#
Visit the start of an object.
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitObjectEnd()#
Visit the end of an object.
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitKey(std::string_view value)#
Visit a key in an object.
- Parameters:
value – Key to visit
- Returns:
Result with the next visitor or an error.
-
using Result = Hush::Result<IVisitor*, EDeserializationError>#
-
class JsonDeserializer#
Public Functions
-
inline JsonDeserializer(std::string_view json)#
-
template<typename T>
inline Result<T, EDeserializationError> Deserialize()#
-
template<typename T>
inline Result<T, EDeserializationError> Deserialize()
-
inline JsonDeserializer(std::string_view json)#
-
class JsonSerializer#
- #include <JsonSerializer.hpp>
JsonSerializer class.
This class is used to serialize data to a JSON string. It has member functions to set keys, start and end objects, and serialize data. It also supports serializing custom types that follow the IsSerializable concept.
Public Functions
-
inline JsonSerializer()#
-
inline ESerializationError SetKey(std::string_view key)#
Sets the key for the next value to be serialized.
- Parameters:
key – Key to serialize
- Returns:
SerializationError
-
inline ESerializationError BeginObject()#
Begins an object in the JSON string.
- Returns:
SerializationError
-
inline ESerializationError EndObject()#
Ends an object in the JSON string.
- Returns:
SerializationError
-
template<IsSerializable<JsonSerializer> T>
inline ESerializationError Serialize(const T &value)# Serializes an object to a JSON string.
- Template Parameters:
T – Serializable object
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<typename T>
inline ESerializationError Serialize(const T&)#
-
template<typename T>
inline ESerializationError Serialize(const T)#
-
template<typename T>
inline ESerializationError SerializeArray(const std::span<const T> values)# Serializes a span of values to a JSON array.
- Parameters:
values – Value to serialize
- Returns:
SerializationError
-
template<typename V, IsMapIterator<std::string, V> It>
inline ESerializationError SerializeMap(It begin, It end)# Serializes a map of values to a JSON object.
- Template Parameters:
V – Value type
It – Iterator type
- Parameters:
begin – Begin iterator
end – End iterator
- Returns:
SerializationError
-
template<typename T>
inline ESerializationError Serialize(std::string_view key, const T &value)# Serializes a key-value pair to a JSON object.
- Template Parameters:
T – Type
- Parameters:
key – Key
value – Value
- Returns:
SerializationError
-
template<typename T>
inline ESerializationError Serialize(std::string_view key, const std::span<const T> values)# Serializes an array of values to a JSON array.
- Template Parameters:
T – Type
- Parameters:
key – Key
values – Values
- Returns:
SerializationError
-
template<typename V, IsMapIterator<std::string, V> It>
inline ESerializationError Serialize(std::string_view key, It begin, It end)# Serializes a map of values to a JSON object.
- Template Parameters:
V – Value type
It – Iterator type
- Parameters:
key – Key
begin – Iterator begin
end – Iterator end
- Returns:
SerializationError
-
inline std::string FinishSerialization()#
Finalizes the serialization process and returns the serialized JSON string. You should not call any other function after this one.
- Returns:
Serialized JSON string
-
template<>
inline ESerializationError Serialize(const double value)# Serializes a double value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const float value)# Serializes a float value to a JSON string.
- Parameters:
key – Key to serialize
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const bool value)# Serializes a boolean value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::uint8_t value)# Serializes an uint8 value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::uint16_t value)# Serializes an uint16 value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::uint32_t value)# Serializes an uint32 value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::uint64_t value)# Serializes an uint64 value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::int8_t value)# Serializes an int8 value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::int16_t value)# Serializes an int16 value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::int32_t value)# Serializes an int32 value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::int64_t value)# Serializes an int64 value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::string &value)# Serializes a string value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::string_view value)# Serializes a string_view value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
inline JsonSerializer()#
-
template<typename T, typename = void>
struct Visitor : public Hush::Serialization::IVisitor# Public Functions
-
inline Visitor(IVisitor *parent, T *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, T *value, EFormatDescribingType describingType)#
- template<typename T> Visitor< T > : public Hush::Serialization::BuiltinVisitors::Visitor< T > , public decltypestd::declval< T & >Deserializestd::declval , public EFormatDescribingType::NonSelfDescribing
Public Types
-
using Parent = decltype(std::declval<T&>().Deserialize(std::declval<IVisitor*>(), EFormatDescribingType::NonSelfDescribing))#
-
using Type = T#
Public Functions
-
inline Visitor(IVisitor *parent, T *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, T *value, EFormatDescribingType describingType)
-
using Parent = decltype(std::declval<T&>().Deserialize(std::declval<IVisitor*>(), EFormatDescribingType::NonSelfDescribing))#
-
namespace BuiltinVisitors#
-
template<typename F>
struct FloatVisitor : public Hush::Serialization::IVisitor# Public Types
-
using Exists = std::true_type#
Public Functions
-
inline FloatVisitor(IVisitor *parent, F *value, EFormatDescribingType describingType)#
-
using Exists = std::true_type#
-
template<typename IntType>
struct IntVisitor : public Hush::Serialization::IVisitor# Public Types
-
using Exists = std::true_type#
Public Functions
-
inline IntVisitor(IVisitor *parent, IntType *value, EFormatDescribingType describingType)#
-
using Exists = std::true_type#
-
template<typename T>
struct Visitor : public Hush::Serialization::IVisitor# Subclassed by Hush::Serialization::Visitor< T >
Public Types
-
using Exists = std::false_type#
-
using Exists = std::false_type#
-
template<>
struct Visitor<bool> : public Hush::Serialization::IVisitor# Public Functions
-
inline Visitor(IVisitor *parent, bool *value, EFormatDescribingType describingType)#
Public Members
-
bool *value = {}#
-
inline Visitor(IVisitor *parent, bool *value, EFormatDescribingType describingType)#
-
template<>
struct Visitor<double> : public Hush::Serialization::BuiltinVisitors::FloatVisitor<double># Public Functions
-
inline Visitor(IVisitor *parent, double *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, double *value, EFormatDescribingType describingType)#
-
template<>
struct Visitor<float> : public Hush::Serialization::BuiltinVisitors::FloatVisitor<float># Public Types
-
using Exists = std::true_type#
Public Functions
-
inline Visitor(IVisitor *parent, float *value, EFormatDescribingType describingType)#
-
using Exists = std::true_type#
-
template<>
struct Visitor<int16_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<int16_t># Public Functions
-
inline Visitor(IVisitor *parent, int16_t *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, int16_t *value, EFormatDescribingType describingType)#
-
template<>
struct Visitor<int32_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<int32_t># Public Functions
-
inline Visitor(IVisitor *parent, int32_t *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, int32_t *value, EFormatDescribingType describingType)#
-
template<>
struct Visitor<int64_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<int64_t># Public Functions
-
inline Visitor(IVisitor *parent, int64_t *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, int64_t *value, EFormatDescribingType describingType)#
-
template<>
struct Visitor<int8_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<int8_t># Public Types
-
using Exists = std::true_type#
Public Functions
-
inline Visitor(IVisitor *parent, int8_t *value, EFormatDescribingType describingType)#
-
using Exists = std::true_type#
-
template<>
struct Visitor<std::map<std::string, std::string>> : public Hush::Serialization::IVisitor# Public Types
-
using Exists = std::true_type#
Public Functions
-
inline Visitor(IVisitor *parent, std::map<std::string, std::string> *value, EFormatDescribingType describingType)#
-
using Exists = std::true_type#
-
template<>
struct Visitor<std::string> : public Hush::Serialization::IVisitor# Public Types
-
using Exists = std::true_type#
Public Functions
-
inline Visitor(IVisitor *parent, std::string *value, EFormatDescribingType describingType)#
Public Members
-
std::string *value = {}#
-
using Exists = std::true_type#
-
template<>
struct Visitor<uint16_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<uint16_t># Public Functions
-
inline Visitor(IVisitor *parent, uint16_t *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, uint16_t *value, EFormatDescribingType describingType)#
-
template<>
struct Visitor<uint32_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<uint32_t># Public Functions
-
inline Visitor(IVisitor *parent, uint32_t *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, uint32_t *value, EFormatDescribingType describingType)#
-
template<>
struct Visitor<uint64_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<uint64_t># Public Functions
-
inline Visitor(IVisitor *parent, uint64_t *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, uint64_t *value, EFormatDescribingType describingType)#
-
template<>
struct Visitor<uint8_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<uint8_t># Public Functions
-
inline Visitor(IVisitor *parent, uint8_t *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, uint8_t *value, EFormatDescribingType describingType)#
-
template<typename F>
-
enum class EFormatDescribingType#
-
namespace StringUtils#
Provides utility functions for handling strings (C and std strings)
Functions
-
std::wstring ToWString(const char *data)#
Converts the given char* to a standard wstring, used for Windows, since char_t* is wchar_t*.
- Parameters:
data – String to convert
- Returns:
wstring of the converted string, from 8B to 16B chars
-
std::string FromWString(const std::wstring &str)#
-
inline constexpr std::string_view SubstrView(const std::string &str, int32_t offset, int32_t endIdx)#
-
std::wstring ToWString(const char *data)#
-
namespace Tests#
-
namespace Threading#
Enums
Functions
-
constexpr uint64_t pack(uint32_t workerHead, uint32_t stealerHead) noexcept#
Pack two 32-bit integers into a 64-bit integer.
-
constexpr std::tuple<uint32_t, uint32_t> unpack(uint64_t value) noexcept#
Unpack a 64-bit integer into two 32-bit integers.
- Parameters:
value – The 64-bit integer to unpack.
- Returns:
A tuple containing the worker’s head index and the stealer’s head index.
-
template<typename T>
Task<void> RunOn(Hush::Threading::Concepts::Executor auto *executor, Task<T> task)#
-
inline impl::SelfDeleteTask MakeSelfDeleteTask(Task<void> task) noexcept#
-
template<Concepts::Awaitable A, typename T = typename Concepts::AwaitableTraits<A>::ResultType>
decltype(auto) Wait(A &&awaitable)#
-
template<Concepts::Awaitable... Awaitables>
auto WhenAll(Awaitables&&... awaitables)#
-
template<std::ranges::range RangeType, Concepts::Awaitable AwaitableType = typename std::ranges::range_value_t<RangeType>, typename T = typename Concepts::AwaitableTraits<AwaitableType>::ResultType>
auto WhenAll(RangeType awaitables)#
Variables
-
static constexpr size_t MAX_PARALLEL_TASKS = 1024#
-
static constexpr size_t MIN_CHUNK_SIZE = 1000#
-
template<typename T, size_t Size>
class Stealer# - #include <StealingQueue.hpp>
Handle for multi-threaded stealing operations.
- Template Parameters:
T – The type of the items in the queue.
Size – The size of the queue. It must be a power of 2 and less than 2^31.
-
template<typename T, size_t Size>
class StealingQueue# - #include <StealingQueue.hpp>
This queue is heavily inspired by the work of asynchronics/st3, which is a Rust implementation of a stealing queue. Its work is MIT-licensed and can be found at: asynchronics/st3
Its work is based on Tokio’s worker queue, itself based on Go scheduler work-stealing queues.
Unlike his implementation, we use a statically-sized array to store the data because it is meant to be used by our thread pool.
This queue is a ring buffer with wrap-around semantics with a tail and a head positions. The actual buffer index is the least significant bits of the tail and head positions.
- Template Parameters:
T – The type of the elements stored in the queue. It must be a trivial type (non trivial types could be implemented in the future).
Size – The size of the queue. It must be a power of 2 and less than 2^31.
Public Functions
-
inline StealingQueue() noexcept#
-
StealingQueue(const StealingQueue&) = delete#
-
StealingQueue &operator=(const StealingQueue&) = delete#
-
StealingQueue(StealingQueue&&) = delete#
-
StealingQueue &operator=(StealingQueue&&) = delete#
-
~StealingQueue() noexcept#
-
T &ReadAt(uint32_t index) noexcept#
Read an item at the given index in the queue.
This position is mapped to a valid ring buffer index using the mask.
For this to work correctly, the item must have been previously initialized at that index.
- Parameters:
index – The index to read from. It must be less than the capacity of the queue.
- Returns:
A reference to the item at the given index.
-
void WriteAt(uint32_t index, T &&value) noexcept#
Write an item at the given index in the queue.
This position is mapped to a valid ring buffer index using the mask.
If a previous item was at that index, it will be overwritten and not destructed. So care must be taken.
- Parameters:
index – The index to write to.
value – The value to write at the given index. It must be a valid item.
-
template<typename F>
Result<std::tuple<uint32_t, uint32_t>, EStealError> MarkForSteal(F &countFunc, uint32_t maxCount)# Attempt to mark a range of items for stealing. The amount of items is determined by the provided function
countFunc
, which is invoked with the number of items available in the queue.In case of success, it returns a tuple containing the stealer’s head index and the number of items. The number of items is guaranteed to be at least 1.
If the queue is empty, it returns
EStealError::Empty
. If the queue is busy (concurrent stealing operation), it returnsEStealError::Busy
.- Template Parameters:
F – The type of the function that will be used to determine the number of items to steal. It must take a size_t and return a size_t.
- Parameters:
countFunc – The function that will be used to determine the number of items to steal. It is invoked with the number of items available in the queue.
maxCount – The maximum number of items to steal. It is used to limit the number of items stolen in case the function returns a larger value than the available items.
- Returns:
A Result containing a tuple with the stealer’s head index and the number of items stolen, or an EStealError in case of failure.
-
inline constexpr uint32_t Capacity() const noexcept#
-
template<typename T>
class SyncWait#
-
template<typename T>
class SyncWaitTask# - #include <SyncWait.hpp>
Sync wait task.
Public Types
-
using promise_type = impl::SyncWaitPromise<T>#
-
using CoroutineType = std::coroutine_handle<promise_type>#
Public Functions
-
inline SyncWaitTask(CoroutineType coroutine) noexcept#
Constructor
- Parameters:
coroutine – coroutine handle
-
inline SyncWaitTask(SyncWaitTask &&other) noexcept#
Move constructor
- Parameters:
other – Other SyncWaitTask to move from
-
inline SyncWaitTask &operator=(SyncWaitTask &&other) noexcept#
Move assignment operator
- Parameters:
other – Other SyncWaitTask to move from
- Returns:
self
-
inline ~SyncWaitTask()#
Destructor.
-
inline promise_type &promise() & noexcept#
Returns the promise
- Returns:
The promise
-
inline const promise_type &promise() const & noexcept#
Returns the promise
- Returns:
The promise
-
inline promise_type &&promise() && noexcept#
Returns the promise
- Returns:
The promise
-
inline CoroutineType GetCoroutine() const noexcept#
Returns the coroutine
- Returns:
The coroutine
-
inline CoroutineType GetCoroutine() noexcept#
Returns the coroutine
- Returns:
The coroutine
-
using promise_type = impl::SyncWaitPromise<T>#
-
template<typename T>
struct Task# -
Public Functions
-
inline Task() noexcept#
-
inline explicit Task(std::coroutine_handle<promise_type> coroutine) noexcept#
-
inline ~Task()#
-
inline bool Ready() const noexcept#
-
inline bool Resume()#
-
inline auto operator co_await() const & noexcept#
-
inline std::coroutine_handle<promise_type> GetCoroutine() const noexcept#
-
inline Task() noexcept#
-
template<typename T, size_t Size>
class Worker# - #include <StealingQueue.hpp>
Handle for single-threaded FIFO operations.
- Template Parameters:
T – The type of the items in the queue.
Size – The size of the queue. It must be a power of 2 and less than 2^31.
Public Functions
-
Worker() noexcept#
-
Stealer<T, Size> MakeStealer() noexcept#
Creates a new stealer associated with this worker queue.
Any number of stealers can be created from a single worker queue.
- Returns:
A new Stealer instance that can be used to steal items from this worker queue.
-
size_t Capacity() const noexcept#
Returns the capacity of the worker queue.
- Returns:
The capacity of the worker queue, which is equal to Size.
-
size_t SpareCapacity() const noexcept#
Returns the number of items that can be succesfully pushed onto the queue.
This number might not reflect the real number due to concurrent stealing operations.
- Returns:
The number of items that can be succesfully pushed onto the queue.
-
bool IsEmpty() const noexcept#
Returns true if the worker queue is empty, false otherwise.
While the queue size might not be accurate, it is guaranteed that if a call to
IsEmpty()
returns true, a subsequent call toPop()
will fail.- Returns:
True if the worker queue is empty, false otherwise.
-
namespace Concepts#
-
-
template<Awaitable A, typename = void>
struct AwaitableTraits#
-
template<Awaitable A>
struct AwaitableTraits<A># Public Types
-
using AwaiterType = decltype(GetAwaiter(std::declval<A>()))#
-
using ResultType = decltype(std::declval<AwaiterType>().await_resume())#
-
using AwaiterType = decltype(GetAwaiter(std::declval<A>()))#
-
template<typename T, typename = void>
struct ExecutorTraits#
-
template<Awaitable A, typename = void>
-
namespace Executors#
Variables
-
static constexpr size_t WORKER_QUEUE_SIZE = 256#
-
static constexpr size_t GLOBAL_QUEUE_STEALING_COUNT = 64#
-
thread_local WorkerThread *g_currentWorkerThread = nullptr#
-
class TaskOperation#
-
class ThreadPool#
Public Functions
-
~ThreadPool()#
-
TaskOperation Schedule()#
-
inline uint32_t GetNumThreads() const noexcept#
Public Static Functions
-
static ThreadPool Create(ThreadPoolOptions options = ThreadPoolOptions())#
-
~ThreadPool()#
-
struct ThreadPoolOptions#
-
class WorkerThread#
Public Functions
-
inline WorkerThread(ThreadPool &threadpool, std::barrier<> &startBarrier, int32_t threadAffinity)#
-
inline void SetStealers(std::vector<Stealer<TaskOperation*, WORKER_QUEUE_SIZE>> workers) noexcept#
-
inline void Wake() noexcept#
-
inline Stealer<TaskOperation*, WORKER_QUEUE_SIZE> MakeStealer() noexcept#
-
inline void Stop() noexcept#
-
inline void Join() noexcept#
-
inline WorkerThread(ThreadPool &threadpool, std::barrier<> &startBarrier, int32_t threadAffinity)#
-
static constexpr size_t WORKER_QUEUE_SIZE = 256#
-
namespace impl#
Functions
-
template<Concepts::Awaitable A, typename T = typename Concepts::AwaitableTraits<A>::ResultType>
static SyncWaitTask<T> MakeSyncWaitTask(A &&awaitable)#
-
template<Concepts::Awaitable A, typename T = typename Concepts::AwaitableTraits<A>::ResultType>
static WhenAllTask<T> MakeWhenAllTask(A awaitable)#
-
struct PromiseBase#
Subclassed by Hush::Threading::impl::TaskPromise< T >, Hush::Threading::impl::TaskPromise< T & >, Hush::Threading::impl::TaskPromise< void >
Public Functions
-
PromiseBase() noexcept = default#
-
inline std::suspend_always initial_suspend() noexcept#
-
inline FinalAwaiter final_suspend() noexcept#
-
inline void SetContinuation(std::coroutine_handle<> coroContinuation) noexcept#
Public Members
-
std::coroutine_handle continuation#
-
struct FinalAwaiter#
Public Functions
-
inline bool await_ready() const noexcept#
-
template<typename PromiseType>
inline std::coroutine_handle await_suspend(std::coroutine_handle<PromiseType> coroutine) noexcept#
-
inline void await_resume() noexcept#
-
inline bool await_ready() const noexcept#
-
PromiseBase() noexcept = default#
-
class SelfDeletePromise#
Public Functions
-
inline SelfDeletePromise() noexcept#
-
SelfDeletePromise(SelfDeletePromise&&) noexcept = default#
-
SelfDeletePromise(const SelfDeletePromise&) = delete#
-
SelfDeletePromise &operator=(SelfDeletePromise&&) noexcept = default#
-
SelfDeletePromise &operator=(const SelfDeletePromise&) = delete#
-
~SelfDeletePromise() noexcept = default#
-
inline SelfDeleteTask get_return_object() noexcept#
-
inline std::suspend_always initial_suspend() noexcept#
-
inline std::suspend_never final_suspend() noexcept#
-
inline void return_void() noexcept#
-
inline void unhandled_exception() noexcept#
-
inline SelfDeletePromise() noexcept#
-
class SelfDeleteTask#
Public Types
-
using promise_type = SelfDeletePromise#
Public Functions
-
inline explicit SelfDeleteTask(promise_type &promise) noexcept#
-
inline SelfDeleteTask(SelfDeleteTask &&other) noexcept#
-
inline SelfDeleteTask &operator=(SelfDeleteTask &&other) noexcept#
-
SelfDeleteTask(const SelfDeleteTask&) = delete#
-
SelfDeleteTask &operator=(const SelfDeleteTask&) = delete#
-
inline promise_type *GetPromise() const noexcept#
-
inline std::coroutine_handle<promise_type> GetCoroutineHandle() const noexcept#
-
inline bool Resume() const noexcept#
-
using promise_type = SelfDeletePromise#
-
template<typename T>
struct SyncWaitPromise : public Hush::Threading::impl::SyncWaitPromiseBase# Public Types
-
using ResultType = std::conditional_t<std::is_reference_v<T>, std::remove_reference_t<T>*, std::remove_const_t<T>>#
-
using VariantType = std::variant<std::monostate, ResultType, std::exception_ptr>#
-
using coroutine_type = std::coroutine_handle<SyncWaitPromise>#
Public Functions
-
SyncWaitPromise() noexcept = default#
-
SyncWaitPromise(SyncWaitPromise&&) noexcept = delete#
-
SyncWaitPromise &operator=(SyncWaitPromise&&) noexcept = delete#
-
SyncWaitPromise(const SyncWaitPromise&) noexcept = delete#
-
SyncWaitPromise &operator=(const SyncWaitPromise&) noexcept = delete#
-
~SyncWaitPromise() = default#
-
inline std::suspend_always initial_suspend() noexcept#
-
inline void Start(std::atomic_flag &done) noexcept#
-
inline auto get_return_object() noexcept#
-
inline void Wait() noexcept#
-
inline void return_value(ResultType value) noexcept#
-
inline auto final_suspend() noexcept#
-
inline decltype(auto) Result() &#
-
inline decltype(auto) Result() const &#
-
inline decltype(auto) Result() && noexcept#
-
inline void unhandled_exception() noexcept#
-
using ResultType = std::conditional_t<std::is_reference_v<T>, std::remove_reference_t<T>*, std::remove_const_t<T>>#
-
template<>
struct SyncWaitPromise<void> : public Hush::Threading::impl::SyncWaitPromiseBase# Public Types
-
using CoroutineType = std::coroutine_handle<SyncWaitPromise>#
Public Functions
-
SyncWaitPromise() noexcept = default#
-
~SyncWaitPromise() = default#
-
inline void Start(std::atomic_flag &done) noexcept#
-
inline void Wait() noexcept#
-
inline auto get_return_object() noexcept#
-
inline auto final_suspend() noexcept#
-
inline void return_void() noexcept#
-
inline void Result() noexcept#
-
inline void unhandled_exception() noexcept#
-
using CoroutineType = std::coroutine_handle<SyncWaitPromise>#
-
struct SyncWaitPromiseBase#
Subclassed by Hush::Threading::impl::SyncWaitPromise< T >, Hush::Threading::impl::SyncWaitPromise< void >
-
template<typename T>
struct TaskPromise : public Hush::Threading::impl::PromiseBase#
-
template<>
struct TaskPromise<void> : public Hush::Threading::impl::PromiseBase#
-
class WhenAllLatch#
Public Functions
-
inline WhenAllLatch(size_t count) noexcept#
-
WhenAllLatch(const WhenAllLatch&) = delete#
-
inline WhenAllLatch(WhenAllLatch &&rhs) noexcept#
-
WhenAllLatch &operator=(const WhenAllLatch&) = delete#
-
inline WhenAllLatch &operator=(WhenAllLatch &&rhs) noexcept#
-
inline bool IsReady() const noexcept#
-
inline bool TryAwait(std::coroutine_handle<> handle) noexcept#
-
inline void NotifyCompleted() noexcept#
-
inline WhenAllLatch(size_t count) noexcept#
-
template<typename TaskContainerType>
class WhenAllReadyAwaitable# Public Functions
-
inline explicit WhenAllReadyAwaitable(TaskContainerType &&tasks) noexcept#
-
WhenAllReadyAwaitable(const WhenAllReadyAwaitable&) = delete#
-
inline WhenAllReadyAwaitable(WhenAllReadyAwaitable &&rhs) noexcept#
-
WhenAllReadyAwaitable &operator=(const WhenAllReadyAwaitable&) = delete#
-
WhenAllReadyAwaitable &operator=(WhenAllReadyAwaitable&&) noexcept = delete#
-
inline auto operator co_await() & noexcept#
-
inline auto operator co_await() && noexcept#
-
inline explicit WhenAllReadyAwaitable(TaskContainerType &&tasks) noexcept#
-
template<typename ...TaskTypes>
class WhenAllReadyAwaitable<std::tuple<TaskTypes...>># Public Functions
-
inline explicit WhenAllReadyAwaitable(TaskTypes&&... tasks) noexcept(std::conjunction_v<std::is_nothrow_move_constructible<TaskTypes>...>)#
-
WhenAllReadyAwaitable(const WhenAllReadyAwaitable&) = delete#
-
inline WhenAllReadyAwaitable(WhenAllReadyAwaitable &&rhs) noexcept#
-
WhenAllReadyAwaitable &operator=(const WhenAllReadyAwaitable&) = delete#
-
WhenAllReadyAwaitable &operator=(WhenAllReadyAwaitable&&) noexcept = delete#
-
inline auto operator co_await() & noexcept#
-
inline auto operator co_await() && noexcept#
-
inline explicit WhenAllReadyAwaitable(TaskTypes&&... tasks) noexcept(std::conjunction_v<std::is_nothrow_move_constructible<TaskTypes>...>)#
-
template<>
class WhenAllReadyAwaitable<std::tuple<>># Public Functions
-
constexpr WhenAllReadyAwaitable() noexcept = default#
-
inline explicit constexpr WhenAllReadyAwaitable(std::tuple<>) noexcept#
-
inline constexpr bool await_ready() const noexcept#
-
inline void await_suspend(std::coroutine_handle<> handle) noexcept#
-
inline std::tuple await_resume() const noexcept#
-
constexpr WhenAllReadyAwaitable() noexcept = default#
-
template<typename T>
class WhenAllTask# Public Types
-
using promise_type = WhenAllTasksPromise<T>#
-
using coroutine_handle_type = typename promise_type::coroutine_handle_type#
Public Functions
-
inline WhenAllTask(coroutine_handle_type handle) noexcept#
-
WhenAllTask(const WhenAllTask&) = delete#
-
inline WhenAllTask(WhenAllTask &&rhs) noexcept#
-
WhenAllTask &operator=(const WhenAllTask&) = delete#
-
inline WhenAllTask &operator=(WhenAllTask &&rhs) noexcept#
-
inline ~WhenAllTask() noexcept#
-
inline decltype(auto) return_value() &#
-
inline decltype(auto) return_value() &&#
Friends
- friend class WhenAllReadyAwaitable
-
using promise_type = WhenAllTasksPromise<T>#
-
template<typename T>
class WhenAllTasksPromise# Public Types
-
using coroutine_handle_type = std::coroutine_handle<WhenAllTasksPromise<T>>#
Public Functions
-
WhenAllTasksPromise() = default#
-
inline auto get_return_object() noexcept#
-
inline std::suspend_always initial_suspend() const noexcept#
-
inline auto final_suspend() noexcept#
-
inline void unhandle_exception() noexcept#
-
inline void Start(WhenAllLatch &latch) noexcept#
-
inline void return_void() noexcept#
-
using coroutine_handle_type = std::coroutine_handle<WhenAllTasksPromise<T>>#
-
template<>
class WhenAllTasksPromise<void># Public Types
-
using coroutine_handle_type = std::coroutine_handle<WhenAllTasksPromise<void>>#
Public Functions
-
WhenAllTasksPromise() = default#
-
inline auto get_return_object() noexcept#
-
inline std::suspend_always initial_suspend() const noexcept#
-
inline auto final_suspend() noexcept#
-
inline void unhandled_exception() noexcept#
-
inline void return_void() noexcept#
-
inline void Result()#
-
inline void Start(WhenAllLatch &latch)#
-
using coroutine_handle_type = std::coroutine_handle<WhenAllTasksPromise<void>>#
-
template<Concepts::Awaitable A, typename T = typename Concepts::AwaitableTraits<A>::ResultType>
-
constexpr uint64_t pack(uint32_t workerHead, uint32_t stealerHead) noexcept#
-
namespace TypeUtils#
-
namespace Vector3Math#
-
enum class ELogLevel : uint32_t#