Implemented the ObjectStore functionality.
This commit is contained in:
1 parent
20f476c4ab
commit
a0e76bc1fc
4 files changed
+259
-21
No files matched your search
+11
-1
@@ -1,13 +1,23 @@
|
||||
#ifndef HASHMAP_H
|
||||
#define HASHMAP_H
|
||||
|
||||
#include "engine_build_config.h"
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef DEBUG_ENGINE
|
||||
#include <stdio.h>
|
||||
#endif /* DEBUG_ENGINE */
|
||||
|
||||
void init_hashmap();
|
||||
int32_t add_object_to_map(const char *key);
|
||||
int32_t get_object_index(const char *key);
|
||||
void delete_object_from_map(const char *key);
|
||||
int32_t delete_object_from_map(const char *key);
|
||||
void destroy_hashmap();
|
||||
|
||||
#ifdef DEBUG_ENGINE
|
||||
void print_hashmap();
|
||||
void print_non_empty();
|
||||
#endif // DEBUG_ENGINE
|
||||
|
||||
#endif // !HASHMAP_H
|
||||
+11
-4
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "Renderer.h"
|
||||
#include "SDL_events.h"
|
||||
#include "engine_build_config.h"
|
||||
|
||||
typedef void (*EventHandlerPtr)(const SDL_Event *event, void *object);
|
||||
typedef void (*UpdateFuncPtr)(float delta, void *object);
|
||||
@@ -10,12 +11,18 @@ typedef void (*RenderFuncPtr)(Renderer *renderer, void *object);
|
||||
|
||||
typedef struct object_store ObjectStore;
|
||||
|
||||
void add_object_to_store(ObjectStore *os, const char *object_tag,
|
||||
ObjectStore *create_object_store();
|
||||
void add_object_to_store(ObjectStore *os, void *object, const char *object_tag,
|
||||
EventHandlerPtr eh, UpdateFuncPtr uf,
|
||||
RenderFuncPtr rf);
|
||||
void handle_all_object_events(ObjectStore *os);
|
||||
void update_all_objects(ObjectStore *os);
|
||||
void render_all_objects(ObjectStore *os);
|
||||
void remove_object_from_store(ObjectStore *os, const char *object_tag);
|
||||
void handle_all_objects_events(ObjectStore *os, const SDL_Event *event);
|
||||
void update_all_objects(ObjectStore *os, float delta);
|
||||
void render_all_objects(ObjectStore *os, Renderer *renderer);
|
||||
void destroy_object_store(ObjectStore *os);
|
||||
|
||||
#ifdef DEBUG_ENGINE
|
||||
void print_objects();
|
||||
#endif /* DEBUG_ENGINE */
|
||||
|
||||
#endif // !OBJECT_STORE_H
|
||||
Reference in new issue
Block a user