#ifndef storage_h_INCLUDED #define storage_h_INCLUDED #include #include #ifndef MAX_OBJECTS #define MAX_OBJECTS 4096 #endif #ifndef MAX_COMPONENTS #define MAX_COMPONENTS 32 #endif #define BITSET_BYTES (MAX_COMPONENTS / 8) #include "bitset.h" #define GET_COMPONENT(storage, componentType, idx) (componentType *) internal_getComponent(storage, idx, #componentType) #define REGISTER_COMPONENT(storage, componentType) internal_registerComponent(storage, #componentType, sizeof(componentType)) #define ADD_COMPONENT(storage, idx, componentType) internal_addComponent(storage, idx, #componentType) typedef unsigned int entity_t; typedef struct { const char *name; size_t objectSize; char *objects; } component_pair_t; typedef struct { unsigned int componentsStored; unsigned int objectsStored; component_pair_t *objects; bitarena_t objectSignatures; } storage_t; component_pair_t * // NULL if pair is not found findPair(storage_t *this, const char *name); entity_t createEntity(storage_t *this); // Not intended for use outside of macros void internal_registerComponent(storage_t *storage, const char *name, size_t size); // Not intended for use outside of macros void * // NULL if component with such name is not found internal_addComponent(storage_t *this, entity_t idx, const char *name); // Not intended for use outside of macros void * // NULL if component is not found internal_getComponent(storage_t *this, entity_t idx, const char *name); #endif // storage_h_INCLUDED