manager.h revision 6091827530d6dd43479d6709fb6e9f745c11e900
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync/*-*- Mode: C; c-basic-offset: 8 -*-*/
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#ifndef foomanagerhfoo
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#define foomanagerhfoo
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <stdbool.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include <inttypes.h>
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsynctypedef struct Manager Manager;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include "name.h"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include "job.h"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include "hashmap.h"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include "list.h"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#include "set.h"
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncstruct Manager {
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync uint32_t current_job_id;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /* Active jobs and names */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync Hashmap *names; /* name string => Name object n:1 */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync Hashmap *jobs; /* job id => Job object 1:1 */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /* Names that need to be loaded */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync LIST_HEAD(Meta, load_queue); /* this is actually more a stack than a queue, but uh. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync /* Jobs to be added resp. removed. */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync Hashmap *jobs_to_add; /* Name object => Job object 1:1 */
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync Set *jobs_to_remove;
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync};
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncManager* manager_new(void);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncvoid manager_free(Manager *m);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncJob *manager_get_job(Manager *m, uint32_t id);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncName *manager_get_name(Manager *m, const char *name);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncint manager_load_name(Manager *m, const char *name, Name **_ret);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsyncint manager_add_job(Manager *m, JobType job, Name *name, JobMode mode, Job **_ret);
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync#endif
14ea49401f3c8c61422aefbda43809e275f60c6cvboxsync