#pragma once /// \file blueprint_folder.h /// \author Folling #include /// \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 // @}