intermediate commit

Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
Folling 2023-11-14 16:26:29 +01:00 committed by Folling
parent eb1f414fc4
commit 3608794bf0
No known key found for this signature in database
37 changed files with 131 additions and 1544 deletions

View file

@ -1,151 +0,0 @@
#pragma once
/// \file blueprint_folder.h
/// \author Folling <folling@ikarus.world>
#include <ikarus/macros.h>
/// \addtogroup blueprints Blueprints
/// @{
IKARUS_BEGIN_HEADER
/// \brief A blueprint folder, storing blueprints and other blueprint folders.
struct IkarusBlueprintFolder;
/// \brief Creates a blueprint folder.
/// \param project The project the blueprint folder is part of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param parent The parent folder of the blueprint folder.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param position The position of the blueprint folder in the parent folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \param name The name of the blueprint folder.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
/// \return The created blueprint folder or null if an error occurs.
/// \remark Must be freed using #ikarus_free.
IKA_API IkarusBlueprintFolder * ikarus_blueprint_folder_create(
struct IkarusProject * project, IkarusBlueprintFolder * parent, size_t position, char const * name
);
/// \brief Copies a blueprint folder.
/// \details Creates a copy of the blueprint folder without its children.
/// \param blueprint_folder The blueprint folder to copy.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param parent The parent folder of the blueprint folder.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param position The position of the blueprint folder in the parent folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \param name The name of the blueprint folder.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
/// \return The created blueprint folder or null if an error occurs.
/// \remark Must be freed using #ikarus_free.
IKA_API IkarusBlueprintFolder * ikarus_blueprint_folder_copy(
IkarusBlueprintFolder * blueprint_folder, IkarusBlueprintFolder * parent, size_t position, char const * name
);
/// \brief Deletes a blueprint folder and all its children
/// \param blueprint_folder The blueprint folder to delete.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param keep_children If true, the children of the blueprint folder will be moved to the parent folder.
IKA_API void ikarus_blueprint_folder_delete(IkarusBlueprintFolder * blueprint_folder, bool keep_children);
/// \brief Gets the project of a blueprint folder.
/// \param blueprint_folder The blueprint folder to get the project of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The project of the blueprint folder or null if an error occurs.
IKA_API struct IkarusProject * ikarus_blueprint_folder_get_project(IkarusBlueprintFolder const * blueprint_folder);
/// \brief Gets the parent folder of a blueprint folder.
/// \param blueprint_folder The blueprint folder to get the parent folder of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The parent folder of the blueprint folder or null if an error occurs.
IKA_API struct IkarusBlueprintFolder * ikarus_blueprint_folder_get_parent(IkarusBlueprintFolder const * blueprint_folder);
/// \brief Gets the position of a blueprint folder within its parent folder.
/// \param blueprint_folder The blueprint folder to get the position of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The position of the blueprint folder or undefined if an error occurs.
IKA_API size_t ikarus_blueprint_folder_get_position(IkarusBlueprintFolder const * blueprint_folder);
/// \brief Gets the name of a blueprint folder.
/// \param blueprint_folder The blueprint folder to get the name of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The name of the blueprint folder or null if an error occurs.
/// \remark The returned pointer is valid until the blueprint folder is freed but may be invalidated by other operations.
IKA_API char const * ikarus_blueprint_folder_get_name(IkarusBlueprintFolder const * blueprint_folder);
/// \brief Gets the number of children of a blueprint folder.
/// \param blueprint_folder The blueprint folder to get the number of children of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The number of children or undefined if an error occurs.
IKA_API size_t ikarus_blueprint_folder_get_child_count(IkarusBlueprintFolder const * blueprint_folder);
/// \brief Gets the children of a blueprint folder.
/// \param blueprint_folder The blueprint folder to get the children of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param children_out The buffer to write the children to.
/// \pre \li Must not be null.
/// \param children_out_size The size of the buffer.
IKA_API void ikarus_blueprint_folder_get_children(
IkarusBlueprintFolder const * blueprint_folder, struct IkarusBlueprintTreeItem ** children_out, size_t children_out_size
);
/// \brief Sets the parent folder of an blueprint folder.
/// \param blueprint_folder The blueprint folder to set the parent folder of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_parent The new parent folder of the blueprint folder.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_position The new position of the blueprint folder in the parent folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \remark This adjusts the positions of old and new siblings.
IKA_API void ikarus_blueprint_folder_set_parent(
IkarusBlueprintFolder * blueprint_folder, struct IkarusEntityFolder * new_parent, size_t new_position
);
/// \brief Sets the position of an blueprint folder within its parent folder.
/// \param blueprint_folder The blueprint folder to set the position of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_position The new position of the blueprint folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \remark This adjusts the positions of siblings.
IKA_API void ikarus_blueprint_folder_set_position(IkarusBlueprintFolder * blueprint_folder, size_t new_position);
/// \brief Sets the name of an blueprint folder.
/// \param blueprint_folder The blueprint folder to set the name of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_name The new name of the blueprint folder.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
IKA_API void ikarus_blueprint_folder_set_name(IkarusBlueprintFolder * blueprint_folder, char const * new_name);
/// \brief Converts a blueprint folder to a generic folder.
/// \param blueprint_folder The blueprint folder to convert.
/// \return The constructed folder, representing the blueprint folder.
IKA_API struct IkarusFolder * ikarus_blueprint_folder_to_folder(IkarusBlueprintFolder const * blueprint_folder);
/// \brief Converts a blueprint folder to an object.
/// \param blueprint_folder The blueprint folder to convert.
/// \return The constructed object, representing the blueprint folder.
IKA_API struct IkarusObject * ikarus_blueprint_folder_to_object(IkarusBlueprintFolder const * blueprint_folder);
IKARUS_END_HEADER
// @}

