restructure into smaller files & add IWYU/clang-tidy

Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
folling 2023-08-29 14:12:08 +02:00 committed by Folling
parent 660736133a
commit 13eee8b168
Signed by: folling
SSH key fingerprint: SHA256:S9qEx5WCFFLK49tE/LKnKuJYM5sw+++Dn6qJbbyxnCY
28 changed files with 845 additions and 556 deletions

View file

@ -0,0 +1,22 @@
#pragma once
/// \file blueprint_folder.h
/// \author Folling <mail@folling.io>
#include <ikarus/id.h>
#include <ikarus/macros.h>
/// \addtogroup folder Folders
/// @{
IKARUS_BEGIN_HEADER
/// \brief A blueprint folder, storing blueprints and other blueprint folders.
struct IkarusBlueprintFolder {
/// \private \brief The id of the blueprint folder.
IkarusId id;
};
IKARUS_END_HEADER
// @}

View file

@ -0,0 +1,22 @@
#pragma once
/// \file entity_folder.h
/// \author Folling <mail@folling.io>
#include <ikarus/id.h>
#include <ikarus/macros.h>
/// \addtogroup folder Folders
/// @{
IKARUS_BEGIN_HEADER
/// \brief A entity folder, storing entities and other entity folders.
struct IkarusEntityFolder {
/// \private \brief The id of the entity folder.
IkarusId id;
};
IKARUS_END_HEADER
// @}

View file

@ -0,0 +1,76 @@
#pragma once
/// \file folder.h
/// \author Folling <mail@folling.io>
#include <ikarus/folders/blueprint_folder.h>
#include <ikarus/folders/entity_folder.h>
#include <ikarus/folders/folder_type.h>
#include <ikarus/folders/property_folder.h>
#include <ikarus/macros.h>
IKARUS_BEGIN_HEADER
/// \defgroup folder Folders
/// \brief Folders are used to group objects together.
/// @{
/// \private \brief The data of a folder.
union IkarusFolderData {
/// \private \brief The blueprint folder data of the folder.
IkarusBlueprintFolder blueprint_folder;
/// \private \brief The property folder data of the folder.
IkarusPropertyFolder property_folder;
/// \private \brief The entity folder data of the folder.
IkarusEntityFolder entity_folder;
};
/// \brief A generic folder. Similar to how Objects wrap all types of objects, Folders wrap all types of folders.
struct IkarusFolder {
/// \private \brief The data of the folder.
IkarusFolderData data;
/// \private \brief The type of the folder.
IkarusFolderType type;
};
/// \brief Constructs a folder from a blueprint folder.
/// \param blueprint_folder The blueprint folder to construct the folder from.
/// \return The constructed folder.
IKA_API IkarusFolder ikarus_folder_from_blueprint_folder(IkarusBlueprintFolder blueprint_folder);
/// \brief Constructs a folder from a property folder.
/// \param property_folder The property folder to construct the folder from.
/// \return The constructed folder.
IKA_API IkarusFolder ikarus_folder_from_property_folder(IkarusPropertyFolder property_folder);
/// \brief Constructs a folder from an entity folder.
/// \param entity_folder The entity folder to construct the folder from.
/// \return The constructed folder.
IKA_API IkarusFolder ikarus_folder_from_entity_folder(IkarusEntityFolder entity_folder);
/// \brief Fetches the folder type of a folder.
/// \param folder The folder to fetch the type of.
/// \return The type of the folder.
IKA_API IkarusFolderType ikarus_folder_get_type(IkarusFolder folder);
/// \brief Checks if two folders are equal.
/// \details Since ids store the type of the object, this boils down to a simple comparison of the ids.
/// \param left The left side of the comparison.
/// \param right The right side of the comparison.
/// \return True if the folders are equal, false otherwise
IKA_API bool ikarus_folder_is_equal(IkarusFolder left, IkarusFolder right);
/// \brief Visits a folder. Calling the appropriate function for the folder's type.
/// \param folder The folder to visit.
/// \param blueprint The function to call if the folder is a blueprint folder.
/// \param property The function to call if the folder is a property folder.
/// \param entity The function to call if the folder is an entity folder.
/// \param data The data to pass to the functions.
IKA_API void ikarus_folder_visit(
IkarusFolder folder,
void (*blueprint)(IkarusBlueprintFolder, void *),
void (*property)(IkarusPropertyFolder, void *),
void (*entity)(IkarusEntityFolder, void *),
void * data
);
IKARUS_END_HEADER

View file

@ -0,0 +1,26 @@
#pragma once
// IMPLEMENTATION_DETAIL_FOLDER_TYPES
/// \file folder_type.h
/// \author Folling <mail@folling.io>
#include <ikarus/macros.h>
/// \addtogroup folder folders
/// @{
/// \brief The type of an folder.
/// \remark Folders have the 8th bit set.
enum IkarusFolderType {
/// \brief Not a folder or no folder.
IkarusFolderType_None = 0,
/// \brief An IkarusBlueprintFolder
IkarusFolderType_BlueprintFolder = 0b1000'0001,
/// \brief An IkarusPropertyFolder
IkarusFolderType_PropertyFolder = 0b1000'0010,
/// \brief An IkarusEntityFolder
IkarusFolderType_EntityFolder = 0b1000'0011,
};
/// @}

View file

@ -0,0 +1,23 @@
#pragma once
#include <ikarus/id.h>
#include <ikarus/macros.h>
/// \file property_folder.h
/// \author Folling <mail@folling.io>
/// \addtogroup folder Folders
/// @{
IKARUS_BEGIN_HEADER
/// \brief A property folder, storing properties and other property folders.
/// \remark Property folders are scoped to the blueprint or entity they are associated with.
struct IkarusPropertyFolder {
/// \private \brief The id of the property folder.
IkarusId id;
};
IKARUS_END_HEADER
// @}