X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c39f643b5bfb0e99887c209a94e49f841a2daae4..2c2f9b9fa2cf5d207a8b4d7fec333bfb9e23967d:/src/surf/storage_interface.cpp diff --git a/src/surf/storage_interface.cpp b/src/surf/storage_interface.cpp index 4869a5c329..4ddc3c9296 100644 --- a/src/surf/storage_interface.cpp +++ b/src/surf/storage_interface.cpp @@ -1,3 +1,9 @@ +/* Copyright (c) 2013-2014. 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 "storage_interface.hpp" #include "surf_private.h" @@ -14,6 +20,15 @@ int ROUTING_STORAGE_TYPE_LEVEL; //Routing for storage_type level xbt_dynar_t mount_list = NULL; StorageModelPtr surf_storage_model = NULL; +/************* + * Callbacks * + *************/ + +surf_callback(void, StoragePtr) storageCreatedCallbacks; +surf_callback(void, StoragePtr) storageDestructedCallbacks; +surf_callback(void, StoragePtr) storageStateChangedCallbacks; +surf_callback(void, StorageActionPtr) storageActionStateChangedCallbacks; + /********* * Model * *********/ @@ -42,8 +57,9 @@ Storage::Storage(ModelPtr model, const char *name, xbt_dict_t props, , p_typeId(xbt_strdup(type_id)) , p_writeActions(xbt_dynar_new(sizeof(ActionPtr),NULL)) { + surf_callback_emit(storageCreatedCallbacks, this); p_content = parseContent(content_name); - m_stateCurrent = SURF_RESOURCE_ON; + setState(SURF_RESOURCE_ON); } Storage::Storage(ModelPtr model, const char *name, xbt_dict_t props, @@ -54,14 +70,16 @@ Storage::Storage(ModelPtr model, const char *name, xbt_dict_t props, , m_size(size), m_usedSize(0) , p_typeId(xbt_strdup(type_id)) , p_writeActions(xbt_dynar_new(sizeof(ActionPtr),NULL)) { + surf_callback_emit(storageCreatedCallbacks, this); p_content = parseContent(content_name); - m_stateCurrent = SURF_RESOURCE_ON; + setState(SURF_RESOURCE_ON); XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size); p_constraintRead = lmm_constraint_new(maxminSystem, this, bread); p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite); } Storage::~Storage(){ + surf_callback_emit(storageDestructedCallbacks, this); xbt_dict_free(&p_content); xbt_dynar_free(&p_writeActions); free(p_typeId); @@ -116,6 +134,12 @@ void Storage::updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, d THROW_UNIMPLEMENTED; } +void Storage::setState(e_surf_resource_state_t state) +{ + Resource::setState(state); + surf_callback_emit(storageStateChangedCallbacks, this); +} + xbt_dict_t Storage::getContent() { /* For the moment this action has no cost, but in the future we could take in account access latency of the disk */ @@ -136,8 +160,6 @@ sg_size_t Storage::getSize(){ return m_size; } - - /********** * Action * **********/ @@ -154,3 +176,7 @@ StorageAction::StorageAction(ModelPtr model, double cost, bool failed, lmm_varia , m_type(type), p_storage(storage), p_file(NULL), p_lsDict(NULL) { } +void StorageAction::setState(e_surf_action_state_t state){ + Action::setState(state); + surf_callback_emit(storageActionStateChangedCallbacks, this); +}