Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #179 from Takishipp/signals
[simgrid.git] / src / surf / xml / surfxml_sax_cb.cpp
1 /* Copyright (c) 2006-2017. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include "simgrid/s4u/Engine.hpp"
7 #include "simgrid/sg_config.h"
8 #include "src/kernel/routing/NetPoint.hpp"
9 #include "src/surf/network_interface.hpp"
10 #include "xbt/file.h"
11
12 #include "src/surf/xml/platf_private.hpp"
13 #include <boost/algorithm/string.hpp>
14 #include <boost/algorithm/string/classification.hpp>
15 #include <boost/algorithm/string/split.hpp>
16 #include <string>
17
18 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_parse, surf, "Logging specific to the SURF parsing module");
19
20 SG_BEGIN_DECL()
21
22 int ETag_surfxml_include_state();
23
24 #include "simgrid_dtd.c"
25
26 char* surf_parsed_filename = nullptr; // to locate parse error messages
27
28 std::vector<simgrid::surf::LinkImpl*> parsed_link_list; /* temporary store of current list link of a route */
29
30 /*
31  * Helping functions
32  */
33 void surf_parse_assert(bool cond, const char *fmt, ...) {
34   if (not cond) {
35     va_list va;
36     va_start(va,fmt);
37     int lineno = surf_parse_lineno;
38     char *msg = bvprintf(fmt,va);
39     va_end(va);
40     cleanup();
41     XBT_ERROR("Parse error at %s:%d: %s", surf_parsed_filename, lineno, msg);
42     surf_exit();
43     xbt_die("Exiting now");
44   }
45 }
46 void surf_parse_error(const char *fmt, ...) {
47   va_list va;
48   va_start(va,fmt);
49   int lineno = surf_parse_lineno;
50   char *msg = bvprintf(fmt,va);
51   va_end(va);
52   cleanup();
53   XBT_ERROR("Parse error at %s:%d: %s", surf_parsed_filename, lineno, msg);
54   surf_exit();
55   xbt_die("Exiting now");
56 }
57 void surf_parse_warn(const char *fmt, ...) {
58   va_list va;
59   va_start(va,fmt);
60   char *msg = bvprintf(fmt,va);
61   va_end(va);
62     XBT_WARN("%s:%d: %s", surf_parsed_filename, surf_parse_lineno, msg);
63     free(msg);
64 }
65
66 double surf_parse_get_double(const char *string) {
67   double res;
68   int ret = sscanf(string, "%lg", &res);
69   if (ret != 1)
70     surf_parse_error("%s is not a double", string);
71   return res;
72 }
73
74 int surf_parse_get_int(const char *string) {
75   int res;
76   int ret = sscanf(string, "%d", &res);
77   if (ret != 1)
78     surf_parse_error("%s is not an integer", string);
79   return res;
80 }
81
82 /* Turn something like "1-4,6,9-11" into the vector {1,2,3,4,6,9,10,11} */
83 static std::vector<int>* explodesRadical(const char* radicals)
84 {
85   std::vector<int>* exploded = new std::vector<int>();
86
87   // Make all hosts
88   std::vector<std::string> radical_elements;
89   boost::split(radical_elements, radicals, boost::is_any_of(","));
90   for (auto group : radical_elements) {
91     std::vector<std::string> radical_ends;
92     boost::split(radical_ends, group, boost::is_any_of("-"));
93     int start                = surf_parse_get_int((radical_ends.front()).c_str());
94     int end                  = 0;
95
96     switch (radical_ends.size()) {
97       case 1:
98         end = start;
99         break;
100       case 2:
101         end = surf_parse_get_int((radical_ends.back()).c_str());
102         break;
103       default:
104         surf_parse_error("Malformed radical: %s", group.c_str());
105         break;
106     }
107     for (int i = start; i <= end; i++)
108       exploded->push_back(i);
109   }
110
111   return exploded;
112 }
113
114 struct unit_scale {
115   const char *unit;
116   double scale;
117 };
118
119 /* Note: field `unit' for the last element of parameter `units' should be nullptr. */
120 static double surf_parse_get_value_with_unit(const char *string, const struct unit_scale *units,
121     const char *entity_kind, const char *name, const char *error_msg, const char *default_unit)
122 {
123   char* ptr;
124   int i;
125   errno = 0;
126   double res   = strtod(string, &ptr);
127   if (errno == ERANGE)
128     surf_parse_error("value out of range: %s", string);
129   if (ptr == string)
130     surf_parse_error("cannot parse number: %s", string);
131   if (ptr[0] == '\0') {
132     if (res == 0)
133       return res; // Ok, 0 can be unit-less
134
135     XBT_WARN("Deprecated unit-less value '%s' for %s %s. %s",string, entity_kind, name, error_msg);
136     ptr = (char*)default_unit;
137   }
138   for (i = 0; units[i].unit != nullptr && strcmp(ptr, units[i].unit) != 0; i++);
139
140   if (units[i].unit != nullptr)
141     res *= units[i].scale;
142   else
143     surf_parse_error("unknown unit: %s", ptr);
144   return res;
145 }
146
147 double surf_parse_get_time(const char *string, const char *entity_kind, const char *name)
148 {
149   const struct unit_scale units[] = {
150     { "w",  7 * 24 * 60 * 60 },
151     { "d",  24 * 60 * 60 },
152     { "h",  60 * 60 },
153     { "m",  60 },
154     { "s",  1.0 },
155     { "ms", 1e-3 },
156     { "us", 1e-6 },
157     { "ns", 1e-9 },
158     { "ps", 1e-12 },
159     { nullptr, 0 }
160   };
161   return surf_parse_get_value_with_unit(string, units, entity_kind, name,
162       "Append 's' to your time to get seconds", "s");
163 }
164
165 double surf_parse_get_size(const char *string, const char *entity_kind, const char *name)
166 {
167   const struct unit_scale units[] = {
168     { "EiB", pow(1024, 6) },
169     { "PiB", pow(1024, 5) },
170     { "TiB", pow(1024, 4) },
171     { "GiB", pow(1024, 3) },
172     { "MiB", pow(1024, 2) },
173     { "KiB", 1024 },
174     { "EB",  1e18 },
175     { "PB",  1e15 },
176     { "TB",  1e12 },
177     { "GB",  1e9 },
178     { "MB",  1e6 },
179     { "kB",  1e3 },
180     { "B",   1.0 },
181     { "Eib", 0.125 * pow(1024, 6) },
182     { "Pib", 0.125 * pow(1024, 5) },
183     { "Tib", 0.125 * pow(1024, 4) },
184     { "Gib", 0.125 * pow(1024, 3) },
185     { "Mib", 0.125 * pow(1024, 2) },
186     { "Kib", 0.125 * 1024 },
187     { "Eb",  0.125 * 1e18 },
188     { "Pb",  0.125 * 1e15 },
189     { "Tb",  0.125 * 1e12 },
190     { "Gb",  0.125 * 1e9 },
191     { "Mb",  0.125 * 1e6 },
192     { "kb",  0.125 * 1e3 },
193     { "b",   0.125 },
194     { nullptr,    0 }
195   };
196   return surf_parse_get_value_with_unit(string, units, entity_kind, name,
197       "Append 'B' to get bytes (or 'b' for bits but 1B = 8b).", "B");
198 }
199
200 double surf_parse_get_bandwidth(const char *string, const char *entity_kind, const char *name)
201 {
202   const struct unit_scale units[] = {
203     { "EiBps", pow(1024, 6) },
204     { "PiBps", pow(1024, 5) },
205     { "TiBps", pow(1024, 4) },
206     { "GiBps", pow(1024, 3) },
207     { "MiBps", pow(1024, 2) },
208     { "KiBps", 1024 },
209     { "EBps",  1e18 },
210     { "PBps",  1e15 },
211     { "TBps",  1e12 },
212     { "GBps",  1e9 },
213     { "MBps",  1e6 },
214     { "kBps",  1e3 },
215     { "Bps",   1.0 },
216     { "Eibps", 0.125 * pow(1024, 6) },
217     { "Pibps", 0.125 * pow(1024, 5) },
218     { "Tibps", 0.125 * pow(1024, 4) },
219     { "Gibps", 0.125 * pow(1024, 3) },
220     { "Mibps", 0.125 * pow(1024, 2) },
221     { "Kibps", 0.125 * 1024 },
222     { "Tbps",  0.125 * 1e12 },
223     { "Gbps",  0.125 * 1e9 },
224     { "Mbps",  0.125 * 1e6 },
225     { "kbps",  0.125 * 1e3 },
226     { "bps",   0.125 },
227     { nullptr,    0 }
228   };
229   return surf_parse_get_value_with_unit(string, units, entity_kind, name,
230       "Append 'Bps' to get bytes per second (or 'bps' for bits but 1Bps = 8bps)", "Bps");
231 }
232
233 double surf_parse_get_speed(const char *string, const char *entity_kind, const char *name)
234 {
235   const struct unit_scale units[] = {
236     { "yottaflops", 1e24 },
237     { "Yf",         1e24 },
238     { "zettaflops", 1e21 },
239     { "Zf",         1e21 },
240     { "exaflops",   1e18 },
241     { "Ef",         1e18 },
242     { "petaflops",  1e15 },
243     { "Pf",         1e15 },
244     { "teraflops",  1e12 },
245     { "Tf",         1e12 },
246     { "gigaflops",  1e9 },
247     { "Gf",         1e9 },
248     { "megaflops",  1e6 },
249     { "Mf",         1e6 },
250     { "kiloflops",  1e3 },
251     { "kf",         1e3 },
252     { "flops",      1.0 },
253     { "f",          1.0 },
254     { nullptr,         0 }
255   };
256   return surf_parse_get_value_with_unit(string, units, entity_kind, name,
257       "Append 'f' or 'flops' to your speed to get flop per second", "f");
258 }
259
260 static std::vector<double> surf_parse_get_all_speeds(char* speeds, const char* entity_kind, const char* id){
261
262   std::vector<double> speed_per_pstate;
263
264   if (strchr(speeds, ',') == nullptr){
265     double speed = surf_parse_get_speed(speeds, entity_kind, id);
266     speed_per_pstate.push_back(speed);
267   } else {
268     std::vector<std::string> pstate_list;
269     boost::split(pstate_list, speeds, boost::is_any_of(","));
270     for (auto speed_str : pstate_list) {
271       boost::trim(speed_str);
272       double speed = surf_parse_get_speed(speed_str.c_str(), entity_kind, id);
273       speed_per_pstate.push_back(speed);
274       XBT_DEBUG("Speed value: %f", speed);
275     }
276   }
277   return speed_per_pstate;
278 }
279
280 /*
281  * All the callback lists that can be overridden anywhere.
282  * (this list should probably be reduced to the bare minimum to allow the models to work)
283  */
284
285 /* make sure these symbols are defined as strong ones in this file so that the linker can resolve them */
286
287 /* The default current property receiver. Setup in the corresponding opening callbacks. */
288 xbt_dict_t current_property_set = nullptr;
289 std::map<std::string, std::string>* current_model_property_set = nullptr;
290 int ZONE_TAG                            = 0; // Whether we just opened a zone tag (to see what to do with the properties)
291
292 /* dictionary of random generator data */
293 xbt_dict_t random_data_list = nullptr;
294
295 YY_BUFFER_STATE surf_input_buffer;
296 FILE *surf_file_to_parse = nullptr;
297
298 /*
299  * Stuff relative to storage
300  */
301 void STag_surfxml_storage()
302 {
303   ZONE_TAG = 0;
304   XBT_DEBUG("STag_surfxml_storage");
305   xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
306 }
307 void ETag_surfxml_storage()
308 {
309   s_sg_platf_storage_cbarg_t storage;
310   memset(&storage,0,sizeof(storage));
311
312   storage.properties   = current_property_set;
313   current_property_set = nullptr;
314
315   storage.id           = A_surfxml_storage_id;
316   storage.type_id      = A_surfxml_storage_typeId;
317   storage.content      = A_surfxml_storage_content;
318
319   storage.attach       = A_surfxml_storage_attach;
320   sg_platf_new_storage(&storage);
321 }
322 void STag_surfxml_storage___type()
323 {
324   ZONE_TAG = 0;
325   XBT_DEBUG("STag_surfxml_storage___type");
326   xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
327   xbt_assert(current_model_property_set == nullptr, "Someone forgot to reset the model property set to nullptr in its closing tag (or XML malformed)");
328 }
329 void ETag_surfxml_storage___type()
330 {
331   s_sg_platf_storage_type_cbarg_t storage_type;
332   memset(&storage_type,0,sizeof(storage_type));
333
334   storage_type.properties = current_property_set;
335   current_property_set    = nullptr;
336
337   storage_type.model_properties = current_model_property_set;
338   current_model_property_set    = nullptr;
339
340   storage_type.content          = A_surfxml_storage___type_content;
341   storage_type.id               = A_surfxml_storage___type_id;
342   storage_type.model            = A_surfxml_storage___type_model;
343   storage_type.size             = surf_parse_get_size(A_surfxml_storage___type_size,
344         "size of storage type", storage_type.id);
345   sg_platf_new_storage_type(&storage_type);
346 }
347 void STag_surfxml_mount()
348 {
349   XBT_DEBUG("STag_surfxml_mount");
350 }
351 void ETag_surfxml_mount()
352 {
353   s_sg_platf_mount_cbarg_t mount;
354   memset(&mount,0,sizeof(mount));
355
356   mount.name      = A_surfxml_mount_name;
357   mount.storageId = A_surfxml_mount_storageId;
358   sg_platf_new_mount(&mount);
359 }
360
361 /*
362  * Stuff relative to the <include> tag
363  */
364 static std::vector<YY_BUFFER_STATE> surf_input_buffer_stack;
365 static std::vector<FILE*> surf_file_to_parse_stack;
366 static std::vector<char*> surf_parsed_filename_stack;
367
368 void STag_surfxml_include()
369 {
370   parse_after_config();
371   XBT_DEBUG("STag_surfxml_include '%s'",A_surfxml_include_file);
372   surf_parsed_filename_stack.push_back(surf_parsed_filename); // save old file name
373   surf_parsed_filename = xbt_strdup(A_surfxml_include_file);
374
375   surf_file_to_parse_stack.push_back(surf_file_to_parse); // save old file descriptor
376
377   surf_file_to_parse = surf_fopen(A_surfxml_include_file, "r"); // read new file descriptor
378   xbt_assert((surf_file_to_parse), "Unable to open \"%s\"\n", A_surfxml_include_file);
379
380   surf_input_buffer_stack.push_back(surf_input_buffer);
381   surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, YY_BUF_SIZE);
382   surf_parse_push_buffer_state(surf_input_buffer);
383
384   fflush(nullptr);
385 }
386
387 void ETag_surfxml_include() {
388 /* Nothing to do when done with reading the include tag.
389  * Instead, the handling should be deferred until the EOF of current buffer -- see below */
390 }
391
392 /** @brief When reaching EOF, check whether we are in an include tag, and behave accordingly if yes
393  *
394  * This function is called automatically by sedding the parser in tools/cmake/MaintainerMode.cmake
395  * Every FAIL on "Premature EOF" is preceded by a call to this function, which role is to restore the
396  * previous buffer if we reached the EOF /of an include file/. Its return code is used to avoid the
397  * error message in that case.
398  *
399  * Yeah, that's terribly hackish, but it works. A better solution should be dealed with in flexml
400  * directly: a command line flag could instruct it to do the correct thing when the include directive is encountered
401  * on a line. One day maybe, if the maya allow it.
402  */
403 int ETag_surfxml_include_state()
404 {
405   fflush(nullptr);
406   XBT_DEBUG("ETag_surfxml_include_state '%s'",A_surfxml_include_file);
407
408   if (surf_input_buffer_stack.empty()) // nope, that's a true premature EOF. Let the parser die verbosely.
409     return 0;
410
411   // Yeah, we were in an <include> Restore state and proceed.
412   fclose(surf_file_to_parse);
413   surf_file_to_parse_stack.pop_back();
414   surf_parse_pop_buffer_state();
415   surf_input_buffer_stack.pop_back();
416
417   // Restore the filename for error messages
418   free(surf_parsed_filename);
419   surf_parsed_filename_stack.pop_back();
420
421   return 1;
422 }
423
424 /* Stag and Etag parse functions */
425
426 void STag_surfxml_platform() {
427   XBT_ATTRIB_UNUSED double version = surf_parse_get_double(A_surfxml_platform_version);
428
429   xbt_assert((version >= 1.0), "******* BIG FAT WARNING *********\n "
430       "You're using an ancient XML file.\n"
431       "Since SimGrid 3.1, units are Bytes, Flops, and seconds "
432       "instead of MBytes, MFlops and seconds.\n"
433
434       "Use simgrid_update_xml to update your file automatically. "
435       "This program is installed automatically with SimGrid, or "
436       "available in the tools/ directory of the source archive.\n"
437
438       "Please check also out the SURF section of the ChangeLog for "
439       "the 3.1 version for more information. \n"
440
441       "Last, do not forget to also update your values for "
442       "the calls to MSG_task_create (if any).");
443   xbt_assert((version >= 3.0), "******* BIG FAT WARNING *********\n "
444       "You're using an old XML file.\n"
445       "Use simgrid_update_xml to update your file automatically. "
446       "This program is installed automatically with SimGrid, or "
447       "available in the tools/ directory of the source archive.");
448   xbt_assert((version >= 4.0),
449              "******* FILE %s IS TOO OLD (v:%.1f) *********\n "
450              "Changes introduced in SimGrid 3.13:\n"
451              "  - 'power' attribute of hosts (and others) got renamed to 'speed'.\n"
452              "  - In <trace_connect>, attribute kind=\"POWER\" is now kind=\"SPEED\".\n"
453              "  - DOCTYPE now point to the rignt URL: http://simgrid.gforge.inria.fr/simgrid/simgrid.dtd\n"
454              "  - speed, bandwidth and latency attributes now MUST have an explicit unit (f, Bps, s by default)"
455              "\n\n"
456              "Use simgrid_update_xml to update your file automatically. "
457              "This program is installed automatically with SimGrid, or "
458              "available in the tools/ directory of the source archive.",
459              surf_parsed_filename, version);
460   if (version < 4.1) {
461     XBT_INFO("You're using a v%.1f XML file (%s) while the current standard is v4.1 "
462              "That's fine, the new version is backward compatible. \n\n"
463              "Use simgrid_update_xml to update your file automatically. "
464              "This program is installed automatically with SimGrid, or "
465              "available in the tools/ directory of the source archive.",
466              version, surf_parsed_filename);
467   }
468   xbt_assert(version <= 4.1, "******* FILE %s COMES FROM THE FUTURE (v:%.1f) *********\n "
469                              "The most recent formalism that this version of SimGrid understands is v4.1.\n"
470                              "Please update your code, or use another, more adapted, file.",
471              surf_parsed_filename, version);
472
473   sg_platf_begin();
474 }
475 void ETag_surfxml_platform(){
476   sg_platf_end();
477 }
478
479 void STag_surfxml_host(){
480   ZONE_TAG = 0;
481   xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
482 }
483
484 void STag_surfxml_prop()
485 {
486   if (ZONE_TAG) { // We need to retrieve the most recently opened zone
487     XBT_DEBUG("Set zone property %s -> %s", A_surfxml_prop_id, A_surfxml_prop_value);
488     simgrid::s4u::NetZone* netzone = simgrid::s4u::Engine::instance()->netzoneByNameOrNull(A_surfxml_zone_id);
489
490     netzone->setProperty(A_surfxml_prop_id, A_surfxml_prop_value);
491   }
492   else{
493     if (not current_property_set)
494       current_property_set = xbt_dict_new_homogeneous(&xbt_free_f); // Maybe, it should raise an error
495     xbt_dict_set(current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), nullptr);
496     XBT_DEBUG("add prop %s=%s into current property set %p", A_surfxml_prop_id, A_surfxml_prop_value,
497               current_property_set);
498   }
499 }
500
501 void ETag_surfxml_host()    {
502   s_sg_platf_host_cbarg_t host;
503   memset(&host,0,sizeof(host));
504
505   host.properties = current_property_set;
506   current_property_set = nullptr;
507
508   host.id = A_surfxml_host_id;
509
510   host.speed_per_pstate = surf_parse_get_all_speeds(A_surfxml_host_speed, "speed of host", host.id);
511
512   XBT_DEBUG("pstate: %s", A_surfxml_host_pstate);
513   host.core_amount = surf_parse_get_int(A_surfxml_host_core);
514   host.speed_trace = A_surfxml_host_availability___file[0] ? tmgr_trace_new_from_file(A_surfxml_host_availability___file) : nullptr;
515   host.state_trace = A_surfxml_host_state___file[0] ? tmgr_trace_new_from_file(A_surfxml_host_state___file) : nullptr;
516   host.pstate      = surf_parse_get_int(A_surfxml_host_pstate);
517   host.coord       = A_surfxml_host_coordinates;
518
519   sg_platf_new_host(&host);
520 }
521
522 void STag_surfxml_host___link(){
523   XBT_DEBUG("Create a Host_link for %s",A_surfxml_host___link_id);
524   s_sg_platf_host_link_cbarg_t host_link;
525   memset(&host_link,0,sizeof(host_link));
526
527   host_link.id        = A_surfxml_host___link_id;
528   host_link.link_up   = A_surfxml_host___link_up;
529   host_link.link_down = A_surfxml_host___link_down;
530   sg_platf_new_hostlink(&host_link);
531 }
532
533 void STag_surfxml_router(){
534   sg_platf_new_router(A_surfxml_router_id, A_surfxml_router_coordinates);
535 }
536
537 void ETag_surfxml_cluster(){
538   s_sg_platf_cluster_cbarg_t cluster;
539   memset(&cluster,0,sizeof(cluster));
540   cluster.properties = current_property_set;
541   current_property_set = nullptr;
542
543   cluster.id          = A_surfxml_cluster_id;
544   cluster.prefix      = A_surfxml_cluster_prefix;
545   cluster.suffix      = A_surfxml_cluster_suffix;
546   cluster.radicals    = explodesRadical(A_surfxml_cluster_radical);
547   cluster.speeds      = surf_parse_get_all_speeds(A_surfxml_cluster_speed, "speed of cluster", cluster.id);
548   cluster.core_amount = surf_parse_get_int(A_surfxml_cluster_core);
549   cluster.bw          = surf_parse_get_bandwidth(A_surfxml_cluster_bw, "bw of cluster", cluster.id);
550   cluster.lat         = surf_parse_get_time(A_surfxml_cluster_lat, "lat of cluster", cluster.id);
551   if(strcmp(A_surfxml_cluster_bb___bw,""))
552     cluster.bb_bw = surf_parse_get_bandwidth(A_surfxml_cluster_bb___bw, "bb_bw of cluster", cluster.id);
553   if(strcmp(A_surfxml_cluster_bb___lat,""))
554     cluster.bb_lat = surf_parse_get_time(A_surfxml_cluster_bb___lat, "bb_lat of cluster", cluster.id);
555   if(strcmp(A_surfxml_cluster_limiter___link,""))
556     cluster.limiter_link = surf_parse_get_bandwidth(A_surfxml_cluster_limiter___link, "limiter_link of cluster", cluster.id);
557   if(strcmp(A_surfxml_cluster_loopback___bw,""))
558     cluster.loopback_bw = surf_parse_get_bandwidth(A_surfxml_cluster_loopback___bw, "loopback_bw of cluster", cluster.id);
559   if(strcmp(A_surfxml_cluster_loopback___lat,""))
560     cluster.loopback_lat = surf_parse_get_time(A_surfxml_cluster_loopback___lat, "loopback_lat of cluster", cluster.id);
561
562   switch(AX_surfxml_cluster_topology){
563   case A_surfxml_cluster_topology_FLAT:
564     cluster.topology= SURF_CLUSTER_FLAT ;
565     break;
566   case A_surfxml_cluster_topology_TORUS:
567     cluster.topology= SURF_CLUSTER_TORUS ;
568     break;
569   case A_surfxml_cluster_topology_FAT___TREE:
570     cluster.topology = SURF_CLUSTER_FAT_TREE;
571     break;
572   case A_surfxml_cluster_topology_DRAGONFLY:
573     cluster.topology= SURF_CLUSTER_DRAGONFLY ;
574     break;
575   default:
576     surf_parse_error("Invalid cluster topology for cluster %s",
577                      cluster.id);
578     break;
579   }
580   cluster.topo_parameters = A_surfxml_cluster_topo___parameters;
581   cluster.router_id = A_surfxml_cluster_router___id;
582
583   switch (AX_surfxml_cluster_sharing___policy) {
584   case A_surfxml_cluster_sharing___policy_SHARED:
585     cluster.sharing_policy = SURF_LINK_SHARED;
586     break;
587   case A_surfxml_cluster_sharing___policy_FULLDUPLEX:
588     cluster.sharing_policy = SURF_LINK_FULLDUPLEX;
589     break;
590   case A_surfxml_cluster_sharing___policy_FATPIPE:
591     cluster.sharing_policy = SURF_LINK_FATPIPE;
592     break;
593   default:
594     surf_parse_error("Invalid cluster sharing policy for cluster %s", cluster.id);
595     break;
596   }
597   switch (AX_surfxml_cluster_bb___sharing___policy) {
598   case A_surfxml_cluster_bb___sharing___policy_FATPIPE:
599     cluster.bb_sharing_policy = SURF_LINK_FATPIPE;
600     break;
601   case A_surfxml_cluster_bb___sharing___policy_SHARED:
602     cluster.bb_sharing_policy = SURF_LINK_SHARED;
603     break;
604   default:
605     surf_parse_error("Invalid bb sharing policy in cluster %s", cluster.id);
606     break;
607   }
608
609   sg_platf_new_cluster(&cluster);
610 }
611
612 void STag_surfxml_cluster(){
613   ZONE_TAG = 0;
614   parse_after_config();
615   xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
616 }
617
618 void STag_surfxml_cabinet(){
619   parse_after_config();
620   s_sg_platf_cabinet_cbarg_t cabinet;
621   memset(&cabinet,0,sizeof(cabinet));
622   cabinet.id      = A_surfxml_cabinet_id;
623   cabinet.prefix  = A_surfxml_cabinet_prefix;
624   cabinet.suffix  = A_surfxml_cabinet_suffix;
625   cabinet.speed   = surf_parse_get_speed(A_surfxml_cabinet_speed, "speed of cabinet", cabinet.id);
626   cabinet.bw      = surf_parse_get_bandwidth(A_surfxml_cabinet_bw, "bw of cabinet", cabinet.id);
627   cabinet.lat     = surf_parse_get_time(A_surfxml_cabinet_lat, "lat of cabinet", cabinet.id);
628   cabinet.radicals = explodesRadical(A_surfxml_cabinet_radical);
629
630   sg_platf_new_cabinet(&cabinet);
631 }
632
633 void STag_surfxml_peer(){
634   parse_after_config();
635   s_sg_platf_peer_cbarg_t peer;
636   memset(&peer,0,sizeof(peer));
637   peer.id          = A_surfxml_peer_id;
638   peer.speed       = surf_parse_get_speed(A_surfxml_peer_speed, "speed of peer", peer.id);
639   peer.bw_in       = surf_parse_get_bandwidth(A_surfxml_peer_bw___in, "bw_in of peer", peer.id);
640   peer.bw_out      = surf_parse_get_bandwidth(A_surfxml_peer_bw___out, "bw_out of peer", peer.id);
641   peer.coord       = A_surfxml_peer_coordinates;
642   peer.speed_trace = A_surfxml_peer_availability___file[0] ? tmgr_trace_new_from_file(A_surfxml_peer_availability___file) : nullptr;
643   peer.state_trace = A_surfxml_peer_state___file[0] ? tmgr_trace_new_from_file(A_surfxml_peer_state___file) : nullptr;
644
645   if (A_surfxml_peer_lat[0] != '\0')
646     XBT_WARN("The latency parameter in <peer> is now deprecated. Use the z coordinate instead of '%s'.",
647              A_surfxml_peer_lat);
648
649   sg_platf_new_peer(&peer);
650 }
651
652 void STag_surfxml_link(){
653   ZONE_TAG = 0;
654   xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
655 }
656
657 void ETag_surfxml_link(){
658   LinkCreationArgs link;
659
660   link.properties          = current_property_set;
661   current_property_set     = nullptr;
662
663   link.id                  = std::string(A_surfxml_link_id);
664   link.bandwidth           = surf_parse_get_bandwidth(A_surfxml_link_bandwidth, "bandwidth of link", link.id.c_str());
665   link.bandwidth_trace     = A_surfxml_link_bandwidth___file[0] ? tmgr_trace_new_from_file(A_surfxml_link_bandwidth___file) : nullptr;
666   link.latency             = surf_parse_get_time(A_surfxml_link_latency, "latency of link", link.id.c_str());
667   link.latency_trace       = A_surfxml_link_latency___file[0] ? tmgr_trace_new_from_file(A_surfxml_link_latency___file) : nullptr;
668   link.state_trace         = A_surfxml_link_state___file[0] ? tmgr_trace_new_from_file(A_surfxml_link_state___file):nullptr;
669
670   switch (A_surfxml_link_sharing___policy) {
671   case A_surfxml_link_sharing___policy_SHARED:
672     link.policy = SURF_LINK_SHARED;
673     break;
674   case A_surfxml_link_sharing___policy_FATPIPE:
675      link.policy = SURF_LINK_FATPIPE;
676      break;
677   case A_surfxml_link_sharing___policy_FULLDUPLEX:
678      link.policy = SURF_LINK_FULLDUPLEX;
679      break;
680   default:
681     surf_parse_error("Invalid sharing policy in link %s", link.id.c_str());
682     break;
683   }
684
685   sg_platf_new_link(&link);
686 }
687
688 void STag_surfxml_link___ctn(){
689
690   simgrid::surf::LinkImpl* link = nullptr;
691   char *link_name=nullptr;
692   switch (A_surfxml_link___ctn_direction) {
693   case AU_surfxml_link___ctn_direction:
694   case A_surfxml_link___ctn_direction_NONE:
695     link = simgrid::surf::LinkImpl::byName(A_surfxml_link___ctn_id);
696     break;
697   case A_surfxml_link___ctn_direction_UP:
698     link_name = bprintf("%s_UP", A_surfxml_link___ctn_id);
699     link      = simgrid::surf::LinkImpl::byName(link_name);
700     break;
701   case A_surfxml_link___ctn_direction_DOWN:
702     link_name = bprintf("%s_DOWN", A_surfxml_link___ctn_id);
703     link      = simgrid::surf::LinkImpl::byName(link_name);
704     break;
705   default:
706     surf_parse_error("Invalid direction for link %s", link_name);
707     break;
708   }
709   xbt_free(link_name); // no-op if it's already nullptr
710
711   const char* dirname = "";
712   switch (A_surfxml_link___ctn_direction) {
713     case A_surfxml_link___ctn_direction_UP:
714       dirname = " (upward)";
715       break;
716     case A_surfxml_link___ctn_direction_DOWN:
717       dirname = " (downward)";
718       break;
719     default:
720       dirname = "";
721   }
722   surf_parse_assert(link != nullptr, "No such link: '%s'%s", A_surfxml_link___ctn_id, dirname);
723   parsed_link_list.push_back(link);
724 }
725
726 void ETag_surfxml_backbone(){
727   LinkCreationArgs link;
728
729   link.properties = nullptr;
730   link.id = std::string(A_surfxml_backbone_id);
731   link.bandwidth = surf_parse_get_bandwidth(A_surfxml_backbone_bandwidth, "bandwidth of backbone", link.id.c_str());
732   link.latency = surf_parse_get_time(A_surfxml_backbone_latency, "latency of backbone", link.id.c_str());
733   link.policy = SURF_LINK_SHARED;
734
735   sg_platf_new_link(&link);
736   routing_cluster_add_backbone(simgrid::surf::LinkImpl::byName(A_surfxml_backbone_id));
737 }
738
739 void STag_surfxml_route(){
740   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_route_src), "Route src='%s' does name a node.",
741                     A_surfxml_route_src);
742   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_route_dst), "Route dst='%s' does name a node.",
743                     A_surfxml_route_dst);
744 }
745
746 void STag_surfxml_ASroute(){
747   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_ASroute_src), "ASroute src='%s' does name a node.",
748                     A_surfxml_ASroute_src);
749   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_ASroute_dst), "ASroute dst='%s' does name a node.",
750                     A_surfxml_ASroute_dst);
751
752   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_ASroute_gw___src), "ASroute gw_src='%s' does name a node.",
753                     A_surfxml_ASroute_gw___src);
754   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_ASroute_gw___dst), "ASroute gw_dst='%s' does name a node.",
755                     A_surfxml_ASroute_gw___dst);
756 }
757 void STag_surfxml_zoneRoute(){
758   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_src), "zoneRoute src='%s' does name a node.",
759                     A_surfxml_zoneRoute_src);
760   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_dst), "zoneRoute dst='%s' does name a node.",
761                     A_surfxml_zoneRoute_dst);
762
763   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_gw___src), "zoneRoute gw_src='%s' does name a node.",
764                     A_surfxml_zoneRoute_gw___src);
765   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_gw___dst), "zoneRoute gw_dst='%s' does name a node.",
766                     A_surfxml_zoneRoute_gw___dst);
767 }
768
769 void STag_surfxml_bypassRoute(){
770   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_bypassRoute_src), "bypassRoute src='%s' does name a node.",
771                     A_surfxml_bypassRoute_src);
772   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_bypassRoute_dst), "bypassRoute dst='%s' does name a node.",
773                     A_surfxml_bypassRoute_dst);
774 }
775
776 void STag_surfxml_bypassASroute(){
777   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_bypassASroute_src),
778                     "bypassASroute src='%s' does name a node.", A_surfxml_bypassASroute_src);
779   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_bypassASroute_dst),
780                     "bypassASroute dst='%s' does name a node.", A_surfxml_bypassASroute_dst);
781   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_bypassASroute_gw___src),
782                     "bypassASroute gw_src='%s' does name a node.", A_surfxml_bypassASroute_gw___src);
783   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_bypassASroute_gw___dst),
784                     "bypassASroute gw_dst='%s' does name a node.", A_surfxml_bypassASroute_gw___dst);
785 }
786 void STag_surfxml_bypassZoneRoute(){
787   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_src),
788                     "bypassASroute src='%s' does name a node.", A_surfxml_bypassZoneRoute_src);
789   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_dst),
790                     "bypassASroute dst='%s' does name a node.", A_surfxml_bypassZoneRoute_dst);
791   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_gw___src),
792                     "bypassASroute gw_src='%s' does name a node.", A_surfxml_bypassZoneRoute_gw___src);
793   surf_parse_assert(sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_gw___dst),
794                     "bypassASroute gw_dst='%s' does name a node.", A_surfxml_bypassZoneRoute_gw___dst);
795 }
796
797 void ETag_surfxml_route(){
798   s_sg_platf_route_cbarg_t route;
799   memset(&route,0,sizeof(route));
800
801   route.src         = sg_netpoint_by_name_or_null(A_surfxml_route_src); // tested to not be nullptr in start tag
802   route.dst         = sg_netpoint_by_name_or_null(A_surfxml_route_dst); // tested to not be nullptr in start tag
803   route.gw_src    = nullptr;
804   route.gw_dst    = nullptr;
805   route.link_list   = new std::vector<simgrid::surf::LinkImpl*>();
806   route.symmetrical = (A_surfxml_route_symmetrical == A_surfxml_route_symmetrical_YES);
807
808   for (auto link: parsed_link_list)
809     route.link_list->push_back(link);
810   parsed_link_list.clear();
811
812   sg_platf_new_route(&route);
813   delete route.link_list;
814 }
815
816 void ETag_surfxml_ASroute()
817 {
818   AX_surfxml_zoneRoute_src = AX_surfxml_ASroute_src;
819   AX_surfxml_zoneRoute_dst = AX_surfxml_ASroute_dst;
820   AX_surfxml_zoneRoute_gw___src = AX_surfxml_ASroute_gw___src;
821   AX_surfxml_zoneRoute_gw___dst = AX_surfxml_ASroute_gw___dst;
822   AX_surfxml_zoneRoute_symmetrical = (AT_surfxml_zoneRoute_symmetrical)AX_surfxml_ASroute_symmetrical;
823   ETag_surfxml_zoneRoute();
824 }
825 void ETag_surfxml_zoneRoute()
826 {
827   s_sg_platf_route_cbarg_t ASroute;
828   memset(&ASroute,0,sizeof(ASroute));
829
830   ASroute.src = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_src); // tested to not be nullptr in start tag
831   ASroute.dst = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_dst); // tested to not be nullptr in start tag
832
833   ASroute.gw_src = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_gw___src); // tested to not be nullptr in start tag
834   ASroute.gw_dst = sg_netpoint_by_name_or_null(A_surfxml_zoneRoute_gw___dst); // tested to not be nullptr in start tag
835
836   ASroute.link_list = new std::vector<simgrid::surf::LinkImpl*>();
837
838   for (auto link: parsed_link_list)
839     ASroute.link_list->push_back(link);
840   parsed_link_list.clear();
841
842   switch (A_surfxml_zoneRoute_symmetrical) {
843   case AU_surfxml_zoneRoute_symmetrical:
844   case A_surfxml_zoneRoute_symmetrical_YES:
845     ASroute.symmetrical = true;
846     break;
847   case A_surfxml_zoneRoute_symmetrical_NO:
848     ASroute.symmetrical = false;
849     break;
850   }
851
852   sg_platf_new_route(&ASroute);
853   delete ASroute.link_list;
854 }
855
856 void ETag_surfxml_bypassRoute(){
857   s_sg_platf_route_cbarg_t route;
858   memset(&route,0,sizeof(route));
859
860   route.src         = sg_netpoint_by_name_or_null(A_surfxml_bypassRoute_src); // tested to not be nullptr in start tag
861   route.dst         = sg_netpoint_by_name_or_null(A_surfxml_bypassRoute_dst); // tested to not be nullptr in start tag
862   route.gw_src = nullptr;
863   route.gw_dst = nullptr;
864   route.symmetrical = false;
865   route.link_list   = new std::vector<simgrid::surf::LinkImpl*>();
866
867   for (auto link: parsed_link_list)
868     route.link_list->push_back(link);
869   parsed_link_list.clear();
870
871   sg_platf_new_bypassRoute(&route);
872   delete route.link_list;
873 }
874
875 void ETag_surfxml_bypassASroute()
876 {
877   AX_surfxml_bypassZoneRoute_src = AX_surfxml_bypassASroute_src;
878   AX_surfxml_bypassZoneRoute_dst = AX_surfxml_bypassASroute_dst;
879   AX_surfxml_bypassZoneRoute_gw___src = AX_surfxml_bypassASroute_gw___src;
880   AX_surfxml_bypassZoneRoute_gw___dst = AX_surfxml_bypassASroute_gw___dst;
881   ETag_surfxml_bypassZoneRoute();
882 }
883 void ETag_surfxml_bypassZoneRoute()
884 {
885   s_sg_platf_route_cbarg_t ASroute;
886   memset(&ASroute,0,sizeof(ASroute));
887
888   ASroute.src         = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_src);
889   ASroute.dst         = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_dst);
890   ASroute.link_list   = new std::vector<simgrid::surf::LinkImpl*>();
891   for (auto link: parsed_link_list)
892     ASroute.link_list->push_back(link);
893   parsed_link_list.clear();
894
895   ASroute.symmetrical = false;
896
897   ASroute.gw_src = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_gw___src);
898   ASroute.gw_dst = sg_netpoint_by_name_or_null(A_surfxml_bypassZoneRoute_gw___dst);
899
900   sg_platf_new_bypassRoute(&ASroute);
901   delete ASroute.link_list;
902 }
903
904 void ETag_surfxml_trace(){
905   s_sg_platf_trace_cbarg_t trace;
906   memset(&trace,0,sizeof(trace));
907
908   trace.id = A_surfxml_trace_id;
909   trace.file = A_surfxml_trace_file;
910   trace.periodicity = surf_parse_get_double(A_surfxml_trace_periodicity);
911   trace.pc_data = surfxml_pcdata;
912
913   sg_platf_new_trace(&trace);
914 }
915
916 void STag_surfxml_trace___connect()
917 {
918   parse_after_config();
919   s_sg_platf_trace_connect_cbarg_t trace_connect;
920   memset(&trace_connect,0,sizeof(trace_connect));
921
922   trace_connect.element = A_surfxml_trace___connect_element;
923   trace_connect.trace = A_surfxml_trace___connect_trace;
924
925   switch (A_surfxml_trace___connect_kind) {
926   case AU_surfxml_trace___connect_kind:
927   case A_surfxml_trace___connect_kind_SPEED:
928     trace_connect.kind =  SURF_TRACE_CONNECT_KIND_SPEED;
929     break;
930   case A_surfxml_trace___connect_kind_BANDWIDTH:
931     trace_connect.kind =  SURF_TRACE_CONNECT_KIND_BANDWIDTH;
932     break;
933   case A_surfxml_trace___connect_kind_HOST___AVAIL:
934     trace_connect.kind =  SURF_TRACE_CONNECT_KIND_HOST_AVAIL;
935     break;
936   case A_surfxml_trace___connect_kind_LATENCY:
937     trace_connect.kind =  SURF_TRACE_CONNECT_KIND_LATENCY;
938     break;
939   case A_surfxml_trace___connect_kind_LINK___AVAIL:
940     trace_connect.kind =  SURF_TRACE_CONNECT_KIND_LINK_AVAIL;
941     break;
942   default:
943     surf_parse_error("Invalid trace kind");
944     break;
945   }
946   sg_platf_trace_connect(&trace_connect);
947 }
948
949 void STag_surfxml_AS()
950 {
951   AX_surfxml_zone_id = AX_surfxml_AS_id;
952   AX_surfxml_zone_routing = (AT_surfxml_zone_routing)AX_surfxml_AS_routing;
953   STag_surfxml_zone();
954 }
955
956 void ETag_surfxml_AS()
957 {
958   ETag_surfxml_zone();
959 }
960
961 void STag_surfxml_zone()
962 {
963   parse_after_config();
964   ZONE_TAG                 = 1;
965   s_sg_platf_AS_cbarg_t AS = {A_surfxml_zone_id, (int)A_surfxml_zone_routing};
966
967   sg_platf_new_AS_begin(&AS);
968 }
969
970 void ETag_surfxml_zone()
971 {
972   sg_platf_new_AS_seal();
973 }
974
975 void STag_surfxml_config()
976 {
977   ZONE_TAG = 0;
978   xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
979   XBT_DEBUG("START configuration name = %s",A_surfxml_config_id);
980   if (_sg_cfg_init_status == 2) {
981     surf_parse_error("All <config> tags must be given before any platform elements (such as <zone>, <host>, <cluster>, "
982                      "<link>, etc).");
983   }
984 }
985
986 void ETag_surfxml_config()
987 {
988   xbt_dict_cursor_t cursor = nullptr;
989   char *key;
990   char *elem;
991   xbt_dict_foreach(current_property_set, cursor, key, elem) {
992     if (xbt_cfg_is_default_value(key)) {
993       std::string cfg = std::string(key) + ":" + elem;
994       xbt_cfg_set_parse(cfg.c_str());
995     } else
996       XBT_INFO("The custom configuration '%s' is already defined by user!",key);
997   }
998   XBT_DEBUG("End configuration name = %s",A_surfxml_config_id);
999
1000   xbt_dict_free(&current_property_set);
1001   current_property_set = nullptr;
1002 }
1003
1004 static int argc;
1005 static char **argv;
1006
1007 void STag_surfxml_process()
1008 {
1009   AX_surfxml_actor_function = AX_surfxml_process_function;
1010   STag_surfxml_actor();
1011 }
1012 void STag_surfxml_actor()
1013 {
1014   ZONE_TAG  = 0;
1015   argc    = 1;
1016   argv    = xbt_new(char *, 1);
1017   argv[0] = xbt_strdup(A_surfxml_actor_function);
1018   xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
1019 }
1020
1021 void ETag_surfxml_process()
1022 {
1023   AX_surfxml_actor_host = AX_surfxml_process_host;
1024   AX_surfxml_actor_function = AX_surfxml_process_function;
1025   AX_surfxml_actor_start___time = AX_surfxml_process_start___time;
1026   AX_surfxml_actor_kill___time = AX_surfxml_process_kill___time;
1027   AX_surfxml_actor_on___failure = (AT_surfxml_actor_on___failure)AX_surfxml_process_on___failure;
1028   ETag_surfxml_actor();
1029 }
1030 void ETag_surfxml_actor()
1031 {
1032   s_sg_platf_process_cbarg_t actor;
1033   memset(&actor,0,sizeof(actor));
1034
1035   actor.argc       = argc;
1036   actor.argv       = (const char **)argv;
1037   actor.properties = current_property_set;
1038   actor.host       = A_surfxml_actor_host;
1039   actor.function   = A_surfxml_actor_function;
1040   actor.start_time = surf_parse_get_double(A_surfxml_actor_start___time);
1041   actor.kill_time  = surf_parse_get_double(A_surfxml_actor_kill___time);
1042
1043   switch (A_surfxml_actor_on___failure) {
1044   case AU_surfxml_actor_on___failure:
1045   case A_surfxml_actor_on___failure_DIE:
1046     actor.on_failure =  SURF_ACTOR_ON_FAILURE_DIE;
1047     break;
1048   case A_surfxml_actor_on___failure_RESTART:
1049     actor.on_failure =  SURF_ACTOR_ON_FAILURE_RESTART;
1050     break;
1051   default:
1052     surf_parse_error("Invalid on failure behavior");
1053     break;
1054   }
1055
1056   sg_platf_new_process(&actor);
1057
1058   for (int i = 0; i != argc; ++i)
1059     xbt_free(argv[i]);
1060   xbt_free(argv);
1061   argv = nullptr;
1062
1063   current_property_set = nullptr;
1064 }
1065
1066 void STag_surfxml_argument(){
1067   argc++;
1068   argv = (char**)xbt_realloc(argv, (argc) * sizeof(char **));
1069   argv[(argc) - 1] = xbt_strdup(A_surfxml_argument_value);
1070 }
1071
1072 void STag_surfxml_model___prop(){
1073   if (not current_model_property_set)
1074     current_model_property_set = new std::map<std::string, std::string>();
1075
1076   current_model_property_set->insert(
1077       {std::string(A_surfxml_model___prop_id), std::string(A_surfxml_model___prop_value)});
1078 }
1079
1080 void ETag_surfxml_prop(){/* Nothing to do */}
1081 void STag_surfxml_random(){/* Nothing to do */}
1082 void ETag_surfxml_random(){/* Nothing to do */}
1083 void ETag_surfxml_trace___connect(){/* Nothing to do */}
1084 void STag_surfxml_trace(){parse_after_config();}
1085 void ETag_surfxml_router(){/*Nothing to do*/}
1086 void ETag_surfxml_host___link(){/* Nothing to do */}
1087 void ETag_surfxml_cabinet(){/* Nothing to do */}
1088 void ETag_surfxml_peer(){/* Nothing to do */}
1089 void STag_surfxml_backbone(){/* Nothing to do */}
1090 void ETag_surfxml_link___ctn(){/* Nothing to do */}
1091 void ETag_surfxml_argument(){/* Nothing to do */}
1092 void ETag_surfxml_model___prop(){/* Nothing to do */}
1093
1094 /* Open and Close parse file */
1095 void surf_parse_open(const char *file)
1096 {
1097   xbt_assert(file, "Cannot parse the nullptr file. Bypassing the parser is strongly deprecated nowadays.");
1098
1099   surf_parsed_filename = xbt_strdup(file);
1100   char* dir            = xbt_dirname(file);
1101   surf_path.push_back(std::string(dir));
1102   xbt_free(dir);
1103
1104   surf_file_to_parse = surf_fopen(file, "r");
1105   xbt_assert(surf_file_to_parse != nullptr, "Unable to open '%s'\n", file);
1106   surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, YY_BUF_SIZE);
1107   surf_parse__switch_to_buffer(surf_input_buffer);
1108   surf_parse_lineno = 1;
1109 }
1110
1111 void surf_parse_close()
1112 {
1113   if (surf_parsed_filename) {
1114     surf_path.pop_back();
1115   }
1116
1117   free(surf_parsed_filename);
1118   surf_parsed_filename = nullptr;
1119
1120   if (surf_file_to_parse) {
1121     surf_parse__delete_buffer(surf_input_buffer);
1122     fclose(surf_file_to_parse);
1123     surf_file_to_parse = nullptr; //Must be reset for Bypass
1124   }
1125 }
1126
1127 /* Call the lexer to parse the currently opened file. This pointer to function enables bypassing of the parser */
1128 static int _surf_parse() {
1129   return surf_parse_lex();
1130 }
1131
1132 int_f_void_t surf_parse = &_surf_parse;
1133
1134 SG_END_DECL()