libresman
diff src/resman.h @ 5:bd9b4ff19c93
more stuff
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 01 Feb 2014 08:02:08 +0200 |
parents | 469ce01809bc |
children | 410c19c735b2 |
line diff
1.1 --- a/src/resman.h Fri Jan 31 16:32:02 2014 +0200 1.2 +++ b/src/resman.h Sat Feb 01 08:02:08 2014 +0200 1.3 @@ -1,25 +1,29 @@ 1.4 #ifndef RESOURCE_MANAGER_H_ 1.5 #define RESOURCE_MANAGER_H_ 1.6 1.7 +/* load callback: everything or just file read/parse stage 1.8 + * create callback: second-stage callback for first creation 1.9 + * update callback: second-stage callback for reload 1.10 + */ 1.11 +typedef int (*resman_load_func)(const char *fname, void *data, void *closure); 1.12 +typedef int (*resman_create_func)(void *data, void *closure); 1.13 +typedef int (*resman_update_func)(void *data, void *closure); 1.14 +typedef void (*resman_destroy_func)(void *data, void *closure); 1.15 + 1.16 struct resman; 1.17 1.18 +struct resman *resman_create(void); 1.19 +void resman_free(struct resman *rman); 1.20 + 1.21 int resman_init(struct resman *rman); 1.22 void resman_destroy(struct resman *rman); 1.23 1.24 -/* The load callback will be called to load a data file. It may be called in the 1.25 - * context of a different loading thread. 1.26 - */ 1.27 -/*void resman_set_load_func(struct resman *rman, resman_load_func_t func, void *cls);*/ 1.28 +void resman_set_load_func(struct resman *rman, resman_load_func func, void *cls); 1.29 +void resman_set_create_func(struct resman *rman, resman_create_func func, void *cls); 1.30 +void resman_set_update_func(struct resman *rman, resman_update_func func, void *cls); 1.31 +void resman_set_destroy_func(struct resman *rman, resman_destroy_func func, void *cls); 1.32 1.33 -/* The "done" callback will be called in the context of the main thread, whenever a 1.34 - * file was sucessfully loaded, or an error occured. 1.35 - * It's first argument (status) is set to whatever the load function returned, and its 1.36 - * closure pointer is the closure ... 1.37 - */ 1.38 -/*void resman_set_done_func(struct resman *rman, resman_done_func_t func);*/ 1.39 - 1.40 - 1.41 -int resman_lookup(struct resman *rman, const char *fname, void *cls); 1.42 +int resman_lookup(struct resman *rman, const char *fname, void *data); 1.43 void resman_wait(struct resman *rman, int id); 1.44 1.45 int resman_poll(struct resman *rman);