finalize schema/data setup
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
70820129ae
commit
195f51d3d0
89 changed files with 2324 additions and 6271 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
/// \file blueprint.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
/// \author Folling <mail@folling.io>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
|
|
@ -13,57 +13,113 @@
|
|||
|
||||
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.
|
||||
/// \brief Templates for sharing common properties between entities.
|
||||
/// \details A blueprint allows sharing properties between entities.
|
||||
/// Each entity the blueprint is linked to will have a corresponding value for
|
||||
/// each of the blueprint's 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.
|
||||
/// \brief Flags for creating a blueprint.
|
||||
enum IkarusBlueprintCreateFlags {
|
||||
/// \brief No flags.
|
||||
IkarusBlueprintCreateFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Creates a new blueprint.
|
||||
/// \param project The project to create the blueprint in.
|
||||
/// \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
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param flags Flags for creating the blueprint.
|
||||
/// \return The created blueprint or null if an error occurs.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark Ownership remains with libikarus.
|
||||
IKA_API IkarusBlueprint * ikarus_blueprint_create(
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
IkarusBlueprintCreateFlags flags,
|
||||
struct IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Deletes a blueprint.
|
||||
/// \brief Flags for creating a blueprint from an entity.
|
||||
enum IkarusBlueprintCreateFromEntityFlags {
|
||||
/// \brief No flags.
|
||||
IkarusBlueprintCreateFromEntityFlags_None = 0,
|
||||
/// \brief The default values of the properties will be set to the values of the source entity.
|
||||
IkarusBlueprintCreateFromEntityFlags_AdoptDefaultValues = 1 << 0,
|
||||
/// \brief The entity will be linked to the blueprint, and all values will be turned into properties.
|
||||
IkarusBlueprintCreateFromEntityFlags_LinkEntity = 1 << 1,
|
||||
};
|
||||
|
||||
/// \brief Creates a new blueprint from an entity.
|
||||
/// \details Each value of the entity will be copied into the blueprint as a property.
|
||||
/// \param entity The entity to create the blueprint from.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the blueprint.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param flags Flags for creating the blueprint.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created blueprint or null if an error occurs.
|
||||
IKA_API IkarusBlueprint * ikarus_blueprint_create_from_entity(
|
||||
struct IkarusEntity * entity,
|
||||
char const * name,
|
||||
IkarusBlueprintCreateFromEntityFlags flags,
|
||||
struct IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Flags for copying a blueprint.
|
||||
enum IkarusBlueprintCopyFlags {
|
||||
/// \brief No flags.
|
||||
IkarusBlueprintCopyFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Copies a blueprint.
|
||||
/// \param blueprint The blueprint to copy.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param flags Flags for copying the blueprint.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The copied blueprint or null if an error occurs.
|
||||
IKA_API struct IkarusBlueprint * ikarus_blueprint_copy(
|
||||
struct IkarusBlueprint * blueprint,
|
||||
IkarusBlueprintCopyFlags flags,
|
||||
struct IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Flags for deleting a blueprint.
|
||||
enum IkarusBlueprintDeleteFlags {
|
||||
/// \brief No flags.
|
||||
IkarusBlueprintDeleteFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Deletes a blueprint, all associated properties, and their values.
|
||||
/// \param blueprint The blueprint to delete.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param flags Flags for deleting the blueprint.
|
||||
/// \remark Must not be used after deletion.
|
||||
/// \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
|
||||
struct IkarusBlueprint * blueprint,
|
||||
IkarusBlueprintDeleteFlags flags,
|
||||
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.
|
||||
/// \brief Gets the project a blueprint belongs to.
|
||||
/// \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
|
||||
/// \return The project the blueprint belongs to.
|
||||
/// \remark Ownership remains with libikarus.
|
||||
IKA_API struct IkarusProject * ikarus_blueprint_get_project(
|
||||
struct IkarusBlueprint * blueprint,
|
||||
struct IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the name of a blueprint.
|
||||
|
|
@ -71,79 +127,84 @@ IKA_API IkarusProject * ikarus_blueprint_get_project(
|
|||
/// \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.
|
||||
/// \return The name of the blueprint.
|
||||
/// \remark Ownership remains with libikarus.
|
||||
IKA_API char const * ikarus_blueprint_get_name(
|
||||
IkarusBlueprint const * blueprint,
|
||||
IkarusErrorData * error_out
|
||||
struct IkarusBlueprint * blueprint,
|
||||
struct IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Flags for setting the name of a blueprint.
|
||||
enum IkarusBlueprintSetNameFlags {
|
||||
/// \brief No flags.
|
||||
IkarusBlueprintSetNameFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \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.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param flags Flags for setting the name of the blueprint.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_blueprint_set_name(
|
||||
IkarusBlueprint * blueprint,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
struct IkarusBlueprint * blueprint,
|
||||
char const * name,
|
||||
IkarusBlueprintSetNameFlags flags,
|
||||
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.
|
||||
/// \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 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
|
||||
/// \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
|
||||
/// \return The properties of the blueprint or null if an error occurs.
|
||||
IKA_API struct IkarusProperty ** ikarus_blueprint_get_properties(
|
||||
struct IkarusBlueprint * blueprint,
|
||||
size_t * size_out,
|
||||
struct IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the number of properties of a blueprint.
|
||||
/// \param blueprint The blueprint to get the number of properties of.
|
||||
/// \param blueprint The blueprint to get the properties count 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
|
||||
/// \return The number of properties of the blueprint or 0 if an error occurs.
|
||||
IKA_API size_t ikarus_blueprint_get_properties_count(
|
||||
struct IkarusBlueprint * blueprint,
|
||||
struct IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the entities linked to a blueprint.
|
||||
/// \param blueprint The blueprint to get the linked entities of.
|
||||
/// \brief Gets all entities linked to a blueprint.
|
||||
/// \param blueprint The blueprint to get the 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 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
|
||||
/// \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
|
||||
/// \return The entities linked to the blueprint or null if an error occurs.
|
||||
IKA_API struct IkarusEntity ** ikarus_blueprint_get_entities(
|
||||
struct IkarusBlueprint * blueprint,
|
||||
size_t * size_out,
|
||||
struct 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.
|
||||
/// \param blueprint The blueprint to get the entities count 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
|
||||
/// \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_END_HEADER
|
||||
|
||||
// @}
|
||||
/// @}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
#include <ikarus/stdtypes.h>
|
||||
|
||||
/// \file entity.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
/// \author Folling <mail@folling.io>
|
||||
|
||||
/// \defgroup entities Entities
|
||||
/// \brief Entities are the core building blocks of Ikarus.
|
||||
|
|
@ -13,15 +13,13 @@
|
|||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief Entities are the core building blocks of Ikarus.
|
||||
/// \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.
|
||||
/// \details Entities store a number of values associated with a name or property.
|
||||
///
|
||||
/// For documentation on the types and layout of values \see Values.h.
|
||||
/// For documentation on the types and layout of values \see values.h.
|
||||
///
|
||||
/// 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.
|
||||
/// blueprints it is linked to. \see property.h \see blueprint.h.
|
||||
///
|
||||
/// We distinguish between `EntityValues` and `EntityPropertyValues`.
|
||||
/// `EntityValues` are a direct part of the entity.
|
||||
|
|
@ -29,59 +27,89 @@ IKARUS_BEGIN_HEADER
|
|||
/// via a blueprint.
|
||||
struct IkarusEntity;
|
||||
|
||||
/// \brief Creates an entity.
|
||||
/// \param project The project the entity is part of.
|
||||
/// \brief Flags for creating an entity.
|
||||
enum IkarusEntityCreateFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntityCreateFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Creates a new entity.
|
||||
/// \param project The project to create the entity in.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the entity.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param flags Flags for creating the entity.
|
||||
/// \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
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
IkarusEntityCreateFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Deletes an entity.
|
||||
/// \brief Flags for deleting an entity.
|
||||
enum IkarusEntityDeleteFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntityDeleteFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Deletes an entity and its values.
|
||||
/// \param entity The entity to delete.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param flags Flags for deleting the entity.
|
||||
/// \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,
|
||||
IkarusEntityDeleteFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the id of an entity.
|
||||
/// \param entity The entity to get the id of.
|
||||
/// \brief Flags for copying an entity.
|
||||
enum IkarusEntityCopyFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntityCopyFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Copies an entity.
|
||||
/// \param entity The entity to copy.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param flags Flags for copying the entity.
|
||||
/// \param error_out \see errors.h
|
||||
/// \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);
|
||||
/// \return The copied entity or null if an error occurs.
|
||||
IKA_API IkarusEntity * ikarus_entity_copy(
|
||||
IkarusEntity * entity,
|
||||
IkarusEntityCopyFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the project an entity is part of.
|
||||
/// \brief Gets the project an entity belongs to.
|
||||
/// \param entity The entity to get the project of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \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
|
||||
);
|
||||
/// \return The project the entity belongs to.
|
||||
IKA_API struct IkarusProject *
|
||||
ikarus_entity_get_project(IkarusEntity * entity, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the name of an entity.
|
||||
/// \param entity The entity to get the name of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \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
|
||||
);
|
||||
/// \return The name of the entity.
|
||||
IKA_API char const *
|
||||
ikarus_entity_get_name(IkarusEntity * entity, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Flags for setting the name of an entity.
|
||||
enum IkarusEntitySetNameFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntitySetNameFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Sets the name of an entity.
|
||||
/// \param entity The entity to set the name of.
|
||||
|
|
@ -89,73 +117,27 @@ IKA_API char const * ikarus_entity_get_name(
|
|||
/// \pre \li Must exist.
|
||||
/// \param name The new name of the entity.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param flags Flags for setting the name of the entity.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_entity_set_name(
|
||||
IkarusEntity * entity,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
IkarusEntity * entity,
|
||||
char const * name,
|
||||
IkarusEntitySetNameFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Checks if an entity is linked to a blueprint.
|
||||
/// \param entity The entity to check.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param blueprint The blueprint to check.
|
||||
/// \pre \li Must not be null.
|
||||
/// \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
|
||||
);
|
||||
|
||||
/// \brief Links an entity to a blueprint.
|
||||
/// \param entity The entity to link.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param blueprint The blueprint to link the entity to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \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
|
||||
);
|
||||
|
||||
/// \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.
|
||||
/// \param blueprint The blueprint to unlink the entity from.
|
||||
/// \pre \li Must not be null.
|
||||
/// \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
|
||||
);
|
||||
|
||||
/// \brief Gets all blueprints an entity is linked to.
|
||||
/// \brief Gets the 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.
|
||||
/// \param blueprints_out The buffer to write the blueprints to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param blueprints_out_size The size of the buffer.
|
||||
/// \param size_out An out parameter for the number of blueprints in the returned array
|
||||
/// or undefined if an error occurs.
|
||||
/// \param error_out \see errors.h
|
||||
/// \see ikarus_entity_get_linked_blueprint_count
|
||||
IKA_API void ikarus_entity_get_linked_blueprints(
|
||||
IkarusEntity const * entity,
|
||||
struct IkarusBlueprint ** blueprints_out,
|
||||
size_t blueprints_out_size,
|
||||
IkarusErrorData * error_out
|
||||
IKA_API struct IkarusBlueprint ** ikarus_entity_get_linked_blueprints(
|
||||
IkarusEntity * entity,
|
||||
size_t * size_out,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the number of blueprints an entity is linked to.
|
||||
|
|
@ -163,156 +145,199 @@ IKA_API void ikarus_entity_get_linked_blueprints(
|
|||
/// \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
|
||||
/// \return The number of linked blueprints or 0 if an error occurs.
|
||||
IKA_API size_t ikarus_entity_get_linked_blueprints_count(
|
||||
IkarusEntity * entity,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Checks if an entity has a value with a given name.
|
||||
/// \param entity The entity to check.
|
||||
/// \brief Flags for linking an entity to a blueprint.
|
||||
enum IkarusEntityLinkBlueprintFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntityLinkBlueprintFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Links an entity to a blueprint.
|
||||
/// \details An uninitialized (default) value is created for each property of the
|
||||
/// blueprint.
|
||||
/// \param entity The entity to link the blueprint to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the value to check.
|
||||
/// \param blueprint The blueprint to link to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \pre \li Must be in the same project as the entity.
|
||||
/// \remark If the entity is already linked to the blueprint, nothing happens.
|
||||
/// \param flags Flags for linking the entity to the blueprint.
|
||||
/// \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
|
||||
IKA_API void ikarus_entity_link_blueprint(
|
||||
IkarusEntity * entity,
|
||||
struct IkarusBlueprint * blueprint,
|
||||
IkarusEntityLinkBlueprintFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the value of an entity.
|
||||
/// \brief Flags for unlinking an entity from a blueprint.
|
||||
enum IkarusEntityUnlinkBlueprintFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntityUnlinkBlueprintFlags_None = 0,
|
||||
/// \brief Keep the values associated with the blueprint, transforming them into entity values.
|
||||
IkarusEntityUnlinkBlueprintFlags_KeepValues = 1,
|
||||
};
|
||||
|
||||
/// \brief Unlinks an entity from a blueprint.
|
||||
/// \details All values associated with the blueprint are deleted.
|
||||
/// \param entity The entity to unlink the blueprint from.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param blueprint The blueprint to unlink from.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \remark If the entity is not linked to the blueprint, nothing happens.
|
||||
/// \param flags Flags for unlinking the entity from the blueprint.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_entity_unlink_blueprint(
|
||||
IkarusEntity * entity,
|
||||
struct IkarusBlueprint * blueprint,
|
||||
IkarusEntityUnlinkBlueprintFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the values of an entity.
|
||||
/// \param entity The entity to get the values of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The values, in json format of or null if an error occurs.
|
||||
/// The json representation is an array of objects with the following keys:
|
||||
/// - `name`: The name of the value.
|
||||
/// - `value`: The value itself. \see value.h
|
||||
IKA_API char const *
|
||||
ikarus_entity_get_values(IkarusEntity * entity, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets a 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.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The value's name.
|
||||
/// \pre \li Must not be null.
|
||||
/// \remark Ownership remains with the client.
|
||||
/// \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
|
||||
/// \return The value, in json format of or null if an error occurs. \see value.h
|
||||
IKA_API char const * ikarus_entity_get_value(
|
||||
IkarusEntity * 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.
|
||||
/// \brief Flags for setting a value of an entity.
|
||||
enum IkarusEntitySetValueFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntitySetValueFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Sets a value of an entity.
|
||||
/// \details If no value exists for the name, a new one is created.
|
||||
/// Any previous value is overwritten.
|
||||
/// \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.
|
||||
/// \param name The value's name.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param value The new value of the entity.
|
||||
/// \param value The value to set.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must be a valid json representation of a value. \see value.h
|
||||
/// \param flags Flags for setting the value.
|
||||
/// \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
|
||||
IkarusEntity * entity,
|
||||
char const * name,
|
||||
char const * value,
|
||||
IkarusEntitySetValueFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Removes a value from an entity.
|
||||
/// \pre \li The value must exist.
|
||||
/// \brief Flags for deleting a value of an entity.
|
||||
enum IkarusEntityDeleteValueFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntityDeleteValueFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Deletes a value of an entity.
|
||||
/// \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.
|
||||
/// \param name The property's name to delete the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must be the name of a value which exists within the property.
|
||||
/// \param flags Flags for deleting the value.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_entity_remove_value(
|
||||
IkarusEntity * entity,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
IKA_API void ikarus_entity_delete_value(
|
||||
IkarusEntity * entity,
|
||||
char const * name,
|
||||
IkarusEntityDeleteValueFlags flags,
|
||||
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.
|
||||
/// \param property The property to check.
|
||||
/// \brief Gets the property values of an entity.
|
||||
/// \param entity The entity to get the property values of.
|
||||
/// \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
|
||||
);
|
||||
|
||||
/// \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 linked properties to.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \param properties_out_size The size of the buffer.
|
||||
/// \see ikarus_entity_get_property_count
|
||||
IKA_API void ikarus_entity_get_properties(
|
||||
IkarusEntity const * entity,
|
||||
struct IkarusProperty ** properties_out,
|
||||
size_t properties_out_size,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \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
|
||||
/// \return The property values, in msgpack format of or null if an error occurs.
|
||||
/// The format is a map of property pointers (as integers) to values. \see
|
||||
/// value.h
|
||||
IKA_API char const * ikarus_entity_get_property_values(
|
||||
IkarusEntity * 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 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 an error occurs.
|
||||
IKA_API struct IkarusValue * ikarus_entity_get_property_value(
|
||||
IkarusEntity const * entity,
|
||||
struct IkarusProperty const * property,
|
||||
IkarusErrorData * error_out
|
||||
/// \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, in json format of or null if an error occurs. \see
|
||||
/// value.h
|
||||
IKA_API char const * ikarus_entity_get_property_value(
|
||||
IkarusEntity * entity,
|
||||
struct IkarusProperty * property,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Flags for setting the value of a property of an entity.
|
||||
enum IkarusEntitySetPropertyValueFlags {
|
||||
/// \brief No flags.
|
||||
IkarusEntitySetPropertyValueFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Sets the value of a property of an entity.
|
||||
/// \param entity The entity to set the property value of.
|
||||
/// \details Any previous value is overwritten.
|
||||
/// \param entity The entity to set the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param property The property to set the value of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param value The new value of the property.
|
||||
/// \pre \li Must be linked to the entity.
|
||||
/// \param value The value to set.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must be of the same type as the property.
|
||||
/// \pre \li Must be valid for the property's settings.
|
||||
/// \pre \li Must be a valid json representation of a value. \see value.h
|
||||
/// \pre \li Must be valid for the property's schema. \see schema.h
|
||||
/// \param flags Flags for setting the property value.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark If the entity does not have the property, this function fails.
|
||||
IKA_API void ikarus_entity_set_property_value(
|
||||
IkarusEntity * entity,
|
||||
struct IkarusProperty const * property,
|
||||
struct IkarusValue const * value,
|
||||
IkarusErrorData * error_out
|
||||
IkarusEntity * entity,
|
||||
struct IkarusProperty * property,
|
||||
char const * value,
|
||||
IkarusEntitySetPropertyValueFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
// @}
|
||||
/// @}
|
||||
|
|
|
|||
|
|
@ -1,40 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
/// \file number_property.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
/// \addtogroup properties Properties
|
||||
/// \brief Number properties store a value that can be either true or false. (e.g. "Is the character dead?")
|
||||
/// @{
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
struct IkarusNumberProperty;
|
||||
|
||||
/// \brief Creates a number property.
|
||||
/// \param project The project to create the property in.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param property_source The property source to create the property for.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param default_value The default value for the property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created property or null if an error occurs.
|
||||
IKA_API IkarusNumberProperty * ikarus_number_property_create(
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
struct IkarusPropertySource * property_source,
|
||||
struct IkarusNumberValue * default_value,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
/// @}
|
||||
|
|
@ -1,144 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
/// \file property.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
#include <ikarus/stdtypes.h>
|
||||
#include <ikarus/values/value_cardinality.h>
|
||||
#include <ikarus/values/value_type.h>
|
||||
|
||||
/// \defgroup properties Properties
|
||||
/// \brief Properties define the structure and types of data.
|
||||
/// @{
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief Properties define the structure of blueprints.
|
||||
/// \details Each blueprint can have any number of properties.
|
||||
/// Every property has a type that identifies the kind of data that can be put in.
|
||||
/// This is the "base class" of properties. See the derived types (e.g. IkarusToggleProperty) for more information.
|
||||
///
|
||||
/// The following types currently exist:
|
||||
/// - Toggle: A true/false boolean-like value
|
||||
/// - Number: An arbitrary numeric value
|
||||
/// - Text: An arbitrary textual value
|
||||
///
|
||||
/// Property Examples:
|
||||
/// - Is Dead (Toggle)
|
||||
/// - Age (Number)
|
||||
/// - ISBN (Text)
|
||||
///
|
||||
/// Each entity associated with the property has a value for it.
|
||||
///
|
||||
/// \remark Values for properties are lazily created to save space.
|
||||
/// Fetching the value for some property of some entity will return the property's default value if none is specified.
|
||||
struct IkarusProperty;
|
||||
|
||||
/// \brief Deletes a property.
|
||||
/// \param property The property to delete.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark The property must not be accessed after deletion.
|
||||
IKA_API void ikarus_property_delete(IkarusProperty * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the ID of a property.
|
||||
/// \param property The property 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 property or 0 if an error occurs.
|
||||
IKA_API int64_t ikarus_property_get_id(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the project of a property.
|
||||
/// \param property The property to get the project of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The project of the property or null if an error occurs.
|
||||
IKA_API struct IkarusProject * ikarus_property_get_project(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the name of an property.
|
||||
/// \param entity The property to get the name of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The name of the property or null if an error occurs.
|
||||
IKA_API char const * ikarus_property_get_name(IkarusProperty const * entity, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Sets the name of an property.
|
||||
/// \param entity The property to set the name of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The new name of the property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_property_set_name(IkarusProperty * entity, char const * name, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the type info of a property.
|
||||
/// \param property The property to get the type info of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The type info of the property or null if an error occurs.
|
||||
/// \remark Changing the type of a property is not supported. This is because the property would need to change
|
||||
IKA_API IkarusValueType ikarus_property_get_type(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
// there is no `set_type` as we encode type information in the underlying datatype
|
||||
|
||||
/// \briefs Gets a property's cardinality.
|
||||
/// \param property The property to get the cardinality of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The cardinality of the property or false if an error occurs.
|
||||
IKA_API IkarusValueCardinality ikarus_property_get_cardinality(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \briefs Sets a property's default value.
|
||||
/// \param property The property to set the cardinality of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \\param cardinality The new cardinality of the property.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void
|
||||
ikarus_property_set_cardinality(IkarusProperty * property, IkarusValueCardinality cardinality, IkarusErrorData * error_out);
|
||||
|
||||
/// \briefs Gets a property's default value.
|
||||
/// \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 of the property or null if an error occurs.
|
||||
IKA_API struct IkarusValue * ikarus_property_get_default_value(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the source blueprint of a property.
|
||||
/// \param property The property to get the source of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The source of the property or null if an error occurs.
|
||||
IKA_API struct IkarusBlueprint * ikarus_property_get_blueprint(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Visits a property. Calling the appropriate function for the property's type.
|
||||
/// \param property The property to visit.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param toggle_property_visitor The function to call if the property is a toggle property. Skipped if null.
|
||||
/// \param number_property_visitor The function to call if the property is a number property. Skipped if null.
|
||||
/// \param text_property_visitor The function to call if the property is a text property. Skipped if null.
|
||||
/// \param data The data to pass to the functions.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_property_visit(
|
||||
IkarusProperty * property,
|
||||
void (*toggle_property_visitor)(struct IkarusToggleProperty *, void *),
|
||||
void (*number_property_visitor)(struct IkarusNumberProperty *, void *),
|
||||
void (*text_property_visitor)(struct IkarusTextProperty *, void *),
|
||||
void * data,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
// @}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
/// \file text_property.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
/// \addtogroup properties Properties
|
||||
/// \brief Text properties store a value that can be either true or false. (e.g. "Is the character dead?")
|
||||
/// @{
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
struct IkarusTextProperty;
|
||||
|
||||
/// \brief Creates a text property.
|
||||
/// \param project The project to create the property in.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param property_source The property source to create the property for.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param default_value The default value for the property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created property or null if an error occurs.
|
||||
IKA_API IkarusTextProperty * ikarus_text_property_create(
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
struct IkarusPropertySource * property_source,
|
||||
struct IkarusTextValue * default_value,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
/// @}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
/// \file toggle_property.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
|
||||
/// \addtogroup properties Properties
|
||||
/// @{
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief Toggle properties store a value that can be either true or false. (e.g. "Is the character dead?")
|
||||
struct IkarusToggleProperty;
|
||||
|
||||
/// \brief Creates a toggle property.
|
||||
/// \param project The project to create the property in.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name of the property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param property_source The property source to create the property for.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created property or null if an error occurs.
|
||||
IKA_API IkarusToggleProperty * ikarus_toggle_property_create(
|
||||
struct IkarusProject * project,
|
||||
char const * name,
|
||||
struct IkarusPropertySource * property_source,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
/// @}
|
||||
143
include/ikarus/objects/property.h
Normal file
143
include/ikarus/objects/property.h
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
#pragma once
|
||||
|
||||
/// \file property.h
|
||||
/// \author Folling <mail@folling.io>
|
||||
|
||||
#include <ikarus/errors.h>
|
||||
#include <ikarus/macros.h>
|
||||
#include <ikarus/stdtypes.h>
|
||||
|
||||
/// \defgroup properties Properties
|
||||
/// \brief Properties define the structure and types of data.
|
||||
/// @{
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief Properties define the structure of blueprints.
|
||||
/// \details Each blueprint can have any number of properties.
|
||||
/// Every property has a type that identifies the kind of data that can be put
|
||||
/// in. This is the "base class" of properties. See the derived types (e.g.
|
||||
/// IkarusToggleProperty) for more information.
|
||||
///
|
||||
/// The following types currently exist:
|
||||
/// - Toggle: A true/false boolean-like value
|
||||
/// - Number: An arbitrary numeric value
|
||||
/// - Text: An arbitrary textual value
|
||||
///
|
||||
/// Property Examples:
|
||||
/// - Is Dead (Toggle)
|
||||
/// - Age (Number)
|
||||
/// - ISBN (Text)
|
||||
///
|
||||
/// Each entity associated with the property has a value for it.
|
||||
///
|
||||
/// \remark Values for properties are lazily created to save space.
|
||||
/// Fetching the value for some property of some entity will return the
|
||||
/// property's default value if none is specified.
|
||||
struct IkarusProperty;
|
||||
|
||||
/// \brief Flags for creating a property.
|
||||
enum IkarusPropertyCreateFlags {
|
||||
/// \brief No flags.
|
||||
IkarusPropertyCreateFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Create a new property.
|
||||
/// \param project The project to create the property in.
|
||||
/// \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.
|
||||
/// \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,
|
||||
char const * name,
|
||||
struct IkarusValueSchema * schema,
|
||||
IkarusPropertyCreateFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Flags for deleting a property.
|
||||
enum IkarusPropertyDeleteFlags {
|
||||
/// \brief No flags.
|
||||
IkarusPropertyDeleteFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Delete a property.
|
||||
/// \param property The property to delete.
|
||||
/// \param flags Flags for deleting the property.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_property_delete(
|
||||
IkarusProperty * property,
|
||||
IkarusPropertyDeleteFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Get the project a property belongs to.
|
||||
/// \param property The property to get the project of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The project the property belongs to or null if an error occurred.
|
||||
/// \remark Ownership remains with libikarus.
|
||||
IKA_API struct IkarusProject * ikarus_property_get_project(
|
||||
IkarusProperty * property,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Get the name of a property.
|
||||
/// \param property The property to get the name of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The name of the property or null if an error occurred.
|
||||
/// \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.
|
||||
IkarusPropertySetNameFlags_None = 0,
|
||||
};
|
||||
|
||||
/// \brief Set the name of a property.
|
||||
/// \param property The property to set the name of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The new name of the property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param flags Flags for setting the name of the property.
|
||||
/// \param error_out \see errors.h
|
||||
/// \remark Ownership remains with the caller.
|
||||
IKA_API void ikarus_property_set_name(
|
||||
IkarusProperty * property,
|
||||
char const * name,
|
||||
IkarusPropertySetNameFlags flags,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
/// @}
|
||||
Loading…
Add table
Add a link
Reference in a new issue