Create config parser and read config from file
This commit is contained in:
19
rotagen.h
19
rotagen.h
@@ -3,7 +3,12 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#define MAX_JOBS 8
|
||||
#define MAX_PEOPLE 32
|
||||
#define MAX_JOBS 32
|
||||
#define MAX_SLOTS 32
|
||||
#define MAX_CONSTRAINTS 32
|
||||
|
||||
#define MAX_STRING_LEN 32
|
||||
|
||||
enum constraint_type {
|
||||
JOB_EXEMPTION_CONSTRAINT,
|
||||
@@ -29,7 +34,18 @@ struct slot_result {
|
||||
struct assignment assignments[MAX_JOBS];
|
||||
};
|
||||
|
||||
typedef char string[MAX_STRING_LEN];
|
||||
|
||||
struct config {
|
||||
string people[MAX_PEOPLE];
|
||||
int num_people;
|
||||
string jobs[MAX_JOBS];
|
||||
int num_jobs;
|
||||
string slots[MAX_SLOTS];
|
||||
int num_slots;
|
||||
struct constraint constraints[MAX_CONSTRAINTS];
|
||||
int num_constraints;
|
||||
};
|
||||
|
||||
void generate_rota(struct slot_result *rota_out);
|
||||
void generate_assignment(int slot, int job, struct assignment *assignment_out);
|
||||
@@ -37,5 +53,6 @@ bool satisfies_assignment_constraints(const struct assignment *assignment);
|
||||
bool previously_allocated(int previous_assignments[MAX_JOBS], int person);
|
||||
bool satisfies_slot_constraints(const struct slot_result *slot);
|
||||
void print_rota(const struct slot_result *rota);
|
||||
void read_config(const char *path, struct config *config_out);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user