From 6db8075c9bb0198896e0ffe16669aca5e439e40a Mon Sep 17 00:00:00 2001 From: Adrien Bourmault Date: Thu, 14 Oct 2021 11:27:48 +0200 Subject: [PATCH] Cleanup --- include/arrows.h | 6 ++++++ src/parsing.c | 25 +++++++++++++++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/include/arrows.h b/include/arrows.h index f4ea9b1..ef887ff 100644 --- a/include/arrows.h +++ b/include/arrows.h @@ -51,3 +51,9 @@ static inline int ArrowsReleaseLock(ArrowArray_t *arrowArray) { return pthread_spin_unlock(&arrowArray->lock); } + +Arrow_t *ArrowAdd(Scheduler_t *scheduler, int x, int y, int z, int siteId, + int weight); + +bool ArrowRemove(Scheduler_t *scheduler, int x, int y, int z, int siteId, + int weight); diff --git a/src/parsing.c b/src/parsing.c index 53f846e..35839cb 100644 --- a/src/parsing.c +++ b/src/parsing.c @@ -21,6 +21,7 @@ //=-------------------------------------------------------------------------=// #include "../include/parsing.h" +#include "../include/arrows.h" #include "../include/model.h" // -------------------------------------------------------------------------- // @@ -72,11 +73,14 @@ int parseArrowFieldXML (xmlDocPtr doc, int currentParser, xmlNodePtr currentNode) { - xmlChar *x, *y, *z; + Model_t *destination = ModelTable->table[currentParser].destination; + xmlChar *x, *y, *z, *siteId, *weight; x = xmlGetProp(currentNode, (xmlChar*)"x"); y = xmlGetProp(currentNode, (xmlChar*)"y"); z = xmlGetProp(currentNode, (xmlChar*)"z"); + siteId = xmlGetProp(currentNode, (xmlChar*)"siteId"); + weight = xmlGetProp(currentNode, (xmlChar*)"weight"); // Detect children if (currentNode->xmlChildrenNode) { @@ -94,7 +98,18 @@ int parseArrowFieldXML (xmlDocPtr doc, return -1; } - // TODO create arrow in model + // Create arrow in model + if (destination->scheduler) { + ArrowAdd(destination->scheduler, + atoi((char*)x), atoi((char*)y), atoi((char*)z), + atoi((char*)siteId), atoi((char*)weight)); + } else { + xmlFree(x); + xmlFree(y); + xmlFree(z); + + return -1; + } xmlFree(x); xmlFree(y); @@ -103,9 +118,6 @@ int parseArrowFieldXML (xmlDocPtr doc, return 0; } -// -------------------------------------------------------------------------- // -// Parsing an arrow (but yeah that prints) // -// -------------------------------------------------------------------------- // int parseSpaceSizeFieldXML (xmlDocPtr doc, ModelParserTableXML_t *ModelTable, int currentParser, @@ -340,7 +352,8 @@ int ParseModelIdentityXML(Model_t *model, Parameters_t *params) {(const xmlChar *)"space_param", parseParentFieldXML, model}, {(const xmlChar *)"dimension", parseStubFieldXML, model}, {(const xmlChar *)"size", parseSpaceSizeFieldXML, model}, - {(const xmlChar *)"site_multiplicity", parseStubFieldXML, model}, + {(const xmlChar *)"site_multiplicity", parseIntFieldXML, + &model->siteNumber}, // TODO lacking implementation (model side) {(const xmlChar *)"boundaries", parseStubFieldXML, model},