mirror of
https://gitlab.com/klmp200/LO41.git
synced 2025-07-10 19:59:24 +00:00
La structure du projet avance, on peut maintenant charger les résidents et les visiteurs
This commit is contained in:
33
Visitor/Visitor.c
Normal file
33
Visitor/Visitor.c
Normal file
@ -0,0 +1,33 @@
|
||||
//
|
||||
// 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);
|
||||
free(this);
|
||||
}
|
||||
|
||||
Visitor *_init_Visitor(int id, char* name){
|
||||
Visitor * new_visitor = malloc_or_die(sizeof(Visitor));
|
||||
size_t len = strlen(name);
|
||||
new_visitor->name = malloc_or_die(sizeof(char) * len);
|
||||
strcpy(new_visitor->name, name);
|
||||
new_visitor->id = id;
|
||||
new_visitor->contact_id = -1;
|
||||
new_visitor->position = 0;
|
||||
new_visitor->destination = -1;
|
||||
|
||||
LINK_ALL(Visitor, new_visitor,
|
||||
get_name,
|
||||
get_id
|
||||
);
|
||||
|
||||
return new_visitor;
|
||||
}
|
27
Visitor/Visitor.h
Normal file
27
Visitor/Visitor.h
Normal file
@ -0,0 +1,27 @@
|
||||
//
|
||||
// Created by Antoine Bartuccio on 06/06/2018.
|
||||
//
|
||||
|
||||
#ifndef LO41_VISITOR_H
|
||||
#define LO41_VISITOR_H
|
||||
|
||||
#include "../Objects.h"
|
||||
|
||||
typedef struct o_Visitor {
|
||||
PRIVATE int id;
|
||||
PRIVATE char * name;
|
||||
PRIVATE int contact_id;
|
||||
PRIVATE int position;
|
||||
PRIVATE int destination;
|
||||
|
||||
PUBLIC char * (*get_name)(_THIS(Visitor));
|
||||
PUBLIC int (*get_id)(_THIS(Visitor));
|
||||
|
||||
DESTRUCTOR(Visitor);
|
||||
} Visitor;
|
||||
|
||||
FRIENDLY(name, Building)
|
||||
|
||||
Visitor *_init_Visitor(int id, char* name);
|
||||
|
||||
#endif //LO41_VISITOR_H
|
Reference in New Issue
Block a user