2018-06-06 18:29:02 +00:00
|
|
|
//
|
|
|
|
// Created by Antoine Bartuccio on 06/06/2018.
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "Visitor.h"
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
GETTER(Visitor, char*, name);
|
|
|
|
GETTER(Visitor, int, id);
|
|
|
|
|
|
|
|
void _free__Visitor(THIS(Visitor)){
|
|
|
|
if (this->name != NULL)
|
|
|
|
free(this->name);
|
2018-06-10 15:57:39 +00:00
|
|
|
if (this->contact_name != NULL)
|
|
|
|
free(this->contact_name);
|
2018-06-06 18:29:02 +00:00
|
|
|
free(this);
|
|
|
|
}
|
|
|
|
|
2018-06-10 15:57:39 +00:00
|
|
|
Visitor *_init_Visitor(int id, char* name, char * contact_name){
|
2018-06-06 18:29:02 +00:00
|
|
|
Visitor * new_visitor = malloc_or_die(sizeof(Visitor));
|
2018-06-06 18:33:34 +00:00
|
|
|
new_visitor->name = strdup(name);
|
2018-06-06 18:29:02 +00:00
|
|
|
new_visitor->id = id;
|
|
|
|
new_visitor->position = 0;
|
|
|
|
new_visitor->destination = -1;
|
|
|
|
|
2018-06-10 15:57:39 +00:00
|
|
|
if (contact_name != NULL)
|
|
|
|
new_visitor->contact_name = strdup(contact_name);
|
|
|
|
else
|
|
|
|
new_visitor->contact_name = NULL;
|
|
|
|
|
2018-06-06 18:29:02 +00:00
|
|
|
LINK_ALL(Visitor, new_visitor,
|
|
|
|
get_name,
|
|
|
|
get_id
|
|
|
|
);
|
|
|
|
|
|
|
|
return new_visitor;
|
|
|
|
}
|