xbt_dict_t properties;
} s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
+typedef struct s_surf_parsing_peer_arg *sg_platf_peer_cbarg_t;
+typedef struct s_surf_parsing_peer_arg {
+ const char* id;
+ double power;
+ double bw_in;
+ double bw_out;
+ double lat;
+ const char* coord;
+ tmgr_trace_t availability_trace;
+ tmgr_trace_t state_trace;
+} s_surf_parsing_peer_arg_t;
+
XBT_PUBLIC(void) sg_platf_open(void); // Start a new platform
XBT_PUBLIC(void) sg_platf_close(void); // Finish the creation of the platform
XBT_PUBLIC(void) sg_platf_new_host (sg_platf_host_cbarg_t host); // Add an host to the currently described AS
XBT_PUBLIC(void) sg_platf_new_router(sg_platf_router_cbarg_t router); // Add a router to the currently described AS
XBT_PUBLIC(void) sg_platf_new_link (sg_platf_link_cbarg_t link); // Add a link to the currently described AS
+XBT_PUBLIC(void) sg_platf_new_peer(sg_platf_peer_cbarg_t peer); // Add a peer to the currently described AS
#endif /* SG_PLATF_H */
typedef void (*sg_platf_host_cb_t)(sg_platf_host_cbarg_t);
typedef void (*sg_platf_router_cb_t)(sg_platf_router_cbarg_t);
typedef void (*sg_platf_link_cb_t)(sg_platf_link_cbarg_t);
+typedef void (*sg_platf_peer_cb_t)(sg_platf_peer_cbarg_t);
void sg_platf_host_add_cb(sg_platf_host_cb_t);
void sg_platf_router_add_cb(sg_platf_router_cb_t);
void sg_platf_link_add_cb(sg_platf_link_cb_t);
+void sg_platf_peer_add_cb(sg_platf_peer_cb_t fct);
void sg_platf_postparse_add_cb(void_f_void_t fct);
#ifndef SURFXML_PARSE_VALUES_H_
#define SURFXML_PARSE_VALUES_H_
-typedef struct s_surf_parsing_peer_arg *surf_parsing_peer_arg_t;
-typedef struct s_surf_parsing_peer_arg {
- const char* id;
- double power;
- double bw_in;
- double bw_out;
- double lat;
- const char* coord;
- tmgr_trace_t availability_trace;
- tmgr_trace_t state_trace;
-} s_surf_parsing_peer_arg_t;
typedef struct s_surf_parsing_cluster_arg *surf_parsing_cluster_arg_t;
typedef struct s_surf_parsing_cluster_arg {
extern surf_parsing_cluster_arg_t struct_cluster;
-extern surf_parsing_peer_arg_t struct_peer;
#endif /* SURFXML_PARSE_VALUES_H_ */
xbt_dynar_t sg_platf_host_cb_list = NULL; // of sg_platf_host_cb_t
xbt_dynar_t sg_platf_link_cb_list = NULL; // of sg_platf_link_cb_t
xbt_dynar_t sg_platf_router_cb_list = NULL; // of sg_platf_router_cb_t
+xbt_dynar_t sg_platf_peer_cb_list = NULL; // of sg_platf_peer_cb_t
xbt_dynar_t sg_platf_postparse_cb_list = NULL; // of void_f_void_t
/** Module management function: creates all internal data structures */
sg_platf_host_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
sg_platf_router_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
sg_platf_link_cb_list = xbt_dynar_new(sizeof(sg_platf_host_cb_t), NULL);
+ sg_platf_peer_cb_list = xbt_dynar_new(sizeof(sg_platf_peer_cb_t), NULL);
sg_platf_postparse_cb_list = xbt_dynar_new(sizeof(sg_platf_link_cb_t),NULL);
}
/** Module management function: frees all internal data structures */
xbt_dynar_free(&sg_platf_host_cb_list);
xbt_dynar_free(&sg_platf_router_cb_list);
xbt_dynar_free(&sg_platf_postparse_cb_list);
+ xbt_dynar_free(&sg_platf_peer_cb_list);
}
void sg_platf_new_host(sg_platf_host_cbarg_t h){
(*fun) (link);
}
}
+void sg_platf_new_peer(sg_platf_peer_cbarg_t peer){
+ unsigned int iterator;
+ sg_platf_peer_cb_t fun;
+ xbt_dynar_foreach(sg_platf_link_cb_list, iterator, fun) {
+ (*fun) (peer);
+ }
+}
void sg_platf_open() { /* Do nothing: just for symmetry of user code */ }
void sg_platf_router_add_cb(sg_platf_router_cb_t fct) {
xbt_dynar_push(sg_platf_router_cb_list, &fct);
}
+void sg_platf_peer_add_cb(sg_platf_peer_cb_t fct) {
+ xbt_dynar_push(sg_platf_peer_cb_list, &fct);
+}
void sg_platf_postparse_add_cb(void_f_void_t fct) {
xbt_dynar_push(sg_platf_postparse_cb_list, &fct);
}
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route, surf, "Routing part of surf");
-static void routing_parse_Speer(void); /* peer bypass */
+static void routing_parse_Speer(sg_platf_peer_cbarg_t peer); /* peer bypass */
static void routing_parse_Srandom(void); /* random bypass */
static char* replace_random_parameter(char * chaine);
surfxml_add_callback(STag_surfxml_cluster_cb_list,
&routing_parse_Scluster);
- surfxml_add_callback(STag_surfxml_peer_cb_list,
- &routing_parse_Speer);
-
+ sg_platf_peer_add_cb(routing_parse_Speer); // FIXME: inline in the sg_platf_new_peer instead
sg_platf_postparse_add_cb(clean_routing_after_parse);
#ifdef HAVE_TRACING
xbt_dict_free(&patterns);
}
-static void routing_parse_Speer(void)
+static void routing_parse_Speer(sg_platf_peer_cbarg_t peer)
{
static int AX_ptr = 0;
char *host_id = NULL;
surfxml_bufferstack_push(1);
- XBT_DEBUG("<AS id=\"%s\"\trouting=\"Full\">", struct_peer->id);
- sg_platf_new_AS_open(struct_peer->id, "Full");
+ XBT_DEBUG("<AS id=\"%s\"\trouting=\"Full\">", peer->id);
+ sg_platf_new_AS_open(peer->id, "Full");
XBT_DEBUG(" ");
- host_id = HOST_PEER(struct_peer->id);
- router_id = ROUTER_PEER(struct_peer->id);
- link_id_up = LINK_UP_PEER(struct_peer->id);
- link_id_down = LINK_DOWN_PEER(struct_peer->id);
+ host_id = HOST_PEER(peer->id);
+ router_id = ROUTER_PEER(peer->id);
+ link_id_up = LINK_UP_PEER(peer->id);
+ link_id_down = LINK_DOWN_PEER(peer->id);
- link_router = bprintf("%s_link_router", struct_peer->id);
- link_backbone = bprintf("%s_backbone", struct_peer->id);
+ link_router = bprintf("%s_link_router", peer->id);
+ link_backbone = bprintf("%s_backbone", peer->id);
- XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\"/>", host_id, struct_peer->power);
+ XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\"/>", host_id, peer->power);
s_sg_platf_host_cbarg_t host;
memset(&host,0,sizeof(host));
host.initial_state = SURF_RESOURCE_ON;
host.id = host_id;
- host.power_peak = struct_peer->power;
+ host.power_peak = peer->power;
host.power_scale = 1.0;
- host.power_trace = struct_peer->availability_trace;
- host.state_trace = struct_peer->state_trace;
+ host.power_trace = peer->availability_trace;
+ host.state_trace = peer->state_trace;
host.core_amount = 1;
sg_platf_new_host(&host);
- XBT_DEBUG("<router id=\"%s\"\tcoordinates=\"%s\"/>", router_id, struct_peer->coord);
+ XBT_DEBUG("<router id=\"%s\"\tcoordinates=\"%s\"/>", router_id, peer->coord);
s_sg_platf_router_cbarg_t router;
memset(&router,0,sizeof(router));
router.id = router_id;
- router.coord = struct_peer->coord;
+ router.coord = peer->coord;
sg_platf_new_router(&router);
- XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_id_up, struct_peer->bw_in, struct_peer->lat);
+ XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_id_up, peer->bw_in, peer->lat);
s_sg_platf_link_cbarg_t link;
memset(&link,0,sizeof(link));
link.state = SURF_RESOURCE_ON;
link.policy = SURF_LINK_SHARED;
link.id = link_id_up;
- link.bandwidth = struct_peer->bw_in;
- link.latency = struct_peer->lat;
+ link.bandwidth = peer->bw_in;
+ link.latency = peer->lat;
sg_platf_new_link(&link);
// FIXME: dealing with full duplex is not the role of this piece of code, I'd say [Mt]
// Instead, it should be created fullduplex, and the models will do what's needed in this case
- XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_id_down, struct_peer->bw_out, struct_peer->lat);
+ XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_id_down, peer->bw_out, peer->lat);
link.id = link_id_down;
sg_platf_new_link(&link);
}
void STag_surfxml_peer(void){
- struct_peer = xbt_new0(s_surf_parsing_peer_arg_t, 1);
- struct_peer->id = A_surfxml_peer_id;
- struct_peer->power = surf_parse_get_double(A_surfxml_peer_power);
- struct_peer->bw_in = surf_parse_get_double(A_surfxml_peer_bw_in);
- struct_peer->bw_out = surf_parse_get_double(A_surfxml_peer_bw_out);
- struct_peer->lat = surf_parse_get_double(A_surfxml_peer_lat);
- struct_peer->coord = A_surfxml_peer_coordinates;
- struct_peer->availability_trace = tmgr_trace_new(A_surfxml_peer_availability_file);
- struct_peer->state_trace = tmgr_trace_new(A_surfxml_peer_state_file);
+ s_surf_parsing_peer_arg_t peer;
+ memset(&peer,0,sizeof(peer));
+ peer.id = A_surfxml_peer_id;
+ peer.power = surf_parse_get_double(A_surfxml_peer_power);
+ peer.bw_in = surf_parse_get_double(A_surfxml_peer_bw_in);
+ peer.bw_out = surf_parse_get_double(A_surfxml_peer_bw_out);
+ peer.lat = surf_parse_get_double(A_surfxml_peer_lat);
+ peer.coord = A_surfxml_peer_coordinates;
+ peer.availability_trace = tmgr_trace_new(A_surfxml_peer_availability_file);
+ peer.state_trace = tmgr_trace_new(A_surfxml_peer_state_file);
+
surfxml_call_cb_functions(STag_surfxml_peer_cb_list);
+ sg_platf_new_peer(&peer);
}
void ETag_surfxml_peer(void){
- surfxml_call_cb_functions(ETag_surfxml_peer_cb_list);
- xbt_free(struct_peer);
+ /* nothing to do here */
}
void STag_surfxml_link(void){
s_sg_platf_link_cbarg_t link;
*/
surf_parsing_cluster_arg_t struct_cluster = NULL;
-surf_parsing_peer_arg_t struct_peer = NULL;
/*
* Trace related stuff