restructure into smaller files & add IWYU/clang-tidy
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
d33190b204
commit
0a583b6591
28 changed files with 845 additions and 556 deletions
123
include/ikarus/objects/object.h
Normal file
123
include/ikarus/objects/object.h
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
#pragma once
|
||||
|
||||
/// \file object.h
|
||||
/// \author Folling <mail@folling.io>
|
||||
|
||||
#include <ikarus/folders/blueprint_folder.h>
|
||||
#include <ikarus/folders/entity_folder.h>
|
||||
#include <ikarus/folders/property_folder.h>
|
||||
#include <ikarus/macros.h>
|
||||
#include <ikarus/objects/blueprint.h>
|
||||
#include <ikarus/objects/entity.h>
|
||||
#include <ikarus/objects/object_type.h>
|
||||
#include <ikarus/objects/property.h>
|
||||
|
||||
/// \defgroup object Objects
|
||||
/// \brief Objects are a compound type of all types of objects in the database.
|
||||
/// \details The following objects currently exist:
|
||||
/// - blueprints
|
||||
/// - properties
|
||||
/// - entities
|
||||
/// - blueprint folders
|
||||
/// - property folders
|
||||
/// - entity folders
|
||||
/// @{
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
struct IkarusFolder;
|
||||
|
||||
/// \private \brief The data of an object.
|
||||
union IkarusObjectData {
|
||||
/// \private \brief The blueprint data of the object.
|
||||
IkarusBlueprint blueprint;
|
||||
/// \private \brief The property data of the object.
|
||||
IkarusProperty property;
|
||||
/// \private \brief The entity data of the object.
|
||||
IkarusEntity entity;
|
||||
/// \private \brief The blueprint folder data of the object.
|
||||
IkarusBlueprintFolder blueprint_folder;
|
||||
/// \private \brief The property folder data of the object.
|
||||
IkarusPropertyFolder property_folder;
|
||||
/// \private \brief The entity folder data of the object.
|
||||
IkarusEntityFolder entity_folder;
|
||||
};
|
||||
|
||||
/// \brief A generic object. Wraps all types of objects, including folders.
|
||||
struct IkarusObject {
|
||||
/// \private \brief The type of the object.
|
||||
IkarusObjectType type;
|
||||
/// \private \brief The data of the object.
|
||||
IkarusObjectData data;
|
||||
};
|
||||
|
||||
/// \brief Constructs an object from a blueprint.
|
||||
/// \param blueprint The blueprint to construct the object from.
|
||||
/// \return The constructed object, representing the blueprint.
|
||||
IKA_API IkarusObject ikarus_object_from_blueprint(IkarusBlueprint blueprint);
|
||||
|
||||
/// \brief Constructs an object from a property.
|
||||
/// \param property The property to construct the object from.
|
||||
/// \return The constructed object, representing the property.
|
||||
IKA_API IkarusObject ikarus_object_from_property(IkarusProperty property);
|
||||
|
||||
/// \brief Constructs an object from an entity.
|
||||
/// \param entity The entity to construct the object from.
|
||||
/// \return The constructed object, representing the entity.
|
||||
IKA_API IkarusObject ikarus_object_from_entity(IkarusEntity entity);
|
||||
|
||||
/// \brief Constructs an object from a blueprint folder.
|
||||
/// \param blueprint The folder to construct the object from.
|
||||
/// \return The constructed object, representing the folder.
|
||||
IKA_API IkarusObject ikarus_object_from_blueprint_folder(IkarusBlueprintFolder folder);
|
||||
|
||||
/// \brief Constructs an object from a property folder.
|
||||
/// \param property The folder to construct the object from.
|
||||
/// \return The constructed object, representing the folder.
|
||||
IKA_API IkarusObject ikarus_object_from_property_folder(IkarusPropertyFolder folder);
|
||||
|
||||
/// \brief Constructs an object from a entity folder.
|
||||
/// \param entity The folder to construct the object from.
|
||||
/// \return The constructed object, representing the folder.
|
||||
IKA_API IkarusObject ikarus_object_from_entity_folder(IkarusEntityFolder folder);
|
||||
|
||||
/// \brief Constructs an object from a folder.
|
||||
/// \param folder The folder to construct the object from.
|
||||
/// \return The constructed object, representing the folder.
|
||||
IKA_API IkarusObject ikarus_object_from_folder(IkarusFolder folder);
|
||||
|
||||
/// \brief Compares two objects for equality.
|
||||
/// \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 Whether the objects are equal.
|
||||
IKA_API bool ikarus_object_is_equal(IkarusObject left, IkarusObject right);
|
||||
|
||||
/// \brief Fetches the type of an object.
|
||||
/// \param object The object to fetch the type of.
|
||||
/// \return The type of the object.
|
||||
IKA_API IkarusObjectType ikarus_object_get_type(IkarusObject object);
|
||||
|
||||
/// \brief Visits an object. Calling the appropriate function for the object's type.
|
||||
/// \param object The object to visit.
|
||||
/// \param blueprint The function to call if the object is a blueprint.
|
||||
/// \param property The function to call if the object is a property.
|
||||
/// \param entity The function to call if the object is an entity.
|
||||
/// \param blueprint_folder The function to call if the object is a blueprint folder.
|
||||
/// \param property_folder The function to call if the object is a property folder.
|
||||
/// \param entity_folder The function to call if the object is an entity folder.
|
||||
/// \param data The data to pass to the functions.
|
||||
IKA_API void ikarus_object_visit(
|
||||
IkarusObject object,
|
||||
void (*visit_blueprint)(IkarusBlueprint, void *),
|
||||
void (*visit_property)(IkarusProperty, void *),
|
||||
void (*visit_entity)(IkarusEntity, void *),
|
||||
void (*visit_blueprint_folder)(IkarusBlueprintFolder, void *),
|
||||
void (*visit_property_folder)(IkarusPropertyFolder, void *),
|
||||
void (*visit_entity_folder)(IkarusEntityFolder, void *),
|
||||
void * data
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
// @}
|
||||
Loading…
Add table
Add a link
Reference in a new issue