simworld/common/include/entity/registry.h

63 lines
1.2 KiB
C

#ifndef ENTITY_REGISTRY_H
#define ENTITY_REGISTRY_H
#include <stdlib.h>
#include <jansson.h>
#include "error.h"
struct entity_registrant_t {
char const *name;
char tile;
};
enum error_t entity_registrant_init(
struct entity_registrant_t *,
char const *, char
);
void entity_registrant_free(struct entity_registrant_t *);
struct entity_registry_t {
struct entity_registrant_t *entities;
size_t size;
};
void entity_registry_init(struct entity_registry_t *);
void entity_registry_free(struct entity_registry_t *);
enum error_t entity_registry_serialise(
struct entity_registry_t const *,
struct json_t **
);
enum error_t entity_registry_deserialise(
struct entity_registry_t *,
struct json_t *
);
enum error_t entity_registry_resize(struct entity_registry_t *, size_t);
void entity_registry_set(
struct entity_registry_t *,
struct entity_registrant_t const *,
size_t
);
enum error_t entity_registry_try_set(
struct entity_registry_t *,
struct entity_registrant_t const *,
size_t
);
enum error_t entity_registry_append(
struct entity_registry_t *,
struct entity_registrant_t const *
);
#endif