Flecs: include/flecs/addons/rest.h Source File
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.1 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
rest.h
Go to the documentation of this file.
1
10
11#ifdef FLECS_REST
12
20
21/* Used for the HTTP server */
22#ifndef FLECS_HTTP
23#define FLECS_HTTP
24#endif
25
26/* Used for building the JSON replies */
27#ifndef FLECS_JSON
28#define FLECS_JSON
29#endif
30
31/* For the REST system */
32#ifndef FLECS_PIPELINE
33#define FLECS_PIPELINE
34#endif
35
36#ifndef FLECS_REST_H
37#define FLECS_REST_H
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
44#define ECS_REST_DEFAULT_PORT (27750)
45
47FLECS_API extern const ecs_entity_t ecs_id(EcsRest);
48
50 typedef struct {
51 ecs_world_t *world;
52 ecs_http_server_t *srv;
53 int32_t rc;
54 ecs_map_t cmd_captures;
55 double last_time;
56} ecs_rest_ctx_t;
57
59 typedef struct {
60 uint16_t port;
61 char *ipaddr;
62 ecs_rest_ctx_t *impl;
63} EcsRest;
64
73FLECS_API
74 ecs_http_server_t* ecs_rest_server_init(
75 ecs_world_t *world,
76 const ecs_http_server_desc_t *desc);
77
83FLECS_API
84 void ecs_rest_server_fini(
85 ecs_http_server_t *srv);
86
95FLECS_API
96 void FlecsRestImport(
97 ecs_world_t *world);
98
99#ifdef __cplusplus
100}
101#endif
102
103#endif
104
106
107#endif
ecs_http_server_t
struct ecs_http_server_t ecs_http_server_t
HTTP server.
Definition http.h:48
ecs_rest_server_init
FLECS_API ecs_http_server_t * ecs_rest_server_init(ecs_world_t *world, const ecs_http_server_desc_t *desc)
Create HTTP server for REST API.
ecs_id
FLECS_API const ecs_entity_t ecs_id(EcsRest)
Component that instantiates the REST API.
ecs_rest_server_fini
FLECS_API void ecs_rest_server_fini(ecs_http_server_t *srv)
Clean up REST HTTP server.
FlecsRestImport
FLECS_API void FlecsRestImport(ecs_world_t *world)
REST module import function.
ecs_entity_t
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:381
ecs_world_t
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:425
EcsRest
Component that creates a REST API server when instantiated.
Definition rest.h:59
EcsRest::port
uint16_t port
Port of server (optional, default = 27750).
Definition rest.h:60
EcsRest::ipaddr
char * ipaddr
Interface address (optional, default = 0.0.0.0).
Definition rest.h:61
EcsRest::impl
ecs_rest_ctx_t * impl
Private implementation data.
Definition rest.h:62
ecs_http_server_desc_t
Used with ecs_http_server_init().
Definition http.h:124
ecs_rest_ctx_t
Private REST data.
Definition rest.h:50
ecs_rest_ctx_t::rc
int32_t rc
Reference count.
Definition rest.h:53
ecs_rest_ctx_t::srv
ecs_http_server_t * srv
HTTP server instance.
Definition rest.h:52
ecs_rest_ctx_t::last_time
double last_time
Last processing time.
Definition rest.h:55
ecs_rest_ctx_t::world
ecs_world_t * world
The world.
Definition rest.h:51
ecs_rest_ctx_t::cmd_captures
ecs_map_t cmd_captures
Map of command captures.
Definition rest.h:54