add src/ikarus subdir and make names unique for objects per scope
Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
parent
70fca82425
commit
dc8b7712b0
51 changed files with 590 additions and 735 deletions
|
|
@ -1,6 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
/// \file global.h
|
||||
/// \file errors.h
|
||||
/// \author Folling <folling@ikarus.world>
|
||||
|
||||
#include <ikarus/macros.h>
|
||||
|
|
@ -92,6 +92,7 @@ enum IkarusErrorInfo {
|
|||
IkarusErrorInfo_LibIkarus_Timeout = 0x06000003,
|
||||
};
|
||||
|
||||
/// \brief The maximum length of an error message.
|
||||
size_t const IKARUS_ERROR_DATA_MAX_MESSAGE_LIMIT = 128;
|
||||
|
||||
/// \brief The data stored for an error
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
#include <ikarus/objects/object_type.h>
|
||||
#include <ikarus/stdtypes.h>
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \defgroup id Ids
|
||||
/// \brief Ids are used to identify objects in the database.
|
||||
/// \details They are stored as 64 bit integers with the following layout:
|
||||
|
|
@ -22,6 +20,8 @@ IKARUS_BEGIN_HEADER
|
|||
/// - last 56 bits: incremented counter generated by the database
|
||||
/// @{
|
||||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
/// \brief A wrapper around a 64 bit integer that represents the id of an object.
|
||||
/// \details They are stored as 64 bit integers with the following layout:
|
||||
/// - first bit: ignored, technically we could use it, but SQLite doesn't support u64 integers.
|
||||
|
|
@ -41,6 +41,6 @@ IKA_API IkarusId ikarus_id_from_data_and_type(int64_t data, IkarusObjectType typ
|
|||
/// \return The object type of the given id.
|
||||
IKA_API IkarusObjectType ikarus_id_get_object_type(IkarusId id);
|
||||
|
||||
/// @}
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
/// @}
|
||||
|
|
|
|||
|
|
@ -25,9 +25,9 @@ struct IkarusBlueprint;
|
|||
/// \param name The name of the blueprint.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \pre \li Must be unique among all blueprints in the project.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The created blueprint or null if an error occurs.
|
||||
/// \remark Must be freed using #ikarus_free.
|
||||
IKA_API IkarusBlueprint * ikarus_blueprint_create(struct IkarusProject * project, char const * name, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Deletes & frees a blueprint.
|
||||
|
|
@ -38,6 +38,33 @@ IKA_API IkarusBlueprint * ikarus_blueprint_create(struct IkarusProject * project
|
|||
/// \remark The blueprint must not be accessed after deletion.
|
||||
IKA_API void ikarus_blueprint_delete(IkarusBlueprint * 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 the blueprint is part of 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 of the blueprint 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.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \pre \li Must be unique among all blueprints in the project.
|
||||
/// \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.
|
||||
|
|
@ -86,18 +113,6 @@ IKA_API void ikarus_blueprint_get_linked_entities(
|
|||
/// \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);
|
||||
|
||||
/// \brief Casts a blueprint to an object.
|
||||
/// \param blueprint The blueprint to cast.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The blueprint represented as an object or null if an error occurs.
|
||||
/// \remark This operation is guaranteed to be very fast and is intended to be used frequently.
|
||||
IKA_API struct IkarusObject * ikarus_blueprint_to_object(IkarusBlueprint * blueprint, IkarusErrorData * error_out);
|
||||
|
||||
/// \see ikarus_blueprint_to_object
|
||||
IKA_API struct IkarusObject const * ikarus_blueprint_to_object_const(IkarusBlueprint const * blueprint, IkarusErrorData * error_out);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
// @}
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ struct IkarusEntity;
|
|||
/// \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.
|
||||
/// \remark Must be freed using #ikarus_free.
|
||||
IKA_API IkarusEntity * ikarus_entity_create(struct IkarusProject * project, char const * name, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Deletes an entity.
|
||||
|
|
@ -54,6 +54,33 @@ IKA_API IkarusEntity * ikarus_entity_create(struct IkarusProject * project, char
|
|||
/// \remark The entity must not be accessed after deletion.
|
||||
IKA_API void ikarus_entity_delete(IkarusEntity * entity, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the project an entity is part of.
|
||||
/// \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);
|
||||
|
||||
/// \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);
|
||||
|
||||
/// \brief Sets the name of an entity.
|
||||
/// \param entity The entity to set the name of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \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);
|
||||
|
||||
/// \brief Checks if an entity is linked to a blueprint.
|
||||
/// \param entity The entity to check.
|
||||
/// \pre \li Must not be null.
|
||||
|
|
@ -182,18 +209,6 @@ IKA_API void ikarus_entity_set_value(
|
|||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Casts an entity to an object.
|
||||
/// \param entity The entity to cast.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The entity represented as an object or null if an error occurs.
|
||||
/// \remark This operation is guaranteed to be very fast and is intended to be used frequently.
|
||||
IKA_API struct IkarusObject * ikarus_entity_to_object(IkarusEntity * entity, IkarusErrorData * error_out);
|
||||
|
||||
/// \see ikarus_entity_to_object
|
||||
IKA_API struct IkarusObject const * ikarus_entity_to_object_const(IkarusEntity const * entity, IkarusErrorData * error_out);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
// @}
|
||||
|
|
|
|||
|
|
@ -19,62 +19,6 @@ IKARUS_BEGIN_HEADER
|
|||
/// \brief A generic object. Wraps all types of objects, including folders.
|
||||
struct IkarusObject;
|
||||
|
||||
/// \brief Fetches the project of an object.
|
||||
/// \param object The object to fetch the project from.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The project of the object or null if an error occurs.
|
||||
IKA_API struct IkarusProject * ikarus_object_get_project(IkarusObject const * object, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Fetches the name of an object.
|
||||
/// \param object The object to fetch the name from.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The name of the object or null if an error occurs.
|
||||
IKA_API char const * ikarus_object_get_name(IkarusObject const * object, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Sets the name of an object.
|
||||
/// \param object The object to set the name of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param new_name The new name of the object.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_object_set_name(IkarusObject const * object, char const * new_name, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Fetches the information of an object.
|
||||
/// \param object The object to fetch the information from.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The information of the object or null if an error occurs.
|
||||
IKA_API char const * ikarus_object_get_info(IkarusObject const * object, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Sets the information of an object.
|
||||
/// \param object The object to set the information of.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param new_info The new information of the object.
|
||||
/// \pre \li Must not be null.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_object_set_info(IkarusObject const * object, char const * new_info, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Compares two objects for equality.
|
||||
/// \details This neither compares the pointers nor does a deep copy. Instead it figures out if the objects _are_ the
|
||||
/// same object.
|
||||
/// \param lhs The left hand side object.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param rhs The right hand side object.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return True if the objects are equal, false otherwise.
|
||||
IKA_API bool ikarus_object_is_equal(IkarusObject const * lhs, IkarusObject const * rhs, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Visits an object. Calling the appropriate function for the object's type.
|
||||
/// \param object The object to visit.
|
||||
/// \param blueprint_visitor The function to call if the object is a blueprint. Skipped if null.
|
||||
|
|
@ -84,9 +28,9 @@ IKA_API bool ikarus_object_is_equal(IkarusObject const * lhs, IkarusObject const
|
|||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_object_visit(
|
||||
IkarusObject * object,
|
||||
void (*blueprint_visitor)(struct IkarusBlueprint *, void *),
|
||||
void (*property_visitor)(struct IkarusProperty *, void *),
|
||||
void (*entity_visitor)(struct IkarusEntity *, void *),
|
||||
void (*blueprint_visitor)(struct IkarusBlueprint *, IkarusErrorData * error_out, void *),
|
||||
void (*property_visitor)(struct IkarusProperty *, IkarusErrorData * error_out, void *),
|
||||
void (*entity_visitor)(struct IkarusEntity *, IkarusErrorData * error_out, void *),
|
||||
void * data,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
|
@ -94,9 +38,9 @@ IKA_API void ikarus_object_visit(
|
|||
/// \see ikarus_object_visit
|
||||
IKA_API void ikarus_object_visit_const(
|
||||
IkarusObject const * object,
|
||||
void (*blueprint_visitor)(struct IkarusBlueprint const *, void *),
|
||||
void (*property_visitor)(struct IkarusProperty const *, void *),
|
||||
void (*entity_visitor)(struct IkarusEntity const *, void *),
|
||||
void (*blueprint_visitor)(struct IkarusBlueprint const *, IkarusErrorData * error_out, void *),
|
||||
void (*property_visitor)(struct IkarusProperty const *, IkarusErrorData * error_out, void *),
|
||||
void (*entity_visitor)(struct IkarusEntity const *, IkarusErrorData * error_out, void *),
|
||||
void * data,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,6 @@ IKA_API void ikarus_property_delete(IkarusProperty * property, IkarusErrorData *
|
|||
/// \pre \li Must exist.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The type info of the property or null if an error occurs.
|
||||
/// \remark Must be freed using #ikarus_free.
|
||||
IKA_API IkarusPropertyType ikarus_property_get_type(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the source of a property.
|
||||
|
|
@ -80,7 +79,7 @@ IKA_API IkarusPropertyType ikarus_property_get_type(IkarusProperty const * prope
|
|||
/// \param error_out \see errors.h
|
||||
/// \return The source of the property or null if an error occurs.
|
||||
/// \remark Must be freed using #ikarus_free.
|
||||
IKA_API struct IkarusPropertySource const * ikarus_property_get_source(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
IKA_API struct IkarusPropertyScope const * ikarus_property_get_scope(IkarusProperty const * property, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the default value of a property.
|
||||
/// \param property The property to get the type info of.
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
IKARUS_BEGIN_HEADER
|
||||
|
||||
struct IkarusPropertySource;
|
||||
struct IkarusPropertyScope;
|
||||
|
||||
/// \brief Creates an blueprint property source.
|
||||
/// \param blueprint The blueprint to create the property source for.
|
||||
|
|
@ -20,7 +20,7 @@ struct IkarusPropertySource;
|
|||
/// \param error_out \see errors.h
|
||||
/// \return The created property source or null if an error occurs.
|
||||
/// \remark Must be freed using #ikarus_free.
|
||||
IKA_API struct IkarusPropertySource *
|
||||
IKA_API struct IkarusPropertyScope *
|
||||
ikarus_property_source_create_blueprint(struct IkarusBlueprint * blueprint, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Creates an entity property source.
|
||||
|
|
@ -30,7 +30,7 @@ ikarus_property_source_create_blueprint(struct IkarusBlueprint * blueprint, Ikar
|
|||
/// \param error_out \see errors.h
|
||||
/// \return The created property source or null if an error occurs.
|
||||
/// \remark Must be freed using #ikarus_free.
|
||||
IKA_API struct IkarusPropertySource * ikarus_property_source_create_entity(struct IkarusEntity * entity, IkarusErrorData * error_out);
|
||||
IKA_API struct IkarusPropertyScope * ikarus_property_source_create_entity(struct IkarusEntity * entity, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Visits a property source, calling the appropriate callback.
|
||||
/// \param property_source The property source to visit.
|
||||
|
|
@ -41,7 +41,7 @@ IKA_API struct IkarusPropertySource * ikarus_property_source_create_entity(struc
|
|||
/// \param user_data User data to pass to the callbacks.
|
||||
/// \param error_out \see errors.h
|
||||
IKA_API void ikarus_property_source_visit(
|
||||
struct IkarusPropertySource * property_source,
|
||||
struct IkarusPropertyScope * property_source,
|
||||
void (*blueprint_visitor)(struct IkarusBlueprint *, void *),
|
||||
void (*entity_visitor)(struct IkarusEntity *, void *),
|
||||
void * user_data,
|
||||
|
|
@ -50,7 +50,7 @@ IKA_API void ikarus_property_source_visit(
|
|||
|
||||
/// \see ikarus_property_source_visit
|
||||
IKA_API void ikarus_property_source_visit_const(
|
||||
struct IkarusPropertySource const * property_source,
|
||||
struct IkarusPropertyScope const * property_source,
|
||||
void (*blueprint_visitor)(struct IkarusBlueprint const *, void *),
|
||||
void (*entity_visitor)(struct IkarusEntity const *, void *),
|
||||
void * user_data,
|
||||
|
|
@ -80,29 +80,6 @@ IKA_API void ikarus_project_set_name(IkarusProject * project, char const * new_n
|
|||
/// \remark Ownership remains with libikarus, must not be freed.
|
||||
IKA_API char const * ikarus_project_get_path(IkarusProject const * project, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the blueprints of a project.
|
||||
/// \param project The project 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 error_out \see errors.h
|
||||
IKA_API void ikarus_project_get_blueprints(
|
||||
IkarusProject * project,
|
||||
struct IkarusBlueprint ** blueprints_out,
|
||||
size_t blueprints_out_size,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the number of blueprints of a project.
|
||||
/// \param project The project to get the number of 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_project_get_blueprint_count(IkarusProject const * project, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the entities of a project.
|
||||
/// \param project The project to get the entities of.
|
||||
/// \pre \li Must not be null.
|
||||
|
|
@ -126,6 +103,71 @@ IKA_API void ikarus_project_get_entities(
|
|||
/// \return The number of entities or undefined if an error occurs.
|
||||
IKA_API size_t ikarus_project_get_entity_count(IkarusProject * project, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Gets the blueprints of a project.
|
||||
/// \param project The project 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 error_out \see errors.h
|
||||
IKA_API void ikarus_project_get_blueprints(
|
||||
IkarusProject * project,
|
||||
struct IkarusBlueprint ** blueprints_out,
|
||||
size_t blueprints_out_size,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Gets the number of blueprints of a project.
|
||||
/// \param project The project to get the number of 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_project_get_blueprint_count(IkarusProject const * project, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Finds an entity by a given name.
|
||||
/// \param project The project to search.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name to search for.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The entity with the given name or null if none was found.
|
||||
IKA_API struct IkarusEntity* get_entity_by_name(
|
||||
IkarusProject const * project,
|
||||
char const * name,
|
||||
IkarusErrorData * error_out
|
||||
);
|
||||
|
||||
/// \brief Finds a property by a given name.
|
||||
/// \param project The project to search.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param scope The scope of the property.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \remark Property names are unique only within their scope.
|
||||
/// \param name The name to search for.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The property with the given name or null if none was found.
|
||||
IKA_API struct IkarusProperty *
|
||||
get_property_by_name(IkarusProject const * project, struct IkarusPropertyScope * scope, char const * name, IkarusErrorData * error_out);
|
||||
|
||||
/// \brief Finds a blueprint by a given name.
|
||||
/// \param project The project to search.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must exist.
|
||||
/// \param name The name to search for.
|
||||
/// \pre \li Must not be null.
|
||||
/// \pre \li Must not be empty.
|
||||
/// \param error_out \see errors.h
|
||||
/// \return The blueprint with the given name or null if none was found.
|
||||
IKA_API struct IkarusBlueprint * get_blueprints_by_name(IkarusProject const * project, char const * name, IkarusErrorData * error_out);
|
||||
|
||||
IKARUS_END_HEADER
|
||||
|
||||
/// @}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue