add flatbuffers support and initial rewrite
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
7e883d24eb
commit
98cb7a44ef
72 changed files with 3929 additions and 1403 deletions
|
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/id.h>
|
||||
#include <ikarus/macros.h>
|
||||
#include <ikarus/stdtypes.h>
|
||||
|
||||
|
|
@ -14,25 +13,20 @@
|
|||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief Entities are the core building blocks of Ikarus.
|
||||
/// \detials Blueprints and Properties define the structure of the data.
|
||||
/// Entities define the data itself.
|
||||
/// \details Entities store two data: A name and a set of values.
|
||||
/// The name identifies the entity but does not have to be unique. The values
|
||||
/// are the actual information of the entity.
|
||||
///
|
||||
/// Properties can be associated with Entities in two ways:
|
||||
/// - Directly: The property is linked to the entity.
|
||||
/// - Indirectly: The property is linked to a blueprint the entity is linked to.
|
||||
/// For documentation on the types and layout of values \see Values.h.
|
||||
///
|
||||
/// For each property an entity is linked to, it has a value. These values depend on the property's type.
|
||||
/// For more information on the types see the property documentation.
|
||||
/// Entities can be linked to blueprints.
|
||||
/// The entity has a (possibly uninitialized) value for each property of all
|
||||
/// blueprints it is linked to. \see Property.h \see Blueprint.h.
|
||||
///
|
||||
/// Values are the core type of data within Ikarus.
|
||||
/// Each value is associated with one page and one property.
|
||||
///
|
||||
/// \remark Values are typed, the type of a value is specified by its associated property.
|
||||
/// For more information on the types see the property documentation.
|
||||
///
|
||||
/// \remark Values are guaranteed to be in valid format for a given type
|
||||
/// but not guaranteed to be valid under the settings of the property.
|
||||
/// This is because changing the settings can invalidate existing values without resetting them.
|
||||
/// We distinguish between `EntityValues` and `EntityPropertyValues`.
|
||||
/// `EntityValues` are a direct part of the entity.
|
||||
/// `EntityPropertyValues` are an indirect part of the entity, linked to them
|
||||
/// via a blueprint.
|
||||
struct IkarusEntity;
|
||||
|
||||
/// \brief Creates an entity.
|
||||
|
|
@ -41,11 +35,13 @@ struct IkarusEntity;
|
|||
/// \pre \li Must exist.
|
||||
/// \param name The name of the entity.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \pre \li Must be unique among all entities in the project.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created entity or null if an error occurs.
|
||||
IKA_API IkarusEntity * ikarus_entity_create(struct IkarusProject * project, char const * name, IkarusErrorData * error_out);
|
||||
IKA_API IkarusEntity * ikarus_entity_create(
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Deletes an entity.
|
||||
/// \param entity The entity to delete.
|
||||
|
|
@ -53,15 +49,17 @@ IKA_API IkarusEntity * ikarus_entity_create(struct IkarusProject * project, char
|
|||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark The entity must not be accessed after deletion.
|
||||
IKA_API void ikarus_entity_delete(IkarusEntity * entity, IkarusErrorData * error_out);
|
||||
IKA_API void
|
||||
ikarus_entity_delete(IkarusEntity * entity, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the ID of an entity.
|
||||
/// \param entity The entity to get the ID of.
|
||||
/// \brief Gets the id of an entity.
|
||||
/// \param entity The entity 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 entity or 0 if an error occurs.
|
||||
IKA_API IkarusId ikarus_entity_get_id(IkarusEntity const * entity, IkarusErrorData * error_out);
|
||||
/// \return The id of the entity or 0 if an error occurs.
|
||||
IKA_API int64_t
|
||||
ikarus_entity_get_id(IkarusEntity const * entity, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the project an entity is part of.
|
||||
/// \param entity The entity to get the project of.
|
||||
|
|
@ -69,7 +67,10 @@ IKA_API IkarusId ikarus_entity_get_id(IkarusEntity const * entity, IkarusErrorDa
|
|||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The project the entity is part of or null if an error occurs.
|
||||
IKA_API IkarusProject * ikarus_entity_get_project(IkarusEntity const * entity, IkarusErrorData * error_out);
|
||||
IKA_API IkarusProject * ikarus_entity_get_project(
|
||||
IkarusEntity const * entity,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the name of an entity.
|
||||
/// \param entity The entity to get the name of.
|
||||
|
|
@ -77,7 +78,10 @@ IKA_API IkarusProject * ikarus_entity_get_project(IkarusEntity const * entity, I
|
|||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The name of the entity or null if an error occurs.
|
||||
IKA_API char const * ikarus_entity_get_name(IkarusEntity const * entity, IkarusErrorData * error_out);
|
||||
IKA_API char const * ikarus_entity_get_name(
|
||||
IkarusEntity const * entity,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Sets the name of an entity.
|
||||
/// \param entity The entity to set the name of.
|
||||
|
|
@ -85,10 +89,12 @@ IKA_API char const * ikarus_entity_get_name(IkarusEntity const * entity, IkarusE
|
|||
/// \pre \li Must exist.
|
||||
/// \param name The new name of the entity.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \pre \li Must be unique among all entities in the project.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_entity_set_name(IkarusEntity * entity, char const * name, IkarusErrorData * error_out);
|
||||
IKA_API void ikarus_entity_set_name(
|
||||
IkarusEntity * entity,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Checks if an entity is linked to a blueprint.
|
||||
/// \param entity The entity to check.
|
||||
|
|
@ -99,8 +105,11 @@ IKA_API void ikarus_entity_set_name(IkarusEntity * entity, char const * name, Ik
|
|||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return True if the entity is linked to the blueprint, false otherwise.
|
||||
IKA_API bool
|
||||
ikarus_entity_is_linked_to_blueprint(IkarusEntity const * entity, struct IkarusBlueprint const * blueprint, IkarusErrorData * error_out);
|
||||
IKA_API bool ikarus_entity_is_linked_to_blueprint(
|
||||
IkarusEntity const * entity,
|
||||
struct IkarusBlueprint const * blueprint,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Links an entity to a blueprint.
|
||||
/// \param entity The entity to link.
|
||||
|
|
@ -111,10 +120,14 @@ ikarus_entity_is_linked_to_blueprint(IkarusEntity const * entity, struct IkarusB
|
|||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark No-op if the entity is already linked to the blueprint.
|
||||
IKA_API void ikarus_entity_link_to_blueprint(IkarusEntity * entity, struct IkarusBlueprint * blueprint, IkarusErrorData * error_out);
|
||||
IKA_API void ikarus_entity_link_to_blueprint(
|
||||
IkarusEntity * entity,
|
||||
struct IkarusBlueprint * blueprint,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Unlinks an entity from a blueprint. All values of the properties of the blueprint the entity is linked with
|
||||
/// will be deleted.
|
||||
/// \brief Unlinks an entity from a blueprint.
|
||||
/// All values of the blueprints' properties will be deleted.
|
||||
/// \param entity The entity to unlink.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
|
|
@ -123,9 +136,13 @@ IKA_API void ikarus_entity_link_to_blueprint(IkarusEntity * entity, struct Ikaru
|
|||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark No-op if the entity is not linked to the blueprint.
|
||||
IKA_API void ikarus_entity_unlink_from_blueprint(IkarusEntity * entity, struct IkarusBlueprint * blueprint, IkarusErrorData * error_out);
|
||||
IKA_API void ikarus_entity_unlink_from_blueprint(
|
||||
IkarusEntity * entity,
|
||||
struct IkarusBlueprint * blueprint,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the blueprints an entity is linked to.
|
||||
/// \brief Gets all blueprints an entity is linked to.
|
||||
/// \param entity The entity to get the blueprints of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
|
|
@ -142,14 +159,80 @@ IKA_API void ikarus_entity_get_linked_blueprints(
|
|||
);
|
||||
|
||||
/// \brief Gets the number of blueprints an entity is linked to.
|
||||
/// \param entity The entity to get the number of blueprints of.
|
||||
/// \param entity The entity to get the number of linked blueprints of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The number of blueprints or undefined if an error occurs.
|
||||
IKA_API size_t ikarus_entity_get_linked_blueprint_count(IkarusEntity const * entity, IkarusErrorData * error_out);
|
||||
IKA_API size_t ikarus_entity_get_linked_blueprint_count(
|
||||
IkarusEntity const * entity,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Checks if an entity has a specific property.
|
||||
/// \brief Checks if an entity has a value with a given name.
|
||||
/// \param entity The entity to check.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the value to check.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return False if the entity does not have a value associated with
|
||||
/// the name or if an error occurs, true otherwise.
|
||||
IKA_API bool ikarus_entity_has_value(
|
||||
IkarusEntity const * entity,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the value of an entity.
|
||||
/// \param entity The entity to get the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the value to get.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must be an existing value of the entity.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The value of the entity or null if an error occurs.
|
||||
IKA_API struct IkarusValue * ikarus_entity_get_value(
|
||||
IkarusEntity const * entity,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Sets the value of an entity.
|
||||
/// If the entity does not have a value associated with the name, it is created.
|
||||
/// \remark Types are overwritten if the value already exists.
|
||||
/// \param entity The entity to set the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the value to set.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param value The new value of the entity.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_entity_set_value(
|
||||
IkarusEntity * entity,
|
||||
char const * name,
|
||||
struct IkarusValue const * value,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Removes a value from an entity.
|
||||
/// \pre \li The value must exist.
|
||||
/// \param entity The entity to delete the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the value to delete.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_entity_remove_value(
|
||||
IkarusEntity * entity,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Checks if a property is linked to an entity.
|
||||
/// \param entity The entity to check.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
|
|
@ -157,14 +240,19 @@ IKA_API size_t ikarus_entity_get_linked_blueprint_count(IkarusEntity const * ent
|
|||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return False if an error occurs or the entity does not have the property, true otherwise.
|
||||
IKA_API bool ikarus_entity_has_property(IkarusEntity const * entity, struct IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
/// \return False if an error occurs or the entity does not have the property,
|
||||
/// true otherwise.
|
||||
IKA_API bool ikarus_entity_has_property(
|
||||
IkarusEntity const * entity,
|
||||
struct IkarusProperty const * property,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the properties of an entity.
|
||||
/// \param entity The entity to get the properties of.
|
||||
/// \brief Gets the properties an entity is linked to.
|
||||
/// \param entity The entity to get the linked properties of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param properties_out The buffer to write the properties to.
|
||||
/// \param properties_out The buffer to write the linked properties to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \param properties_out_size The size of the buffer.
|
||||
|
|
@ -176,30 +264,37 @@ IKA_API void ikarus_entity_get_properties(
|
|||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the number of properties of an entity.
|
||||
/// \param entity The entity to get the number of properties of.
|
||||
/// \brief Gets the number of properties an entity is linked to.
|
||||
/// \param entity The entity to get the number of linked 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_entity_get_property_count(IkarusEntity const * entity, IkarusErrorData * error_out);
|
||||
IKA_API size_t ikarus_entity_get_property_count(
|
||||
IkarusEntity const * entity,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the value of a property of an entity.
|
||||
/// \details If the entity has never set the value of the property, the default value is returned (which may be undefined).
|
||||
/// \details If the entity has never set the value of the property,
|
||||
/// the property's default value is returned.
|
||||
/// \param entity The entity to get the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param property The property to get the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \pre \li Must be linked to the entity.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The value of the property or null if the entity does not have the property or an error occurs.
|
||||
/// \remark Must be freed using #ikarus_free.
|
||||
IKA_API struct IkarusEntityPropertyValue *
|
||||
ikarus_entity_get_value(IkarusEntity const * entity, struct IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
/// \return The value of the property or null if an error occurs.
|
||||
IKA_API struct IkarusValue * ikarus_entity_get_property_value(
|
||||
IkarusEntity const * entity,
|
||||
struct IkarusProperty const * property,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Sets the value of a property of an entity.
|
||||
/// \param entity The entity to set the value of.
|
||||
/// \param entity The entity to set the property value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param property The property to set the value of.
|
||||
|
|
@ -211,7 +306,7 @@ ikarus_entity_get_value(IkarusEntity const * entity, struct IkarusProperty const
|
|||
/// \pre \li Must be valid for the property's settings.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark If the entity does not have the property, this function fails.
|
||||
IKA_API void ikarus_entity_set_value(
|
||||
IKA_API void ikarus_entity_set_property_value(
|
||||
IkarusEntity * entity,
|
||||
struct IkarusProperty const * property,
|
||||
struct IkarusValue const * value,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue