#ifndef MT_SHADOW_H #define MT_SHADOW_H #include #include typedef struct MtShadowRegistry MtShadowRegistry; typedef struct MtShadow MtShadow; typedef struct MtShadowPool MtShadowPool; typedef struct MtShadowLookupTree MtShadowLookupTree; /// @brief: An MtShadow contains the actual information which is used /// each time when an entity is modified. It contains the tags and /// other meta-information as well as data required for optimization. struct MtShadow { void *context; MtShadowTag *tag_chain_start; uint32_t identifier; MtShadowPool *pool; MtShadow *pool_next; }; struct MtShadowPool { uint32_t capacity; MtShadow *shadows; MtShadow *first_free; MtShadowPool *continuation; }; typedef struct MtShadowLookupLevel3 { MtShadow *next[256]; } MtShadowLookupLevel3; typedef struct MtShadowLookupLevel2 { MtShadowLookupLevel3 *next[256]; } MtShadowLookupLevel2; typedef struct MtShadowLookup1 { MtShadowLookupLevel2 *next[256]; } MtShadowLookupLevel1; struct MtShadowLookupTree { MtShadowLookupLevel1 *next[256]; }; struct MtShadowRegistry { // TODO: The IDs must be assigned using a singly linked list of indices // to the next free entry, the index representing the ID's value and having // stored the next free entry's index. Conceptually similar to the internals // of the old File Allocation Table filesystems (FAT12, FAT16, FAT32). uint32_t id_counter; MtShadowPool root_pool; MtShadowLookupTree lookup_tree; void *context_ptr; }; MtShadowRegistry mt_create_shadow_registry(void *context_ptr); void mt_cleanup_shadow_registry(MtShadowRegistry *registry); MtShadow * mt_create_shadow(MtShadowRegistry *registry); MtShadow * mt_lookup_shadow(MtShadowRegistry *registry, uint32_t identifier); void mt_delete_shadow(MtShadowRegistry *registry, MtShadow *shadow); void mt_cleanup_shadow_pool(MtShadowPool *pool); void mt_free_shadow_pool(MtShadowPool *pool); MtShadowLookupTree mt_create_shadow_lookup_tree(); void mt_init_shadow_pool(MtShadowPool *pool, uint32_t capacity); MtShadowPool * mt_new_shadow_pool(uint32_t capacity); MtShadow * mt_pool_shadow(MtShadowPool *pool); void mt_unpool_shadow(MtShadow *shadow); #endif // MT_SHADOW_H