add blueprint & property implementation

This commit is contained in:
Folling 2025-01-04 15:25:10 +01:00
parent ef27673846
commit 71964229e7
No known key found for this signature in database
6 changed files with 772 additions and 43 deletions

View file

@ -154,6 +154,22 @@ IKA_API void ikarus_blueprint_set_name(
struct IkarusErrorData * error_out
);
/// \brief Gets whether a blueprint has a property.
/// \param blueprint The blueprint to check the property of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param property The property to check the existence of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \pre \li Must be in the same project as the blueprint.
/// \param error_out \see errors.h
/// \return True if the blueprint has the property, false otherwise or if an error occurs.
IKA_API bool ikarus_blueprint_has_property(
struct IkarusBlueprint * blueprint,
struct IkarusProperty * property,
struct 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.
@ -161,7 +177,7 @@ IKA_API void ikarus_blueprint_set_name(
/// \param size_out An out parameter for the number of items in the returned array or undefined if an error occurs.
/// \param error_out \see errors.h
/// \return The properties of the blueprint or null if an error occurs.
IKA_API struct IkarusBlueprint ** ikarus_blueprint_get_properties(
IKA_API struct IkarusProperty ** ikarus_blueprint_get_properties(
struct IkarusBlueprint * blueprint,
size_t * size_out,
struct IkarusErrorData * error_out
@ -176,15 +192,15 @@ IKA_API struct IkarusBlueprint ** ikarus_blueprint_get_properties(
IKA_API size_t
ikarus_blueprint_get_properties_count(struct IkarusBlueprint * blueprint, struct IkarusErrorData * error_out);
/// \brief Gets all entities linked to a blueprint.
/// \param blueprint The blueprint to get the entities of.
/// \brief Gets the linked entities of a blueprint.
/// \param blueprint The blueprint to get the linked entities of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param size_out An out parameter for the number of items in the returned array or undefined if an error occurs.
/// \remark Ignore if null.
/// \param error_out \see errors.h
/// \return The entities linked to the blueprint or null if an error occurs.
IKA_API struct IkarusEntity ** ikarus_blueprint_get_entities(
/// \return The linked entities of the blueprint or null if an error occurs.
IKA_API struct IkarusEntity ** ikarus_blueprint_get_linked_entities(
struct IkarusBlueprint * blueprint,
size_t * size_out,
struct IkarusErrorData * error_out
@ -197,7 +213,7 @@ IKA_API struct IkarusEntity ** ikarus_blueprint_get_entities(
/// \param error_out \see errors.h
/// \return The number of entities linked to the blueprint or 0 if an error occurs.
IKA_API size_t
ikarus_blueprint_get_entities_count(struct IkarusBlueprint * blueprint, struct IkarusErrorData * error_out);
ikarus_blueprint_get_linked_entities_count(struct IkarusBlueprint * blueprint, struct IkarusErrorData * error_out);
IKARUS_END_HEADER

View file

@ -53,23 +53,47 @@ enum IkarusPropertyCreateFlags {
/// \param project The project to create the property in.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param blueprint The blueprint to create the property for.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param name The name of the property.
/// \pre \li Must not be null.
/// \pre \li Must not be empty.
/// \param schema The schema of the property.
/// \pre \li Must not be null.
/// \pre \li Must be a valid JSON buffer for a IkarusValueSchema. \see schema.h
/// \param default_value The default value of the property.
/// \pre \li Must not be null.
/// \pre \li Must be a valid JSON buffer for an IkarusValueData. \see data.h
/// \param flags Flags for creating the property.
/// \param error_out \see errors.h
/// \return The created property or NULL if an error occurred.
/// \remark Must only be deleted with #ikarus_property_delete.
IKA_API IkarusProperty * ikarus_property_create(
struct IkarusProject * project,
struct IkarusBlueprint * blueprint,
char const * name,
struct IkarusValueSchema * schema,
char const * schema,
char const * default_value,
IkarusPropertyCreateFlags flags,
IkarusErrorData * error_out
);
/// \brief Flags for copying a property.
enum IkarusPropertyCopyFlags {
/// \brief No flags.
IkarusPropertyCopyFlags_None = 0,
};
/// \brief Copy a property.
/// \param property The property to copy.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param flags Flags for copying the property.
/// \param error_out \see errors.h
/// \return The copied property or NULL if an error occurred.
IKA_API IkarusProperty *
ikarus_property_copy(IkarusProperty * property, IkarusPropertyCopyFlags flags, IkarusErrorData * error_out);
/// \brief Flags for deleting a property.
enum IkarusPropertyDeleteFlags {
/// \brief No flags.
@ -101,15 +125,6 @@ IKA_API struct IkarusProject * ikarus_property_get_project(IkarusProperty * prop
/// \remark Ownership remains with libikarus.
IKA_API char const * ikarus_property_get_name(IkarusProperty * property, IkarusErrorData * error_out);
/// \brief Get the schema of a property.
/// \param property The property to get the schema of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \return The schema of the property or null if an error occurred.
/// \remark Ownership remains with libikarus.
IKA_API struct IkarusValueSchema * ikarus_property_get_schema(IkarusProperty * property, IkarusErrorData * error_out);
/// \brief Flags for setting the name of a property.
enum IkarusPropertySetNameFlags {
/// \brief No flags.
@ -133,6 +148,78 @@ IKA_API void ikarus_property_set_name(
IkarusErrorData * error_out
);
/// \brief Get the schema of a property.
/// \param property The property to get the schema of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \return The schema of the property in JSON format or null if an error occurred. \see schema.h
IKA_API char const * ikarus_property_get_schema(IkarusProperty * property, IkarusErrorData * error_out);
/// \brief Flags for setting the schema of a property.
enum IkarusPropertySetSchemaFlags {
/// \brief No flags.
IkarusPropertySetSchemaFlags_None = 0,
};
/// \brief Set the schema of a property.
/// \details Setting the schema of a property will reset all existing values.
/// \param property The property to set the schema of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param schema The new schema of the property.
/// \pre \li Must not be null.
/// \pre \li Must be a valid JSON buffer for a IkarusValueSchema. \see schema.h
/// \param new_default_value The new default value of the property.
/// \pre \li Must not be null.
/// \pre \li Must be a valid JSON buffer for an IkarusValueData. \see data.h
/// \param flags Flags for setting the schema of the property.
/// \param error_out \see errors.h
IKA_API void ikarus_property_set_schema(
IkarusProperty * property,
char const * schema,
char const * new_default_value,
IkarusPropertySetSchemaFlags flags,
IkarusErrorData * error_out
);
/// \brief Get the default value of a property.
/// \param property The property to get the default value of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param error_out \see errors.h
/// \return The default value data of the property in JSON format or null if an error occurred. \see data.h
IKA_API char const * ikarus_property_get_default_value(IkarusProperty * property, IkarusErrorData * error_out);
/// \details The default value must match the schema of the property.
/// \brief Flags for setting the default value of a property.
enum IkarusPropertySetDefaultValueFlags {
/// \brief No flags.
IkarusPropertySetDefaultValueFlags_None = 0,
};
/// \brief Flags for setting the default value of a property.
/// \param property The property to set the default value of.
/// \pre \li Must not be null.
/// \pre \li Must exist.
/// \param value The new default value of the property.
/// \pre \li Must not be null.
/// \pre \li Must be valid JSON \see data.h
/// \pre \li Must be valid according to the property's schema.
/// \param flags Flags for setting the default value of the property.
/// \param error_out \see errors.h
IKA_API void ikarus_property_set_default_value(
IkarusProperty * property,
char const * value,
IkarusPropertySetDefaultValueFlags flags,
IkarusErrorData * error_out
);
/// \brief Gets all values for a property.
/// \param property The property to get the values of.
///
IKARUS_END_HEADER
/// @}