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