static XBT_INLINE void surf_storage_resource_free(void *r)
{
// specific to storage
- Storage *storage = static_cast<Storage*>(r);
+ simgrid::surf::Storage *storage = static_cast<simgrid::surf::Storage*>(r);
// generic resource
delete storage;
}
xbt_dynar_free(&dyn);
}
-static void parse_mstorage_init(sg_platf_mstorage_cbarg_t /*mstorage*/)
+void storage_register_callbacks()
{
- XBT_DEBUG("parse_mstorage_init");
-}
-
-static void parse_mount_init(sg_platf_mount_cbarg_t /*mount*/)
-{
- XBT_DEBUG("parse_mount_init");
-}
-
-static void storage_parse_mstorage(sg_platf_mstorage_cbarg_t /*mstorage*/)
-{
- THROW_UNIMPLEMENTED;
-// mount_t mnt = xbt_new0(s_mount_t, 1);
-// mnt->id = xbt_strdup(mstorage->type_id);
-// mnt->name = xbt_strdup(mstorage->name);
-//
-// if(!mount_list){
-// XBT_DEBUG("Creata a Mount list for %s",A_surfxml_host_id);
-// mount_list = xbt_dynar_new(sizeof(char *), NULL);
-// }
-// xbt_dynar_push(mount_list,(void *) mnt);
-// free(mnt->id);
-// free(mnt->name);
-// xbt_free(mnt);
-// XBT_DEBUG("ROUTING Mount a storage name '%s' with type_id '%s'",mstorage->name, mstorage->id);
-}
-
-static void mount_free(void *p)
-{
- mount_t mnt = (mount_t) p;
- xbt_free(mnt->name);
-}
-
-static void storage_parse_mount(sg_platf_mount_cbarg_t mount)
-{
- // Verification of an existing storage
-#ifndef NDEBUG
- void* storage = xbt_lib_get_or_null(storage_lib, mount->storageId, ROUTING_STORAGE_LEVEL);
-#endif
- xbt_assert(storage,"Disk id \"%s\" does not exists", mount->storageId);
-
- XBT_DEBUG("ROUTING Mount '%s' on '%s'",mount->storageId, mount->name);
-
- s_mount_t mnt;
- mnt.storage = surf_storage_resource_priv(surf_storage_resource_by_name(mount->storageId));
- mnt.name = xbt_strdup(mount->name);
-
- if(!mount_list){
- XBT_DEBUG("Create a Mount list for %s",A_surfxml_host_id);
- mount_list = xbt_dynar_new(sizeof(s_mount_t), mount_free);
- }
- xbt_dynar_push(mount_list, &mnt);
-}
-
-static void storage_define_callbacks()
-{
- sg_platf_mstorage_add_cb(parse_mstorage_init);
- sg_platf_mount_add_cb(parse_mount_init);
-}
-
-void storage_register_callbacks() {
-
ROUTING_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, xbt_free_f);
ROUTING_STORAGE_HOST_LEVEL = xbt_lib_add_level(storage_lib, routing_storage_host_free);
ROUTING_STORAGE_TYPE_LEVEL = xbt_lib_add_level(storage_type_lib, routing_storage_type_free);
SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, surf_storage_resource_free);
-
- sg_platf_mstorage_add_cb(storage_parse_mstorage);
- sg_platf_mount_add_cb(storage_parse_mount);
}
/*********
void surf_storage_model_init_default(void)
{
- surf_storage_model = new StorageN11Model();
- storage_define_callbacks();
+ surf_storage_model = new simgrid::surf::StorageN11Model();
xbt_dynar_push(all_existing_models, &surf_storage_model);
}
+namespace simgrid {
+namespace surf {
+
StorageN11Model::StorageN11Model() : StorageModel() {
Action *action = NULL;
Storage *storage = new StorageN11(this, id, properties, p_maxminSystem,
Bread, Bwrite, Bconnection, type_id, (char *)content_name,
xbt_strdup(content_type), storage_type->size, (char *) attach);
- surf_callback_emit(storageCreatedCallbacks, storage);
+ storageCreatedCallbacks(storage);
xbt_lib_set(storage_lib, id, SURF_STORAGE_LEVEL, storage);
XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s'\n\t\tproperties '%p'\n\t\tBread '%f'\n",
file->mount = xbt_strdup(mount);
file->current_position = 0;
- StorageAction *action = new StorageN11Action(getModel(), 0, getState() != SURF_RESOURCE_ON, this, OPEN);
+ StorageAction *action = new StorageN11Action(getModel(), 0, isOff(), this, OPEN);
action->p_file = file;
return action;
free(fd->name);
free(fd->mount);
xbt_free(fd);
- StorageAction *action = new StorageN11Action(getModel(), 0, getState() != SURF_RESOURCE_ON, this, CLOSE);
+ StorageAction *action = new StorageN11Action(getModel(), 0, isOff(), this, CLOSE);
return action;
}
else
fd->current_position += size;
- StorageAction *action = new StorageN11Action(getModel(), size, getState() != SURF_RESOURCE_ON, this, READ);
+ StorageAction *action = new StorageN11Action(getModel(), size, isOff(), this, READ);
return action;
}
char *filename = fd->name;
XBT_DEBUG("\tWrite file '%s' size '%llu/%llu'",filename,size,fd->size);
- StorageAction *action = new StorageN11Action(getModel(), size, getState() != SURF_RESOURCE_ON, this, WRITE);
+ StorageAction *action = new StorageN11Action(getModel(), size, isOff(), this, WRITE);
action->p_file = fd;
/* Substract the part of the file that might disappear from the used sized on
* the storage element */
THROW_UNIMPLEMENTED;
}
+}
+}