diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..8e9be42 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,8 @@ +image: ubuntu:bionic + +build: + stage: build + before_script: + - apt update && apt -y install make cmake gcc + script: + - mkdir cmake-build && cd cmake-build && cmake .. && make \ No newline at end of file diff --git a/Building/Building.c b/Building/Building.c new file mode 100644 index 0000000..c7b0b9b --- /dev/null +++ b/Building/Building.c @@ -0,0 +1,4 @@ +// +// Created by Antoine Bartuccio on 05/06/2018. +// +#include "Building.h" diff --git a/Building/Building.h b/Building/Building.h new file mode 100644 index 0000000..f0af2a6 --- /dev/null +++ b/Building/Building.h @@ -0,0 +1,23 @@ +// +// Created by Antoine Bartuccio on 05/06/2018. +// + +#ifndef LO41_BUILDING_H +#define LO41_BUILDING_H + +#define ELEVATOR_NB 3 + +#include "../Objects.h" +#include "../List/List.h" +#include "../Elevator/Elevator.h" +#include "../CommunicationBox/CommunicationBox.h" + +typedef struct o_Building { + int floors; + List * residents; + CommunicationBox * box; + Elevator elevators[ELEVATOR_NB]; +} Building; + + +#endif //LO41_BUILDING_H diff --git a/CMakeLists.txt b/CMakeLists.txt index 0f6d9b1..f358df6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,4 +4,4 @@ project(LO41 C) set(CMAKE_C_STANDARD 11) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") -add_executable(LO41 main.c List/List.h List/List.c Objects.h List/Element.c List/Element.h Objects.c) \ No newline at end of file +add_executable(LO41 main.c List/List.h List/List.c Objects.h List/Element.c List/Element.h Objects.c Building/Building.c Building/Building.h Elevator/Elevator.c Elevator/Elevator.h CommunicationBox/CommunicationBox.c CommunicationBox/CommunicationBox.h) \ No newline at end of file diff --git a/CommunicationBox/CommunicationBox.c b/CommunicationBox/CommunicationBox.c new file mode 100644 index 0000000..1fc7b63 --- /dev/null +++ b/CommunicationBox/CommunicationBox.c @@ -0,0 +1,5 @@ +// +// Created by Antoine Bartuccio on 05/06/2018. +// + +#include "CommunicationBox.h" diff --git a/CommunicationBox/CommunicationBox.h b/CommunicationBox/CommunicationBox.h new file mode 100644 index 0000000..ed572b9 --- /dev/null +++ b/CommunicationBox/CommunicationBox.h @@ -0,0 +1,14 @@ +// +// Created by Antoine Bartuccio on 05/06/2018. +// + +#ifndef LO41_COMMUNICATIONBOX_H +#define LO41_COMMUNICATIONBOX_H + +#include "../Objects.h" + +typedef struct o_CommunicationBox { + +} CommunicationBox; + +#endif //LO41_COMMUNICATIONBOX_H diff --git a/Elevator/Elevator.c b/Elevator/Elevator.c new file mode 100644 index 0000000..c7d1ce5 --- /dev/null +++ b/Elevator/Elevator.c @@ -0,0 +1,5 @@ +// +// Created by Antoine Bartuccio on 05/06/2018. +// + +#include "Elevator.h" diff --git a/Elevator/Elevator.h b/Elevator/Elevator.h new file mode 100644 index 0000000..84f11d4 --- /dev/null +++ b/Elevator/Elevator.h @@ -0,0 +1,14 @@ +// +// Created by Antoine Bartuccio on 05/06/2018. +// + +#ifndef LO41_ELEVATOR_H +#define LO41_ELEVATOR_H + +#include "../Objects.h" + +typedef struct o_Elevator { + +} Elevator; + +#endif //LO41_ELEVATOR_H diff --git a/List/Element.c b/List/Element.c index 96b1e1c..87058ab 100644 --- a/List/Element.c +++ b/List/Element.c @@ -12,7 +12,7 @@ GETTER(Element, void*, data) SETTER(Element, Element*, previous) SETTER(Element, Element*, next) -void $_free__Element(THIS(Element)){ +void _free__Element(THIS(Element)){ List * list = this->list; if (list != NULL) { if (list->head == this && list->tail == this) { @@ -35,7 +35,7 @@ void $_free__Element(THIS(Element)){ free(this); } -Element *$_init_Element(void *data, size_t size, List *list){ +Element *_init_Element(void *data, size_t size, List *list){ Element *el = (Element*) malloc_or_die(sizeof(Element)); void *new_data = NULL; diff --git a/List/Element.h b/List/Element.h index b352337..09b38a0 100644 --- a/List/Element.h +++ b/List/Element.h @@ -30,6 +30,6 @@ FRIENDLY(data, List) FRIENDLY(next, List) FRIENDLY(previous, List) -Element *$_init_Element(void *data, size_t size, List *list); +Element *_init_Element(void *data, size_t size, List *list); #endif //LO41_ELEMENT_H diff --git a/List/List.c b/List/List.c index 41c89a4..547a946 100644 --- a/List/List.c +++ b/List/List.c @@ -54,7 +54,7 @@ void * get_tail_data_List(THIS(List)){ return NULL; } -void $_free__List(THIS(List)){ +void _free__List(THIS(List)){ this->clear(this); free(this); } @@ -129,7 +129,7 @@ void remove_tail_List(THIS(List)){ DELETE(this->tail); } -List *$_init_List(){ +List *_init_List(){ List *l = (List*) malloc_or_die(sizeof(List)); l->size = 0; l->head = NULL; diff --git a/List/List.h b/List/List.h index 7850f7a..b4ac79c 100644 --- a/List/List.h +++ b/List/List.h @@ -43,6 +43,6 @@ FRIENDLY(head, Element) FRIENDLY(tail, Element) FRIENDLY(size, Element) -List *$_init_List(); +List *_init_List(); #endif //LO41_LIST_H diff --git a/Objects.h b/Objects.h index 2c53f84..c9dee21 100644 --- a/Objects.h +++ b/Objects.h @@ -8,9 +8,9 @@ #include #include -#define NEW(type, ...) $_init_##type(__VA_ARGS__) -#define DELETE(obj) obj->$_free_(obj) -#define DESTRUCTOR(type) void (*$_free_)(struct o_##type *this) +#define NEW(type, ...) _init_##type(__VA_ARGS__) +#define DELETE(obj) obj->_free_(obj) +#define DESTRUCTOR(type) void (*_free_)(struct o_##type *this) #define THIS(type) type *this #define _THIS(type) struct o_##type *this #define CRASH(message) perror(message) @@ -35,7 +35,7 @@ void * malloc_or_die(size_t size); #define VA_NUM_ARGS_IMPL(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, N, ...) N #define LINK_NB_(N) LINK_ALL_##N #define LINK_NB(N) LINK_NB_(N) -#define LINK_ALL(type, obj, ...) LINK(type, obj, $_free_) LINK_NB(VA_NUM_ARGS(__VA_ARGS__))(type, obj, __VA_ARGS__) +#define LINK_ALL(type, obj, ...) LINK(type, obj, _free_) LINK_NB(VA_NUM_ARGS(__VA_ARGS__))(type, obj, __VA_ARGS__) #define LINK_ALL_1(type, obj, method, ...) LINK(type, obj, method) #define LINK_ALL_2(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_1(type, obj, __VA_ARGS__) #define LINK_ALL_3(type, obj, method, ...) LINK(type, obj, method) LINK_ALL_2(type, obj, __VA_ARGS__)