/* now let's create the SG wrappers */
xbt_dict_foreach(workstation_set, cursor, name, workstation) {
-
__SG_workstation_create(name, workstation, NULL);
}
-
}
/* Launches the simulation. Returns a NULL-terminated array of SG_task_t whose state has changed.
SG_task_t* SG_simulate(double how_long)
{
/* TODO */
+
+ /* temporary test to access to the surf workstation structure */
+ xbt_dict_cursor_t cursor = NULL;
+ char *name = NULL;
+ void *workstation = NULL;
+ const char *surf_name;
+ int speed;
+
+ xbt_dict_foreach(workstation_set, cursor, name, workstation) {
+ surf_name = surf_workstation_resource->common_public->get_resource_name(workstation);
+ speed = surf_workstation_resource->extension_public->get_speed(workstation, 1.0);
+ printf("Workstation name: %s, Surf name: %s, speed: %d\n", name, surf_name, speed);
+ }
+
return NULL;
}
return link->data;
}
-/* Sets the user data of a link. The data can be NULL.
+/* Sets the user data of a link. The new data can be NULL. The old data should have been freed first if it was not NULL.
*/
void SG_link_set_data(SG_link_t link, void *data) {
xbt_assert0(link, "Invalid parameter");
void __SG_link_destroy(SG_link_t link) {
xbt_assert0(link, "Invalid parameter");
- if (link->name)
+ if (link->sgdata != NULL)
+ xbt_free(link->sgdata);
+
+ if (link->name != NULL)
xbt_free(link->name);
xbt_free(link);
return sg_global->workstation_count;
}
-/* Sets the data of a workstation.
+/* Sets the data of a workstation. The new data can be NULL. The old data should have been freed first if it was not NULL.
*/
void SG_workstation_set_data(SG_workstation_t workstation, void *data) {
xbt_assert0(workstation != NULL, "Invalid parameter");
workstation->data = data;
}
-/* Returns the data of a workstation.
+/* Returns the data of a workstation. The user data can be NULL.
*/
void* SG_workstation_get_data(SG_workstation_t workstation) {
xbt_assert0(workstation != NULL, "Invalid parameter");
*/
const char* SG_workstation_get_name(SG_workstation_t workstation) {
xbt_assert0(workstation != NULL, "Invalid parameter");
- return NULL;
- /* return workstation->name;*/
+ return workstation->name;
}
SG_link_t* SG_workstation_route_get_list(SG_workstation_t src, SG_workstation_t dst) {
void __SG_workstation_destroy(SG_workstation_t workstation) {
xbt_assert0(workstation != NULL, "Invalid parameter");
- SG_workstation_data_t sgdata = workstation->sgdata;
- if (sgdata != NULL) {
- xbt_free(sgdata);
+ if (workstation->sgdata != NULL) {
+ xbt_free(workstation->sgdata);
+ }
+
+ if (workstation->name != NULL) {
+ xbt_free(workstation->name);
}
/* TODO: route */