This commit is contained in:
Adrien Bourmault 2021-10-14 11:27:48 +02:00
parent 0cc24b8a65
commit 6db8075c9b
No known key found for this signature in database
GPG Key ID: 6EB408FE0ACEC664
2 changed files with 25 additions and 6 deletions

View File

@ -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);

View File

@ -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},