View file

@ -1,31 +0,0 @@
#pragma once
/// \file blueprint_tree_item.h
/// \author Folling <folling@ikarus.world>
#include <ikarus/macros.h>
/// \addtogroup blueprints Blueprints
/// @{
IKARUS_BEGIN_HEADER
struct IkarusBlueprintTreeItem;
/// \brief Visits a blueprint tree item, calling the appropriate visitor function.
/// \param item The item to visit.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param blueprint_visitor The visitor function called if the item is a blueprint. Skipped if null.
/// \param blueprint_folder_visitor The visitor function called if the item is a blueprint folder. Skipped if null.
/// \param data The data passed to the visitor functions.
IKA_API void ikarus_blueprint_tree_item_visit(
struct IkarusBlueprintTreeItem * item,
void (*blueprint_visitor)(struct IkarusBlueprint * blueprint, void * data),
void (*blueprint_folder_visitor)(struct IkarusBlueprintFolder * folder, void * data),
void * data
);
IKARUS_END_HEADER
/// @}

View file

@ -1,151 +0,0 @@
#pragma once
/// \file entity_folder.h
/// \author Folling <folling@ikarus.world>
#include <ikarus/macros.h>
/// \addtogroup entities Entities
/// @{
IKARUS_BEGIN_HEADER
/// \brief A entity folder, storing entities and other entity folders.
struct IkarusEntityFolder;
/// \brief Creates a entity folder.
/// \param project The project the entity folder is part of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param parent The parent folder of the entity folder.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param position The position of the entity folder in the parent folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \param name The name of the entity folder.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
/// \return The created entity folder or null if an error occurs.
/// \remark Must be freed using #ikarus_free.
IKA_API IkarusEntityFolder * ikarus_entity_folder_create(
struct IkarusProject * project, IkarusEntityFolder * parent, size_t position, char const * name
);
/// \brief Copies a entity folder.
/// \details Creates a copy of the entity folder without its children.
/// \param entity_folder The entity folder to copy.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param parent The parent folder of the entity folder.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param position The position of the entity folder in the parent folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \param name The name of the entity folder.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
/// \return The created entity folder or null if an error occurs.
/// \remark Must be freed using #ikarus_free.
IKA_API IkarusEntityFolder * ikarus_entity_folder_copy(
IkarusEntityFolder * entity_folder, IkarusEntityFolder * parent, size_t position, char const * name
);
/// \brief Deletes a entity folder and all its children
/// \param entity_folder The entity folder to delete.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param keep_children If true, the children of the entity folder will be moved to the parent folder.
IKA_API void ikarus_entity_folder_delete(IkarusEntityFolder * entity_folder, bool keep_children);
/// \brief Gets the project of a entity folder.
/// \param entity_folder The entity folder to get the project of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The project of the entity folder or null if an error occurs.
IKA_API struct IkarusProject * ikarus_entity_folder_get_project(IkarusEntityFolder const * entity_folder);
/// \brief Gets the parent folder of a entity folder.
/// \param entity_folder The entity folder to get the parent folder of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The parent folder of the entity folder or null if an error occurs.
IKA_API struct IkarusEntityFolder * ikarus_entity_folder_get_parent(IkarusEntityFolder const * entity_folder);
/// \brief Gets the position of a entity folder within its parent folder.
/// \param entity_folder The entity folder to get the position of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The position of the entity folder or undefined if an error occurs.
IKA_API size_t ikarus_entity_folder_get_position(IkarusEntityFolder const * entity_folder);
/// \brief Gets the name of a entity folder.
/// \param entity_folder The entity folder to get the name of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The name of the entity folder or null if an error occurs.
/// \remark The returned pointer is valid until the entity folder is freed but may be invalidated by other operations.
IKA_API char const * ikarus_entity_folder_get_name(IkarusEntityFolder const * entity_folder);
/// \brief Gets the number of children of a entity folder.
/// \param entity_folder The entity folder to get the number of children of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The number of children or undefined if an error occurs.
IKA_API size_t ikarus_entity_folder_get_child_count(IkarusEntityFolder const * entity_folder);
/// \brief Gets the children of a entity folder.
/// \param entity_folder The entity folder to get the children of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param children_out The buffer to write the children to.
/// \pre \li Must not be null.
/// \param children_out_size The size of the buffer.
IKA_API void ikarus_entity_folder_get_children(
IkarusEntityFolder const * entity_folder, struct IkarusEntityTreeItem ** children_out, size_t children_out_size
);
/// \brief Sets the parent folder of an entity folder.
/// \param entity_folder The entity folder to set the parent folder of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_parent The new parent folder of the entity folder.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_position The new position of the entity folder in the parent folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \remark This adjusts the positions of old and new siblings.
IKA_API void ikarus_entity_folder_set_parent(
IkarusEntityFolder * entity_folder, struct IkarusEntityFolder * new_parent, size_t new_position
);
/// \brief Sets the position of an entity folder within its parent folder.
/// \param entity_folder The entity folder to set the position of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_position The new position of the entity folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \remark This adjusts the positions of siblings.
IKA_API void ikarus_entity_folder_set_position(IkarusEntityFolder * entity_folder, size_t new_position);
/// \brief Sets the name of an entity folder.
/// \param entity_folder The entity folder to set the name of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_name The new name of the entity folder.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
IKA_API void ikarus_entity_folder_set_name(IkarusEntityFolder * entity_folder, char const * new_name);
/// \brief Converts a entity folder to a generic folder.
/// \param entity_folder The entity folder to convert.
/// \return The constructed folder, representing the entity folder.
IKA_API struct IkarusFolder * ikarus_entity_folder_to_folder(IkarusEntityFolder const * entity_folder);
/// \brief Converts a entity folder to an object.
/// \param entity_folder The entity folder to convert.
/// \return The constructed object, representing the entity folder.
IKA_API struct IkarusObject * ikarus_entity_folder_to_object(IkarusEntityFolder const * entity_folder);
IKARUS_END_HEADER
// @}

