2018-06-05 23:15:23 +00:00
|
|
|
//
|
|
|
|
// Created by Antoine Bartuccio on 05/06/2018.
|
|
|
|
//
|
|
|
|
#include "Building.h"
|
2018-06-06 01:00:35 +00:00
|
|
|
|
|
|
|
GETTER(Building, Elevator **, elevators)
|
|
|
|
|
|
|
|
void _free__Building(THIS(Building)){
|
|
|
|
int i = 0;
|
|
|
|
DELETE(this->residents);
|
|
|
|
DELETE(this->box);
|
|
|
|
for (i=0; i<ELEVATOR_NB; i++)
|
|
|
|
DELETE(this->elevators[i]);
|
|
|
|
free(this->elevators);
|
|
|
|
|
|
|
|
free(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
Building *_init_Building(){
|
|
|
|
Building * new_building = malloc_or_die(sizeof(Building));
|
|
|
|
int i;
|
|
|
|
|
|
|
|
new_building->floors = FLOORS;
|
|
|
|
new_building->elevators = malloc_or_die(sizeof(Elevator*) * ELEVATOR_NB);
|
|
|
|
new_building->residents = NEW(List);
|
|
|
|
new_building->box = NEW(CommunicationBox);
|
|
|
|
for (i=0; i<ELEVATOR_NB; i++)
|
|
|
|
new_building->elevators[i] = NEW(Elevator);
|
|
|
|
|
|
|
|
|
|
|
|
LINK_ALL(Building, new_building,
|
|
|
|
get_elevators
|
|
|
|
)
|
|
|
|
|
|
|
|
return new_building;
|
|
|
|
}
|