libikarus/include/ikarus/objects/blueprint.h
Folling 70820129ae
add flatbuffers support and initial rewrite
Signed-off-by: Folling <mail@folling.io>
2025-04-15 12:08:10 +02:00

149 lines
4.9 KiB
C

#pragma once
/// \file blueprint.h
/// \author Folling <folling@ikarus.world>
#include <ikarus/errors.h>
#include <ikarus/macros.h>
#include <ikarus/stdtypes.h>
/// \defgroup blueprints Blueprints
/// \brief Blueprints are templates for entities.
/// @{
IKARUS_BEGIN_HEADER
/// \brief Blueprints are templates for managing common properties of entities.
/// \details A blueprint is a collection of properties which can be linked to entities.
/// Each entity the blueprint is linked to will have values for the blueprints
/// properties. Changes in blueprints will be reflected in all linked entities.
struct IkarusBlueprint;
/// \brief Creates a blueprint.
/// \param project The project the blueprint is part of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param name The name of the blueprint.
/// \pre \li Must not be null.
/// \param error_out \see errors.h
/// \return The created blueprint or null if an error occurs.
IKA_API IkarusBlueprint * ikarus_blueprint_create(
struct IkarusProject * project,
char const * name,
IkarusErrorData * error_out
);
/// \brief Deletes a blueprint.
/// \param blueprint The blueprint to delete.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \remark The blueprint must not be accessed after deletion.
IKA_API void ikarus_blueprint_delete(
IkarusBlueprint * blueprint,
IkarusErrorData * error_out
);
/// \brief Gets the ID of a blueprint.
/// \param blueprint The blueprint to get the ID of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \return The ID of the blueprint or 0 if an error occurs.
IKA_API int64_t ikarus_blueprint_get_id(
IkarusBlueprint const * blueprint,
IkarusErrorData * error_out
);
/// \brief Gets the project a blueprint is part of.
/// \param blueprint The blueprint to get the project of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \return The project or null if an error occurs.
IKA_API IkarusProject * ikarus_blueprint_get_project(
IkarusBlueprint const * blueprint,
IkarusErrorData * error_out
);
/// \brief Gets the name of a blueprint.
/// \param blueprint The blueprint to get the name of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \return The name or null if an error occurs.
IKA_API char const * ikarus_blueprint_get_name(
IkarusBlueprint const * blueprint,
IkarusErrorData * error_out
);
/// \brief Sets the name of a blueprint.
/// \param blueprint The blueprint to set the name of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param name The new name of the blueprint.
/// \pre \li Must not be null.
/// \param error_out \see errors.h
IKA_API void ikarus_blueprint_set_name(
IkarusBlueprint * blueprint,
char const * name,
IkarusErrorData * error_out
);
/// \brief Gets the properties of a blueprint.
/// \param blueprint The blueprint to get the properties of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param properties_out The buffer to write the properties to.
/// \pre \li Must not be null.
/// \param properties_out_size The size of the buffer.
/// \param error_out \see errors.h
/// \see ikarus_blueprint_get_property_count
IKA_API void ikarus_blueprint_get_properties(
IkarusBlueprint const * blueprint,
struct IkarusProperty ** properties_out,
size_t properties_out_size,
IkarusErrorData * error_out
);
/// \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.
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \return The number of properties or undefined if an error occurs.
IKA_API size_t ikarus_blueprint_get_property_count(
IkarusBlueprint const * blueprint,
IkarusErrorData * error_out
);
/// \brief Gets the entities linked to a blueprint.
/// \param blueprint The blueprint to get the linked entities of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param entities_out The buffer to write the entities to.
/// \pre \li Must not be null.
/// \param entities_out_size The size of the buffer.
/// \param error_out \see errors.h
/// \see ikarus_blueprint_get_linked_entity_count
IKA_API void ikarus_blueprint_get_linked_entities(
IkarusBlueprint const * blueprint,
struct IkarusEntity ** entities_out,
size_t entities_out_size,
IkarusErrorData * error_out
);
/// \brief Gets the number of entities linked to a blueprint.
/// \param blueprint The blueprint to get the number of linked entities of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \return The number of linked entities or undefined if an error occurs.
IKA_API size_t ikarus_blueprint_get_linked_entity_count(
IkarusBlueprint const * blueprint,
IkarusErrorData * error_out
);
IKARUS_END_HEADER
// @}