View file

@ -1,31 +0,0 @@
#pragma once
/// \file entity_tree_item.h
/// \author Folling <folling@ikarus.world>
#include <ikarus/macros.h>
/// \addtogroup entities Entities
/// @{
IKARUS_BEGIN_HEADER
struct IkarusEntityTreeItem;
/// \brief Visits a entity tree item, calling the appropriate visitor function.
/// \param item The item to visit.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param entity_visitor The visitor function called if the item is a entity. Skipped if null.
/// \param entity_folder_visitor The visitor function called if the item is a entity folder. Skipped if null.
/// \param data The data passed to the visitor functions.
IKA_API void ikarus_entity_tree_item_visit(
struct IkarusEntityTreeItem * item,
void (*entity_visitor)(struct IkarusEntity * entity, void * data),
void (*entity_folder_visitor)(struct IkarusEntityFolder * folder, void * data),
void * data
);
IKARUS_END_HEADER
/// @}

View file

@ -1,38 +0,0 @@
#pragma once
/// \file folder.h
/// \author Folling <folling@ikarus.world>
#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.
/// @{
/// \brief A generic folder. Similar to how Objects wrap all types of objects, Folders wrap all types of folders.
struct IkarusFolder;
/// \brief Special value for inserting objects at the end of a folder.
enum FolderPosition { FolderPosition_EndOfFolder = -1 };
/// \brief Visits a folder. Calling the appropriate function for the folder's type.
/// \param folder The folder to visit.
/// \param blueprint_visitor The function to call if the folder is a blueprint folder.
/// \param property_visitor The function to call if the folder is a property folder.
/// \param entity_visitor The function to call if the folder is an entity folder.
/// \param data The data passed to the visitor functions.
IKA_API void ikarus_folder_visit(
IkarusFolder * folder,
void (*blueprint_visitor)(IkarusBlueprintFolder *, void *),
void (*property_visitor)(IkarusPropertyFolder *, void *),
void (*entity_visitor)(IkarusEntityFolder *, void *),
void * data
);
IKARUS_END_HEADER

