/* Creates a workstation and registers it in SD.
*/
SD_workstation_t __SD_workstation_create(void *surf_workstation, void *data) {
- CHECK_INIT_DONE();
+ SD_CHECK_INIT_DONE();
xbt_assert0(surf_workstation != NULL, "surf_workstation is NULL !");
SD_workstation_data_t sd_data = xbt_new0(s_SD_workstation_data_t, 1); /* workstation private data */
const char *name = SD_workstation_get_name(workstation);
xbt_dict_set(sd_global->workstations, name, workstation, __SD_workstation_destroy); /* add the workstation to the dictionary */
+ sd_global->workstation_count++;
- /* TODO: route */
return workstation;
}
/* Returns a workstation given its name, or NULL if there is no such workstation.
*/
SD_workstation_t SD_workstation_get_by_name(const char *name) {
- CHECK_INIT_DONE();
+ SD_CHECK_INIT_DONE();
xbt_assert0(name != NULL, "Invalid parameter");
/* Returns a NULL-terminated array of existing workstations.
*/
SD_workstation_t* SD_workstation_get_list(void) {
- CHECK_INIT_DONE();
+ SD_CHECK_INIT_DONE();
SD_workstation_t* array = xbt_new0(SD_workstation_t, sd_global->workstation_count + 1);
/* Returns the number or workstations.
*/
int SD_workstation_get_number(void) {
- CHECK_INIT_DONE();
+ SD_CHECK_INIT_DONE();
return sd_global->workstation_count;
}
/* 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 SD_workstation_set_data(SD_workstation_t workstation, void *data) {
- CHECK_INIT_DONE();
+ SD_CHECK_INIT_DONE();
xbt_assert0(workstation != NULL, "Invalid parameter");
workstation->data = data;
}
/* Returns the data of a workstation. The user data can be NULL.
*/
void* SD_workstation_get_data(SD_workstation_t workstation) {
- CHECK_INIT_DONE();
+ SD_CHECK_INIT_DONE();
xbt_assert0(workstation != NULL, "Invalid parameter");
return workstation->data;
}
/* Returns the name of a workstation.
*/
const char* SD_workstation_get_name(SD_workstation_t workstation) {
- CHECK_INIT_DONE();
+ SD_CHECK_INIT_DONE();
xbt_assert0(workstation != NULL, "Invalid parameter");
return surf_workstation_resource->common_public->get_resource_name(workstation->sd_data->surf_workstation);
}
/* Returns an new array of links representating the route between two workstations.
*/
SD_link_t* SD_workstation_route_get_list(SD_workstation_t src, SD_workstation_t dst) {
- CHECK_INIT_DONE();
+ SD_CHECK_INIT_DONE();
void *surf_src = src->sd_data->surf_workstation;
void *surf_dst = dst->sd_data->surf_workstation;
/* Returns the number of links on the route between two workstations.
*/
int SD_workstation_route_get_size(SD_workstation_t src, SD_workstation_t dst) {
- CHECK_INIT_DONE();
+ SD_CHECK_INIT_DONE();
return surf_workstation_resource->extension_public->
get_route_size(src->sd_data->surf_workstation, dst->sd_data->surf_workstation);
}
/* Returns the total power of a workstation.
*/
double SD_workstation_get_power(SD_workstation_t workstation) {
- CHECK_INIT_DONE();
+ SD_CHECK_INIT_DONE();
xbt_assert0(workstation != NULL, "Invalid parameter");
return surf_workstation_resource->extension_public->get_speed(workstation->sd_data->surf_workstation, 1.0);
}
/* Returns the proportion of available power in a workstation (normally a number between 0 and 1).
*/
double SD_workstation_get_available_power(SD_workstation_t workstation) {
- CHECK_INIT_DONE();
+ SD_CHECK_INIT_DONE();
xbt_assert0(workstation != NULL, "Invalid parameter");
return surf_workstation_resource->extension_public->get_available_speed(workstation->sd_data->surf_workstation);
}
/* Destroys a workstation. The user data (if any) should have been destroyed first.
*/
void __SD_workstation_destroy(void *workstation) {
- CHECK_INIT_DONE();
+ SD_CHECK_INIT_DONE();
xbt_assert0(workstation != NULL, "Invalid parameter");
if (((SD_workstation_t) workstation)->sd_data != NULL) {
xbt_free(((SD_workstation_t) workstation)->sd_data);
}
- /* TODO: route */
-
xbt_free(workstation);
}