diff --git a/Makefile b/Makefile
index b9938a2..b70e681 100644
--- a/Makefile
+++ b/Makefile
@@ -25,8 +25,9 @@ BINDIR=bin
INCDIR=include
SRCDIR=src
DEBDIR=debian
-SERVEROBJ= $(BINDIR)/scheduler.o $(BINDIR)/server.o $(BINDIR)/localworker.o \
- $(BINDIR)/centers.o $(BINDIR)/cmds.o $(BINDIR)/main.o
+SERVEROBJ= $(BINDIR)/scheduler.o $(BINDIR)/server.o $(BINDIR)/localworker.o \
+ $(BINDIR)/centers.o $(BINDIR)/cmds.o $(BINDIR)/model.o \
+ $(BINDIR)/main.o
CLIOBJ= $(BINDIR)/cli.o
.DEFAULT_GOAL:= all
diff --git a/include/base.h b/include/base.h
index 105b981..ae7a8d5 100644
--- a/include/base.h
+++ b/include/base.h
@@ -40,7 +40,7 @@ struct {
int x;
int y;
int z;
- int o;
+ int siteId;
} typedef Arrow_t;
struct {
@@ -51,7 +51,7 @@ struct {
struct {
char *label;
- int arrowId;
+ int narrow;
} typedef Site_t;
struct {
@@ -119,8 +119,20 @@ struct {
//
// Server
//
-
struct {
pthread_t *id;
bool pleaseStop;
} typedef Server_t;
+
+/* -------------------------------------------------------------------------- */
+
+//
+// Model
+//
+struct {
+ int id;
+ int space_xmax;
+ int space_ymax;
+ int space_zmax;
+ int siteNumber;
+} typedef Model_t;
diff --git a/include/model.h b/include/model.h
new file mode 100644
index 0000000..4256da6
--- /dev/null
+++ b/include/model.h
@@ -0,0 +1,26 @@
+//=-------------------------------------------------------------------------=//
+// Model definitions //
+// //
+// Copyright © 2021 The Gem-graph Project //
+// //
+// This file is part of gem-graph. //
+// //
+// This program is free software: you can redistribute it and/or modify //
+// it under the terms of the GNU Affero General Public License as //
+// published by the Free Software Foundation, either version 3 of the //
+// License, or (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU Affero General Public License for more details. //
+// //
+// You should have received a copy of the GNU Affero General Public License //
+// along with this program. If not, see . //
+//=-------------------------------------------------------------------------=//
+
+#ifndef BASE_H
+ #include "../include/base.h"
+#endif
+
+void ModelPrepareSpace(Space_t *globalDrawingSpace, Model_t *model);
diff --git a/src/cmds.c b/src/cmds.c
index f196077..9faa487 100644
--- a/src/cmds.c
+++ b/src/cmds.c
@@ -21,8 +21,10 @@
#include "../include/base.h"
#include "../include/scheduler.h"
+#include "../include/model.h"
#define ARROW_NUMBER 6
+#define SITE_NUMBER 2
#define MAX_CYCLES 10
#define MAX_THREAD 0
#define XMAX 30
@@ -35,25 +37,21 @@
void *launchScheduler(void *args)
{
Scheduler_t *scheduler0;
+ Model_t *model0;
- //
// Creating structure for the Scheduler
- //
scheduler0 = (Scheduler_t*) calloc(1, sizeof(Scheduler_t));
scheduler0->globalDrawingSpace =
(Space_t*) calloc(1, sizeof(Space_t));
- scheduler0->globalDrawingSpace->space =
- (SpaceUnit_t*) calloc(SPACE_SIZE, sizeof(SpaceUnit_t));
- scheduler0->globalDrawingSpace->size = SPACE_SIZE;
- scheduler0->globalDrawingSpace->xmax = SPACE_SIZE;
- scheduler0->globalDrawingSpace->ymax = SPACE_SIZE;
- scheduler0->globalDrawingSpace->zmax = SPACE_SIZE;
+
+ // Creating structure for the model
+ model0 = (Model_t*) calloc(1, sizeof(Model_t));
+
+ // Preparing global drawing space
+ ModelPrepareSpace(scheduler0->globalDrawingSpace, model0);
scheduler0->arrowList = (ArrowArray_t*) calloc(1, sizeof(ArrowArray_t));
- scheduler0->arrowList->array =
- (Arrow_t*) calloc(ARROW_NUMBER, sizeof(Arrow_t));
- scheduler0->arrowList->size = ARROW_NUMBER;
printLog("Populating a random arrow list...\n");
diff --git a/src/model.c b/src/model.c
new file mode 100644
index 0000000..ba01a2f
--- /dev/null
+++ b/src/model.c
@@ -0,0 +1,56 @@
+//=-------------------------------------------------------------------------=//
+// Model management module //
+// //
+// Copyright © 2021 The Gem-graph Project //
+// //
+// This file is part of gem-graph. //
+// //
+// This program is free software: you can redistribute it and/or modify //
+// it under the terms of the GNU Affero General Public License as //
+// published by the Free Software Foundation, either version 3 of the //
+// License, or (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU Affero General Public License for more details. //
+// //
+// You should have received a copy of the GNU Affero General Public License //
+// along with this program. If not, see . //
+//=-------------------------------------------------------------------------=//
+
+#include "../include/base.h"
+
+void ModelPrepareSpace(Space_t *globalDrawingSpace, Model_t *model)
+{
+ globalDrawingSpace->size = (model->space_xmax+1) * (model->space_ymax+1) * (model->space_zmax+1);
+ globalDrawingSpace->xmax = model->space_xmax;
+ globalDrawingSpace->ymax = model->space_ymax;
+ globalDrawingSpace->zmax = model->space_zmax;
+
+ globalDrawingSpace->space =
+ (SpaceUnit_t*) calloc(globalDrawingSpace->size, sizeof(SpaceUnit_t));
+
+ for (int i = 0; i < globalDrawingSpace->size; i++) {
+ globalDrawingSpace->space[i].nsite = model->siteNumber;
+ globalDrawingSpace->space[i].sites = (Site_t*) calloc(model->siteNumber, sizeof(Site_t));
+ }
+}
+
+void ModelPrepareArrows(Space_t *globalDrawingSpace, ArrowArray_t *arrowList,
+ Model_t *model)
+{
+#define ARROW_NUMBER 6
+
+ arrowList->array = (Arrow_t*) calloc(ARROW_NUMBER, sizeof(Arrow_t));
+ arrowList->size = ARROW_NUMBER;
+
+ // Creating some arrows
+ globalDrawingSpace->space[3].sites[1].narrow = 1;
+ arrowList->array[0].siteId = 1;
+ arrowList->array[0].x = 3;
+
+ globalDrawingSpace->space[4].sites[0].narrow = 1;
+ arrowList->array[1].siteId = 0;
+ arrowList->array[1].x = 4;
+}