View file

@ -1,26 +0,0 @@
#pragma once
// IMPLEMENTATION_DETAIL_FOLDER_TYPES
/// \file folder_type.h
/// \author Folling <folling@ikarus.world>
#include <ikarus/macros.h>
/// \addtogroup folder folders
/// @{
/// \brief The type of an folder.
/// \remark The values are identical to their counterparts in #IkarusObjectType.
enum IkarusFolderType {
/// \brief Not a folder or no folder.
IkarusFolderType_None = 0,
/// \brief An IkarusBlueprintFolder
IkarusFolderType_BlueprintFolder = 0b0100'0001,
/// \brief An IkarusPropertyFolder
IkarusFolderType_PropertyFolder = 0b0100'0010,
/// \brief An IkarusEntityFolder
IkarusFolderType_EntityFolder = 0b0100'0011,
};
/// @}

View file

@ -1,159 +0,0 @@
#pragma once
/// \file property_folder.h
/// \author Folling <folling@ikarus.world>
#include <ikarus/macros.h>
/// \addtogroup properties Properties
/// @{
IKARUS_BEGIN_HEADER
/// \brief A property folder, storing properties and other property folders.
struct IkarusPropertyFolder;
/// \brief Creates a property folder.
/// \param project The project the property folder is part of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param parent The parent folder of the property folder.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param position The position of the property folder in the parent folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \param name The name of the property folder.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
/// \return The created property folder or null if an error occurs.
/// \remark Must be freed using #ikarus_free.
IKA_API IkarusPropertyFolder * ikarus_property_folder_create(
struct IkarusProject * project, IkarusPropertyFolder * parent, size_t position, char const * name
);
/// \brief Copies a property folder.
/// \details Creates a copy of the property folder without its children.
/// \param property_folder The property folder to copy.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param parent The parent folder of the property folder.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param position The position of the property folder in the parent folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \param name The name of the property folder.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
/// \return The created property folder or null if an error occurs.
/// \remark Must be freed using #ikarus_free.
IKA_API IkarusPropertyFolder * ikarus_property_folder_copy(
IkarusPropertyFolder * property_folder, IkarusPropertyFolder * parent, size_t position, char const * name
);
/// \brief Deletes a property folder and all its children
/// \param property_folder The property folder to delete.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param keep_children If true, the children of the property folder will be moved to the parent folder.
IKA_API void ikarus_property_folder_delete(IkarusPropertyFolder * property_folder, bool keep_children);
/// \brief Gets the project of a property folder.
/// \param property_folder The property folder to get the project of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The project of the property folder or null if an error occurs.
IKA_API struct IkarusProject * ikarus_property_folder_get_project(IkarusPropertyFolder const * property_folder);
/// \brief Gets the property source of a property folder.
/// \param property_folder The property folder to get the property source of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The property source of the property folder or null if an error occurs.
/// \remark Must be freed using #ikarus_free.
IKA_API struct IkarusPropertySource * ikarus_property_folder_get_source(IkarusPropertyFolder const * property_folder);
/// \brief Gets the parent folder of a property folder.
/// \param property_folder The property folder to get the parent folder of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The parent folder of the property folder or null if an error occurs.
IKA_API struct IkarusPropertyFolder * ikarus_property_folder_get_parent(IkarusPropertyFolder const * property_folder);
/// \brief Gets the position of a property folder within its parent folder.
/// \param property_folder The property folder to get the position of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The position of the property folder or undefined if an error occurs.
IKA_API size_t ikarus_property_folder_get_position(IkarusPropertyFolder const * property_folder);
/// \brief Gets the name of a property folder.
/// \param property_folder The property folder to get the name of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The name of the property folder or null if an error occurs.
/// \remark The returned pointer is valid until the property folder is freed but may be invalidated by other operations.
IKA_API char const * ikarus_property_folder_get_name(IkarusPropertyFolder const * property_folder);
/// \brief Gets the number of children of a property folder.
/// \param property_folder The property folder to get the number of children of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The number of children or undefined if an error occurs.
IKA_API size_t ikarus_property_folder_get_child_count(IkarusPropertyFolder const * property_folder);
/// \brief Gets the children of a property folder.
/// \param property_folder The property folder to get the children of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param children_out The buffer to write the children to.
/// \pre \li Must not be null.
/// \param children_out_size The size of the buffer.
IKA_API void ikarus_property_folder_get_children(
IkarusPropertyFolder const * property_folder, struct IkarusPropertyTreeItem ** children_out, size_t children_out_size
);
/// \brief Sets the parent folder of an property folder.
/// \param property_folder The property folder to set the parent folder of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_parent The new parent folder of the property folder.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_position The new position of the property folder in the parent folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \remark This adjusts the positions of old and new siblings.
IKA_API void ikarus_property_folder_set_parent(
IkarusPropertyFolder * property_folder, struct IkarusPropertyFolder * new_parent, size_t new_position
);
/// \brief Sets the position of an property folder within its parent folder.
/// \param property_folder The property folder to set the position of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_position The new position of the property folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \remark This adjusts the positions of siblings.
IKA_API void ikarus_property_folder_set_position(IkarusPropertyFolder * property_folder, size_t new_position);
/// \brief Sets the name of an property folder.
/// \param property_folder The property folder to set the name of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_name The new name of the property folder.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
IKA_API void ikarus_property_folder_set_name(IkarusPropertyFolder * property_folder, char const * new_name);
/// \brief Converts a property folder to a generic folder.
/// \param property_folder The property folder to convert.
/// \return The constructed folder, representing the property folder.
IKA_API struct IkarusFolder * ikarus_property_folder_to_folder(IkarusPropertyFolder const * property_folder);
/// \brief Converts a property folder to an object.
/// \param property_folder The property folder to convert.
/// \return The constructed object, representing the property folder.
IKA_API struct IkarusObject * ikarus_property_folder_to_object(IkarusPropertyFolder const * property_folder);
IKARUS_END_HEADER
// @}

