finalise interface & documentation

Signed-off-by: Folling <mail@folling.io>
This commit is contained in:
folling 2023-11-06 13:14:39 +01:00 committed by Folling
parent c5157bd849
commit 52580a4382
Signed by: folling
SSH key fingerprint: SHA256:S9qEx5WCFFLK49tE/LKnKuJYM5sw+++Dn6qJbbyxnCY
56 changed files with 2074 additions and 780 deletions

View file

@ -3,12 +3,9 @@
// IMPLEMENTATION_DETAIL_OBJECT_SCOPES
/// \file object_scope.h
/// \author Folling <mail@folling.io>
/// \author Folling <folling@ikarus.world>
#include <ikarus/macros.h>
#include <ikarus/scopes/blueprint_scope.h>
#include <ikarus/scopes/entity_scope.h>
#include <ikarus/scopes/property_scope.h>
/// \defgroup object_scopes Object Scopes
/// \brief Scopes define where objects belong to.
@ -17,65 +14,30 @@
IKARUS_BEGIN_HEADER
/// \private \brief The data for an object scope.
union IkarusObjectScopeData {
/// \private \brief The blueprint data of the scope.
IkarusBlueprintScope _blueprint;
/// \private \brief The property data of the scope.
IkarusPropertyScope _property;
/// \private \brief The entity data of the scope.
IkarusEntityScope _entity;
};
/// \brief The scope of an object.
struct IkarusObjectScope;
/// The type of an object scope.
/// \brief The type of an object scope.
enum IkarusObjectScopeType {
/// \brief The scope is a blueprint scope.
IkarusObjectScopeType_Blueprint,
IkarusObjectScopeType_Blueprint = 1,
/// \brief The scope is a property scope.
IkarusObjectScopeType_Property,
IkarusObjectScopeType_Property = 2,
/// \brief The scope is an entity scope.
IkarusObjectScopeType_Entity
IkarusObjectScopeType_Entity = 3
};
/// \brief The scope of an object.
struct IkarusObjectScope {
/// \private \brief Represents the type of the scope.
IkarusObjectScopeType _type;
/// \private \brief Represents the data of the scope.
IkarusObjectScopeData _data;
};
/// \brief Converts a blueprint scope to an object scope.
/// \param scope The scope to convert.
/// \return The converted scope.
IKA_API IkarusObjectScope ikarus_blueprint_scope_to_object_scope(IkarusBlueprintScope scope);
/// \brief Converts a property scope to an object scope.
/// \param scope The scope to convert.
/// \return The converted scope.
IKA_API IkarusObjectScope ikarus_property_scope_to_object_scope(IkarusPropertyScope scope);
/// Converts an entity scope to an object scope.
/// \param scope The scope to convert.
/// \return The converted scope.
IKA_API IkarusObjectScope ikarus_entity_scope_to_object_scope(IkarusEntityScope scope);
/// \brief Fetches the type of an object scope.
/// \param scope The scope to fetch the type of.
/// \return The type of the scope.
IKA_API IkarusObjectScopeType ikarus_object_scope_get_type(IkarusObjectScope scope);
/// \brief Visits an object scope, calling the appropriate function.
/// \param scope The scope to visit.
/// \param blueprint The function to call if the scope is an #IkarusBlueprintScope.
/// \param property The function to call if the scope is an #IkarusPropertyScope.
/// \param entity The function to call if the scope is an #IkarusEntityScope.
/// \param blueprint_visitor The function to call if the scope is an #IkarusBlueprintScope.
/// \param property_visitor The function to call if the scope is an #IkarusPropertyScope.
/// \param entity_visitor The function to call if the scope is an #IkarusEntityScope.
/// \remark function pointers may be null in which case they are not called.
IKA_API void ikarus_object_scope_visit(
IkarusObjectScope scope,
void (*blueprint)(IkarusBlueprintScope, void *),
void (*property)(IkarusPropertyScope, void *),
void (*entity)(IkarusEntityScope, void *),
IkarusObjectScope * scope,
void (*blueprint_visitor)(struct IkarusBlueprintScope *, void *),
void (*property_visitor)(struct IkarusPropertyScope *, void *),
void (*entity_visitor)(struct IkarusEntityScope *, void *),
void * data
);