1
0
mirror of https://gitlab.com/klmp200/LO41.git synced 2024-11-15 05:13:22 +00:00
LO41/Elevator/Elevator.h

47 lines
1.3 KiB
C
Raw Normal View History

//
// Created by Antoine Bartuccio on 05/06/2018.
//
#ifndef LO41_ELEVATOR_H
#define LO41_ELEVATOR_H
#include <pthread.h>
#include "../Objects.h"
#include "../List/List.h"
#include "../Passenger/Passenger.h"
2018-06-15 09:50:38 +00:00
//#define MAX_ELEVATOR_CAPACITY 10
#define MAX_ELEVATOR_CAPACITY 3
2018-06-15 09:50:38 +00:00
typedef enum {RUNNING, WAITING, SLEEPING, BROKEN} ELEVATOR_STATE;
typedef struct o_Elevator {
PRIVATE ELEVATOR_STATE state;
PRIVATE List * passengers;
PRIVATE char * name;
2018-06-10 02:00:01 +00:00
PRIVATE int floor;
PRIVATE pthread_mutex_t mutex_passenger;
PRIVATE pthread_mutex_t mutex_state;
2018-06-10 02:00:01 +00:00
PRIVATE pthread_mutex_t mutex_floor;
PUBLIC void * (*runnable)(void * void_this);
SYNCHRONIZE PRIVATE void (*set_state)(_THIS(Elevator), ELEVATOR_STATE var);
SYNCHRONIZE PRIVATE void (*set_floor)(_THIS(Elevator), int var);
SYNCHRONIZE PUBLIC void (*repair)(_THIS(Elevator));
SYNCHRONIZE PUBLIC int (*get_number_of_passengers)(_THIS(Elevator));
2018-06-18 14:09:28 +00:00
SYNCHRONIZE PUBLIC void (*add_passenger)(_THIS(Elevator), Passenger passenger);
SYNCHRONIZE PUBLIC ELEVATOR_STATE (*get_state)(_THIS(Elevator));
2018-06-10 02:00:01 +00:00
SYNCHRONIZE PUBLIC int (*get_floor)(_THIS(Elevator));
2018-06-15 13:38:26 +00:00
SYNCHRONIZE PUBLIC int (*can_get_inside)(_THIS(Elevator), int floor);
2018-06-06 01:00:35 +00:00
DESTRUCTOR(Elevator);
} Elevator;
FRIENDLY(state, Building)
Elevator *_init_Elevator(char* name);
2018-06-06 01:00:35 +00:00
#endif //LO41_ELEVATOR_H