View file

@ -1,31 +0,0 @@
#pragma once
/// \file property_tree_item.h
/// \author Folling <folling@ikarus.world>
#include <ikarus/macros.h>
/// \addtogroup properties Properties
/// @{
IKARUS_BEGIN_HEADER
struct IkarusPropertyTreeItem;
/// \brief Visits a property tree item, calling the appropriate visitor function.
/// \param item The item to visit.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param property_visitor The visitor function called if the item is a property. Skipped if null.
/// \param property_folder_visitor The visitor function called if the item is a property folder. Skipped if null.
/// \param data The data passed to the visitor functions.
IKA_API void ikarus_property_tree_item_visit(
struct IkarusPropertyTreeItem * item,
void (*property_visitor)(struct IkarusProperty * property, void * data),
void (*property_folder_visitor)(struct IkarusPropertyFolder * folder, void * data),
void * data
);
IKARUS_END_HEADER
/// @}

View file

@ -21,37 +21,25 @@ struct IkarusBlueprint;
/// \param project The project the blueprint is part of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param parent The parent folder of the blueprint.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param position The position of the blueprint in the parent folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \param name The name of the blueprint.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
/// \return The created blueprint or null if an error occurs.
/// \remark Must be freed using #ikarus_free.
IKA_API IkarusBlueprint * ikarus_blueprint_create(
struct IkarusProject * project, struct IkarusBlueprintFolder * parent, size_t position, char const * name
);
IKA_API IkarusBlueprint * ikarus_blueprint_create(struct IkarusProject * project, char const * name);
/// \brief Creates a blueprint from an entity.
/// \details The created blueprint will have the same properties as the entity.
/// \param entity The entity to create the blueprint from.
/// \pre \li Must not be null.
/// \param link_entity If true, the entity will be linked to the blueprint. If not they will remain separate.
/// \param parent The parent folder of the blueprint.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param position The position of the blueprint in the parent folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \param name The name of the blueprint. Must not be empty.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
/// \return The created blueprint or null if an error occurs.
/// \remark Must be freed using #ikarus_free.
IKA_API IkarusBlueprint * ikarus_blueprint_create_from_entity(
struct IkarusEntity * entity, bool link_entity, struct IkarusBlueprintFolder * parent, size_t position, char const * name
struct IkarusEntity * entity, bool link_entity, char const * name
);
/// \brief Copies a blueprint.
@ -59,20 +47,13 @@ IKA_API IkarusBlueprint * ikarus_blueprint_create_from_entity(
/// \param blueprint The blueprint to copy.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param parent The parent folder of the blueprint.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param position The position of the blueprint in the parent folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \param name The name of the blueprint.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
/// \return The created blueprint or null if an error occurs.
/// \remark Linked entities won't be copied.
/// \remark Must be freed using #ikarus_free.
IKA_API IkarusBlueprint * ikarus_blueprint_copy(
IkarusBlueprint const * blueprint, struct IkarusBlueprintFolder * parent, size_t position, char const * name
);
IKA_API IkarusBlueprint * ikarus_blueprint_copy(IkarusBlueprint const * blueprint, char const * name);
/// \brief Deletes a blueprint.
/// \param blueprint The blueprint to delete.
@ -88,20 +69,6 @@ IKA_API void ikarus_blueprint_delete(IkarusBlueprint * blueprint);
/// \return The project of the blueprint or null if an error occurs.
IKA_API struct IkarusProject * ikarus_blueprint_get_project(IkarusBlueprint const * blueprint);
/// \brief Gets the parent folder of a blueprint.
/// \param blueprint The blueprint to get the parent folder of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The parent folder of the blueprint or null if an error occurs.
IKA_API struct IkarusBlueprintFolder * ikarus_blueprint_get_parent(IkarusBlueprint const * blueprint);
/// \brief Gets the position of a blueprint within its parent folder.
/// \param blueprint The blueprint to get the position of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The position of the blueprint or undefined if an error occurs.
IKA_API size_t ikarus_blueprint_get_position(IkarusBlueprint const * blueprint);
/// \brief Gets the name of a blueprint.
/// \param blueprint The blueprint to get the name of.
/// \pre \li Must not be null.
@ -110,14 +77,6 @@ IKA_API size_t ikarus_blueprint_get_position(IkarusBlueprint const * blueprint);
/// \remark The returned pointer is valid until the blueprint is freed but may be invalidated by other operations.
IKA_API char const * ikarus_blueprint_get_name(IkarusBlueprint const * blueprint);
/// \brief Gets the property root folder of a blueprint.
/// \param blueprint The blueprint to get the root folder of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The root folder of all properties of the blueprint or null if an error occurs.
/// \remark Must be freed using #ikarus_free.
IKA_API struct IkarusPropertyFolder * ikarus_blueprint_get_property_root_folder(IkarusBlueprint const * blueprint);
/// \brief Gets the number of properties of a blueprint.
/// \param blueprint The blueprint to get the number of properties of.
/// \pre \li Must not be null.
@ -154,29 +113,6 @@ IKA_API void ikarus_blueprint_get_linked_entities(
IkarusBlueprint const * blueprint, struct IkarusEntity ** entities_out, size_t entities_out_size
);
/// \brief Sets the parent folder of a blueprint.
/// \param blueprint The blueprint to set the parent folder of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_parent The new parent folder of the blueprint.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_position The new position of the blueprint in the parent folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \remark This adjusts the positions of old and new siblings.
IKA_API void ikarus_blueprint_set_parent(
IkarusBlueprint * blueprint, struct IkarusBlueprintFolder * new_parent, size_t new_position
);
/// \brief Sets the position of a blueprint within its parent folder.
/// \param blueprint The blueprint to set the position of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_position The new position of the blueprint. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \remark This adjusts the positions of siblings.
IKA_API void ikarus_blueprint_set_position(IkarusBlueprint * blueprint, size_t new_position);
/// \brief Sets the name of a blueprint.
/// \param blueprint The blueprint to set the name of.
/// \pre \li Must not be null.
@ -186,14 +122,6 @@ IKA_API void ikarus_blueprint_set_position(IkarusBlueprint * blueprint, size_t n
/// \pre \li Must not be empty.
IKA_API void ikarus_blueprint_set_name(IkarusBlueprint * blueprint, char const * new_name);
/// \brief Converts a blueprint to an object.
/// \param blueprint The blueprint to convert.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The constructed object, representing the blueprint.
/// \remark Must be freed using #ikarus_free.
IKA_API struct IkarusObject * ikarus_blueprint_to_object(IkarusBlueprint const * blueprint);
/// \brief Compares two blueprints.
/// \param left The left blueprint to compare.
/// \pre \li Must not be null.

View file

@ -1,6 +1,7 @@
#pragma once
#include <ikarus/macros.h>
#include <ikarus/stdtypes.h>
/// \file entity.h
/// \author Folling <folling@ikarus.world>
@ -230,12 +231,6 @@ IKA_API void ikarus_entity_set_value(
IkarusEntity * entity, struct IkarusProperty const * property, struct IkarusValue * value, bool validate_settings
);
/// \brief Converts an entity to an object.
/// \param entity The entity to convert.
/// \return The constructed object, representing the entity.
/// \remark Must be freed using #ikarus_free.
IKA_API struct IkarusObject * ikarus_entity_to_object(IkarusEntity const * entity);
/// \brief Compares two entities.
/// \param left The left entity to compare.
/// \pre \li Must not be null.

View file

@ -7,6 +7,7 @@
#include <ikarus/macros.h>
#include <ikarus/objects/property_type.h>
#include <ikarus/stdtypes.h>
/// \defgroup properties Properties
/// \brief Properties define the structure and types of data.
@ -58,11 +59,6 @@ struct IkarusProperty;
/// \param property_source The property source the property is part of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param parent_folder The parent folder of the property.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param position The position of the property in the parent folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \param name The name of the property.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
@ -73,8 +69,6 @@ struct IkarusProperty;
IKA_API struct IkarusProperty * ikarus_property_create(
struct IkarusProject * project,
struct IkarusPropertySource * property_source,
struct IkarusPropertyFolder * parent_folder,
size_t position,
char const * name,
struct IkarusPropertyTypeInfo * property_info
);
@ -87,22 +81,13 @@ IKA_API struct IkarusProperty * ikarus_property_create(
/// \param source The source to copy the property to.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param parent_folder The parent folder of the property.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param position The position of the property in the parent folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \param name The name of the property.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
/// \return The created property or null if an error occurs.
/// \remark Must be freed using #ikarus_free.
IKA_API struct IkarusProperty * ikarus_property_copy(
struct IkarusProperty * property,
struct IkarusPropertySource * source,
struct IkarusPropertyFolder * parent_folder,
size_t position,
char const * name
struct IkarusProperty * property, struct IkarusPropertySource * source, char const * name
);
/// \brief Deletes a property.
@ -119,20 +104,6 @@ IKA_API void ikarus_property_delete(struct IkarusProperty * property);
/// \return The project of the property or null if an error occurs.
IKA_API struct IkarusProject * ikarus_property_get_project(IkarusProperty const * property);
/// \brief Gets the parent folder of a property.
/// \param property The property to get the parent folder of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The parent folder of the property or null if an error occurs.
IKA_API struct IkarusPropertyFolder * ikarus_property_get_parent(IkarusProperty const * property);
/// \brief Gets the position of a property within its parent folder.
/// \param property The property to get the position of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \return The position of the property or undefined if an error occurs.
IKA_API size_t ikarus_property_get_position(IkarusProperty const * property);
/// \brief Gets the name of a property.
/// \param property The property to get the name of.
/// \pre \li Must not be null.
@ -165,29 +136,6 @@ IKA_API struct IkarusPropertySource * ikarus_property_get_source(IkarusProperty
/// \remark Must be freed using #ikarus_free.
IKA_API struct IkarusValue * ikarus_property_get_default_value(IkarusProperty const * property);
/// \brief Sets the parent folder of a property.
/// \param property The property to set the parent folder of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_parent The new parent folder of the property.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_position The new position of the property in the parent folder. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \remark This adjusts the positions of old and new siblings.
IKA_API void ikarus_property_set_parent(
IkarusProperty * property, struct IkarusPropertyFolder * new_parent, size_t new_position
);
/// \brief Sets the position of a property within its parent folder.
/// \param property The property to set the position of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param new_position The new position of the property. \see #FolderPosition
/// \pre \li Must be within bounds for the parent folder.
/// \remark This adjusts the positions of siblings.
IKA_API void ikarus_property_set_position(IkarusProperty * property, size_t new_position);
/// \brief Sets the name of a property.
/// \param property The property to set the name of.
/// \pre \li Must not be null.
@ -208,11 +156,6 @@ IKA_API void ikarus_property_set_type_info(
IkarusProperty * property, struct IkarusPropertyTypeInfo new_type_info, bool attempt_conversion
);
/// \brief Converts a property to an object.
/// \param property The property to convert.
/// \return The constructed object, representing the property.
IKA_API struct IkarusObject * ikarus_property_to_object(IkarusProperty const * property);
/// \brief Compares two properties.
/// \param left The left property to compare.
/// \pre \li Must not be null.

View file

@ -1,30 +0,0 @@
#pragma once
/// \file blueprint_scope.h
/// \author Folling <folling@ikarus.world>
#include <ikarus/id.h>
#include <ikarus/macros.h>
/// \addtogroup object_scopes ObjectScopes
/// @{
IKARUS_BEGIN_HEADER
/// \brief The global scope of all blueprints.
struct IkarusBlueprintScope;
/// \brief Creates a blueprint scope.
/// \return The created blueprint scope.
/// \remark Must be freed with #ikarus_free.
IKA_API IkarusBlueprintScope * ikarus_blueprint_scope_create();
/// \brief Converts a blueprint scope to an object scope.
/// \param scope The scope to convert.
/// \return The converted scope.
/// \remark Must be freed with #ikarus_free.
IKA_API struct IkarusObjectScope * ikarus_blueprint_scope_to_object_scope(IkarusBlueprintScope const * scope);
IKARUS_END_HEADER
// @}

View file

@ -1,29 +0,0 @@
#pragma once
/// \file entity_scope.h
/// \author Folling <folling@ikarus.world>
#include <ikarus/macros.h>
/// \addtogroup object_scopes ObjectScopes
/// @{
IKARUS_BEGIN_HEADER
/// \brief The global scope of all entities.
struct IkarusEntityScope;
/// \brief Creates an entity scope.
/// \return The created entity scope.
/// \remark Must be freed with #ikarus_free.
IKA_API IkarusEntityScope * ikarus_entity_scope_create();
/// Converts an entity scope to an object scope.
/// \param scope The scope to convert.
/// \return The converted scope.
/// \remark Must be freed with #ikarus_free.
IKA_API struct IkarusObjectScope * ikarus_entity_scope_to_object_scope(IkarusEntityScope const * scope);
IKARUS_END_HEADER
// @}

View file

@ -1,46 +0,0 @@
#pragma once
// IMPLEMENTATION_DETAIL_OBJECT_SCOPES
/// \file object_scope.h
/// \author Folling <folling@ikarus.world>
#include <ikarus/macros.h>
/// \defgroup object_scopes Object Scopes
/// \brief Scopes define where objects belong to.
/// \details They are required to differentiate between different types of objects with NULL as their parent.
/// @{
IKARUS_BEGIN_HEADER
/// \brief The scope of an object.
struct IkarusObjectScope;
/// \brief The type of an object scope.
enum IkarusObjectScopeType {
/// \brief The scope is a blueprint scope.
IkarusObjectScopeType_Blueprint = 1,
/// \brief The scope is a property scope.
IkarusObjectScopeType_Property = 2,
/// \brief The scope is an entity scope.
IkarusObjectScopeType_Entity = 3
};
/// \brief Visits an object scope, calling the appropriate function.
/// \param scope The scope to visit.
/// \param blueprint_visitor The function to call if the scope is an #IkarusBlueprintScope.
/// \param property_visitor The function to call if the scope is an #IkarusPropertyScope.
/// \param entity_visitor The function to call if the scope is an #IkarusEntityScope.
/// \remark function pointers may be null in which case they are not called.
IKA_API void ikarus_object_scope_visit(
IkarusObjectScope * scope,
void (*blueprint_visitor)(struct IkarusBlueprintScope *, void *),
void (*property_visitor)(struct IkarusPropertyScope *, void *),
void (*entity_visitor)(struct IkarusEntityScope *, void *),
void * data
);
/// @}
IKARUS_END_HEADER

View file

@ -1,48 +0,0 @@
#pragma once
/// \file property_scope.h
/// \author Folling <folling@ikarus.world>
#include <ikarus/id.h>
#include <ikarus/macros.h>
/// \addtogroup object_scopes ObjectScopes
/// @{
IKARUS_BEGIN_HEADER
/// \brief The scope of a property
struct IkarusPropertyScope;
/// \brief Creates a property scope from a blueprint.
/// \param blueprint The blueprint the property is scoped to.
/// \return The created property scope.
/// \remark Must be freed with #ikarus_free.
IKA_API IkarusPropertyScope * ikarus_property_scope_create_blueprint(struct IkarusBlueprint * blueprint);
/// \brief Creates a property scope from an entity.
/// \param entity The entity the property is scoped to.
/// \return The created property scope.
/// \remark Must be freed with #ikarus_free.
IKA_API IkarusPropertyScope * ikarus_property_scope_create_entity(struct IkarusEntity * entity);
/// \brief Converts a property scope to an object scope.
/// \param scope The scope to convert.
/// \return The converted scope.
/// \remark Must be freed with #ikarus_free.
IKA_API struct IkarusObjectScope * ikarus_property_scope_to_object_scope(IkarusPropertyScope const * scope);
/// \brief Visits a property scope, calling the appropriate function.
/// \param scope The scope to to visit
/// \param blueprint_visitor The function to call if the property is scoped to a blueprint.
/// \param entity_visitor The function to call if the property is scoped to an entity.
/// \param data The data passed to the visitor functions.
IKA_API void ikarus_property_scope_visit(
IkarusPropertyScope * scope,
void (*blueprint_visitor)(struct IkarusBlueprint *, void *),
void (*entity_visitor)(struct IkarusEntity *, void *),
void * data
);
IKARUS_END_HEADER
// @}