--- /dev/null
+/* platf.h - Public interface to the SimGrid platforms */
+
+/* Copyright (c) 2004, 2005, 2006, 2007, 2009, 2010, 2011. The SimGrid Team.
+ * All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef SG_PLATF_H
+#define SG_PLATF_H
+
+#include <xbt.h> /* our toolbox */
+
+XBT_PUBLIC(void) sg_platf_new_AS_open(const char *id, const char *mode);
+XBT_PUBLIC(void) sg_platf_new_AS_close(void);
+
+#endif /* SG_PLATF_H */
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "simgrid_lua.h"
+#include "simgrid/platf.h"
#include <string.h>
#include <ctype.h>
//AS List
static xbt_dynar_t as_list_d;
-/*
- * Initialize platform model routing
- */
-
-static void create_AS(const char *id, const char *mode)
-{
- routing_AS_init(id, mode);
-}
-
/**
* create host resource via CPU model [for MSG]
*/
// Add AS
xbt_dynar_foreach(as_list_d, i,p_as)
{
- create_AS(p_as->id, p_as->mode);
+ sg_platf_new_AS_open(p_as->id,p_as->mode);
// add associated Hosts
xbt_dynar_foreach(p_as->host_list_d, j, p_host){
create_host(p_host->id, p_host->power_peak, p_host->power_scale,
}
// Finalize AS
- routing_AS_end(p_as->id);
+ sg_platf_new_AS_close();
}
// add traces
xbt_dynar_foreach(as_list_d, i, p_as)
{
// Init AS
- create_AS(p_as->id, p_as->mode);
+ sg_platf_new_AS_open(p_as->id,p_as->mode);
// add Sub AS
}
/* </AS> */
// Finalize AS
- routing_AS_end(p_as->id);
+ sg_platf_new_AS_close();
}
// add traces
surf_wsL07_add_traces();
-/* Copyright (c) 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2009, 2010, 2011. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
#include <pcre.h> /* regular expression library */
+
+#include "simgrid/platf.h" // platform creation API
+
#include "surf_routing_private.h"
#include "surf/surf_routing.h"
#include "surf/surfxml_parse_values.h"
}
/**
- * \brief Make a new routing component
+ * \brief Make a new routing component to the platform
+ *
+ * Add a new autonomous system to the platform. Any elements (such as host,
+ * router or sub-AS) added after this call and before the corresponding call
+ * to sg_platf_new_AS_close() will be added to this AS.
+ *
+ * Once this function was called, the configuration concerning the used
+ * models cannot be changed anymore.
*
- * make the new structure and
- * set the parsing functions to allows parsing the part of the routing tree
+ * @param AS_id name of this autonomous system. Must be uniq in the platform
+ * @param wanted_routing_type one of Full, Floyd, Dijkstra or similar. Full list in the variable routing_models, in src/surf/surf_routing.c
*/
-void routing_AS_init(const char *AS_id, const char *wanted_routing_type)
+void sg_platf_new_AS_open(const char *AS_id, const char *wanted_routing_type)
{
routing_component_t new_routing;
model_type_t model = NULL;
}
/**
- * \brief Finish the creation of a new routing component
+ * \brief Specify that the current description of AS is finished
+ *
+ * Once you've declared all the content of your AS, you have to close
+ * it with this call. Your AS is not usable until you call this function.
+ *
+ * @fixme: this call is not as robust as wanted: bad things WILL happen
+ * if you call it twice for the same AS, or if you forget calling it, or
+ * even if you add stuff to a closed AS
*
- * When you finish to read the routing component, other structures must be created.
- * the "end" method allow to do that for any routing model type
*/
-void routing_AS_end(const char *AS_id)
-{
+void sg_platf_new_AS_close() {
if (current_routing == NULL) {
- THROWF(arg_error, 0, "Close AS(%s), that were never opened", AS_id);
+ THROWF(arg_error, 0, "Close an AS, but none was under construction");
} else {
network_element_info_t info = NULL;
xbt_assert(!xbt_lib_get_or_null(as_router_lib,current_routing->name, ROUTING_ASR_LEVEL),
#include "xbt/log.h"
#include "xbt/str.h"
#include "xbt/dict.h"
+#include "simgrid/platf.h"
#include "surf/surfxml_parse_private.h"
#include "surf/surf_private.h"
/* Call the right C function when we see the <AS> tags */
static void parse_S_AS(void) {
- routing_AS_init(A_surfxml_AS_id, A_surfxml_AS_routing);
+ sg_platf_new_AS_open(A_surfxml_AS_id, A_surfxml_AS_routing);
}
static void parse_E_AS(void) {
- routing_AS_end(A_surfxml_AS_id);
+ sg_platf_new_AS_close();
}