@@ -432,6 +432,16 @@ typedef struct ecs_type_hooks_t ecs_type_hooks_t;
432
432
* alignment and type hooks. */
433
433
typedef struct ecs_type_info_t ecs_type_info_t ;
434
434
435
+ /** Cached Type information.
436
+ * Contains information about a component type, such as its id, size and alignment */
437
+ typedef struct ecs_cached_component_info_t ecs_cached_component_info_t ;
438
+
439
+ /** An index to a cached component id information.
440
+ * Can be used to map a typed component from object-oriented language
441
+ * fast to a dynamically-per-world generated component id.
442
+ * Components are resolved by name lookup and subsequently cached. */
443
+ typedef int32_t ecs_component_cache_index_t ;
444
+
435
445
/** Information about an entity, like its table and row. */
436
446
typedef struct ecs_record_t ecs_record_t ;
437
447
@@ -864,6 +874,16 @@ struct ecs_type_info_t {
864
874
const char * name ; /**< Type name. */
865
875
};
866
876
877
+ /** Type that contains cache component information
878
+ *
879
+ * \ingroup components
880
+ */
881
+ struct ecs_cached_component_info_t {
882
+ ecs_entity_t component ; /**< Handle to component */
883
+ ecs_size_t size ; /**< Size of type */
884
+ ecs_size_t alignment ; /**< Alignment of type */
885
+ };
886
+
867
887
#include "flecs/private/api_types.h" /* Supporting API types */
868
888
#include "flecs/private/api_support.h" /* Supporting API functions */
869
889
#include "flecs/private/vec.h" /* Vector */
@@ -3690,6 +3710,38 @@ const ecs_type_hooks_t* ecs_get_hooks_id(
3690
3710
ecs_world_t * world ,
3691
3711
ecs_entity_t id );
3692
3712
3713
+ /** Get the cached information for a specific component cache index.
3714
+ *
3715
+ * @param world The world.
3716
+ * @param component_cache_index The component cache index to lookup.
3717
+ * @return The cached component info for the specific component, always returns a present entry.
3718
+ */
3719
+ FLECS_API
3720
+ ecs_cached_component_info_t * ecs_get_or_create_cached_component_info (
3721
+ ecs_world_t * world ,
3722
+ ecs_component_cache_index_t component_cache_index );
3723
+
3724
+ /** Get the valid cached information for a specific component cache index.
3725
+ *
3726
+ * @param world The world.
3727
+ * @param component_cache_index The component cache index to lookup.
3728
+ * @return The valid cached component info for the specific component or NULL if invalid.
3729
+ */
3730
+ FLECS_API
3731
+ const ecs_cached_component_info_t * ecs_lookup_cached_component_info (
3732
+ const ecs_world_t * world ,
3733
+ ecs_component_cache_index_t component_cache_index );
3734
+
3735
+
3736
+ /** Test if the cached component info is valid (set)
3737
+ *
3738
+ * @param component_info The component cache index to lookup.
3739
+ * @return True if the info is valid.
3740
+ */
3741
+ FLECS_API
3742
+ bool ecs_is_cached_component_info_valid (
3743
+ const ecs_cached_component_info_t * component_info );
3744
+
3693
3745
/** @} */
3694
3746
3695
3747
/**
0 commit comments