2024-12-09 19:27:50 +01:00
|
|
|
#ifndef PLANNER
|
|
|
|
#define PLANNER
|
2024-12-11 01:08:31 +01:00
|
|
|
#include <stdint.h>
|
2024-12-10 22:06:49 +01:00
|
|
|
#include <time.h>
|
|
|
|
|
2024-12-11 01:08:31 +01:00
|
|
|
/*
|
|
|
|
* task subject struct used to track different tasks
|
|
|
|
* create new task with taskNew(name, time_t created, time_t deadline, int
|
|
|
|
* priority, uint64_t spare)
|
|
|
|
*
|
|
|
|
* should be freed by user
|
|
|
|
*
|
|
|
|
* used to interface with human and store data
|
|
|
|
*/
|
|
|
|
typedef struct Task {
|
2024-12-10 22:06:49 +01:00
|
|
|
char *name;
|
|
|
|
time_t created;
|
|
|
|
time_t deadline;
|
|
|
|
int priority;
|
2024-12-11 01:08:31 +01:00
|
|
|
uint64_t spare;
|
|
|
|
} Task;
|
2024-12-10 22:06:49 +01:00
|
|
|
|
2024-12-11 01:08:31 +01:00
|
|
|
/*
|
|
|
|
* allocates and returns Task (free after use)
|
|
|
|
* returns NULL on failure
|
|
|
|
*/
|
|
|
|
Task *newTask(char *n, time_t c, time_t d, int p, uint64_t sp);
|
|
|
|
|
2024-12-11 03:51:32 +01:00
|
|
|
/*
|
|
|
|
* compare function for Task
|
|
|
|
*/
|
2024-12-11 03:09:54 +01:00
|
|
|
int cmpTask(Task *a, Task *b);
|
|
|
|
|
2024-12-11 01:08:31 +01:00
|
|
|
/*
|
|
|
|
* Event struct contains task and planned time frame
|
|
|
|
*
|
|
|
|
* used to create timetable
|
|
|
|
*
|
|
|
|
* eventNew(task, start, end, spare)
|
|
|
|
*
|
|
|
|
*/
|
2024-12-10 22:06:49 +01:00
|
|
|
typedef struct Event {
|
2024-12-11 01:08:31 +01:00
|
|
|
Task *task;
|
2024-12-10 22:06:49 +01:00
|
|
|
time_t plannedStartTime;
|
|
|
|
time_t plannedEndTime;
|
2024-12-11 01:08:31 +01:00
|
|
|
uint64_t spare; // spare var
|
2024-12-10 22:06:49 +01:00
|
|
|
} Event;
|
2024-12-11 01:08:31 +01:00
|
|
|
/*
|
|
|
|
* allocates and returns Event (free after use)
|
|
|
|
* returns NULL on failure
|
|
|
|
*/
|
|
|
|
Event *newEvent(Task *t, time_t s, time_t e, uint64_t sp);
|
2024-12-11 03:51:32 +01:00
|
|
|
/*
|
|
|
|
* compare function for Event
|
|
|
|
*/
|
2024-12-11 03:09:54 +01:00
|
|
|
int cmpEvent(Event *a, Event *b);
|
2024-12-10 22:06:49 +01:00
|
|
|
|
2024-12-11 01:08:31 +01:00
|
|
|
int genPlan(Task *head);
|
2024-12-09 19:27:50 +01:00
|
|
|
|
|
|
|
#endif // !PLANNER
|