finalise interface & documentation
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
c5157bd849
commit
52580a4382
56 changed files with 2074 additions and 780 deletions
|
|
@ -1,21 +1,150 @@
|
|||
#pragma once
|
||||
|
||||
/// \file blueprint_folder.h
|
||||
/// \author Folling <mail@folling.io>
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/id.h>
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
/// \addtogroup folder Folders
|
||||
/// \addtogroup blueprints Blueprints
|
||||
/// @{
|
||||
|
||||
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;
|
||||
};
|
||||
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
|
||||
|
||||
|
|
|
|||
31
include/ikarus/folders/blueprint_tree_item.h
Normal file
31
include/ikarus/folders/blueprint_tree_item.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#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
|
||||
|
||||
/// @}
|
||||
|
|
@ -1,21 +1,150 @@
|
|||
#pragma once
|
||||
|
||||
/// \file entity_folder.h
|
||||
/// \author Folling <mail@folling.io>
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/id.h>
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
/// \addtogroup folder Folders
|
||||
/// \addtogroup entities Entities
|
||||
/// @{
|
||||
|
||||
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;
|
||||
};
|
||||
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
|
||||
|
||||
|
|
|
|||
31
include/ikarus/folders/entity_tree_item.h
Normal file
31
include/ikarus/folders/entity_tree_item.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#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
|
||||
|
||||
/// @}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
/// \file folder.h
|
||||
/// \author Folling <mail@folling.io>
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/folders/blueprint_folder.h>
|
||||
#include <ikarus/folders/entity_folder.h>
|
||||
|
|
@ -15,61 +15,23 @@ IKARUS_BEGIN_HEADER
|
|||
/// \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;
|
||||
struct IkarusFolder;
|
||||
|
||||
/// \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 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 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.
|
||||
/// \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)(IkarusBlueprintFolder, void *),
|
||||
void (*property)(IkarusPropertyFolder, void *),
|
||||
void (*entity)(IkarusEntityFolder, void *),
|
||||
IkarusFolder * folder,
|
||||
void (*blueprint_visitor)(IkarusBlueprintFolder *, void *),
|
||||
void (*property_visitor)(IkarusPropertyFolder *, void *),
|
||||
void (*entity_visitor)(IkarusEntityFolder *, void *),
|
||||
void * data
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
// IMPLEMENTATION_DETAIL_FOLDER_TYPES
|
||||
|
||||
/// \file folder_type.h
|
||||
/// \author Folling <mail@folling.io>
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
|
|
@ -11,16 +11,16 @@
|
|||
/// @{
|
||||
|
||||
/// \brief The type of an folder.
|
||||
/// \remark Folders have the 8th bit set.
|
||||
/// \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 = 0b1000'0001,
|
||||
IkarusFolderType_BlueprintFolder = 0b0100'0001,
|
||||
/// \brief An IkarusPropertyFolder
|
||||
IkarusFolderType_PropertyFolder = 0b1000'0010,
|
||||
IkarusFolderType_PropertyFolder = 0b0100'0010,
|
||||
/// \brief An IkarusEntityFolder
|
||||
IkarusFolderType_EntityFolder = 0b1000'0011,
|
||||
IkarusFolderType_EntityFolder = 0b0100'0011,
|
||||
};
|
||||
|
||||
/// @}
|
||||
|
|
|
|||
|
|
@ -1,22 +1,158 @@
|
|||
#pragma once
|
||||
|
||||
#include <ikarus/id.h>
|
||||
/// \file property_folder.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
/// \file property_folder.h
|
||||
/// \author Folling <mail@folling.io>
|
||||
|
||||
/// \addtogroup folder Folders
|
||||
/// \addtogroup properties Properties
|
||||
/// @{
|
||||
|
||||
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;
|
||||
};
|
||||
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
|
||||
|
||||
|
|
|
|||
31
include/ikarus/folders/property_tree_item.h
Normal file
31
include/ikarus/folders/property_tree_item.h
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#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
|
||||
|
||||
/// @}
|
||||
Loading…
Add table
Add a link
Reference in a new issue