From 8b170c65c7f1daa87221caaffee907b6cf73b01d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20B=C3=A9daride?= Date: Tue, 25 Mar 2014 10:42:44 +0100 Subject: [PATCH] Change StateChanged callback signatures --- buildtools/Cmake/DefinePackages.cmake | 3 + .../ReservationPlugin.java | 8 +- examples/java/surfPlugin/TracePlugin.java | 8 +- src/bindings/java/surf.i | 17 +++++ src/bindings/java/surf_swig.cpp | 8 +- src/bindings/java/surf_swig.hpp | 8 +- src/surf/cpu_interface.cpp | 10 ++- src/surf/cpu_interface.hpp | 50 ++++++------ src/surf/network_interface.cpp | 11 ++- src/surf/network_interface.hpp | 48 ++++++------ src/surf/plugins/energy.cpp | 6 +- src/surf/storage_interface.cpp | 10 ++- src/surf/storage_interface.hpp | 38 +++++----- src/surf/workstation_interface.cpp | 10 ++- src/surf/workstation_interface.hpp | 76 +++++++++---------- 15 files changed, 170 insertions(+), 141 deletions(-) diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index 2c0e140ae3..d7b0a5a6ea 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -505,6 +505,9 @@ set(JSURF_JAVA_GENERATED_SRC ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/NetworkLink.java ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/NetworkAction.java + ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/ActionState.java + ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/ResourceState.java + ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/LmmConstraint.java ${CMAKE_BINARY_DIR}/src/bindings/java/org/simgrid/surf/XbtDict.java ) diff --git a/examples/java/reservationSurfPlugin/ReservationPlugin.java b/examples/java/reservationSurfPlugin/ReservationPlugin.java index 0bd91aa5d1..8a637a802f 100644 --- a/examples/java/reservationSurfPlugin/ReservationPlugin.java +++ b/examples/java/reservationSurfPlugin/ReservationPlugin.java @@ -34,11 +34,11 @@ public class ReservationPlugin extends Plugin { Msg.info("Trace: Cpu destructed "+cpu.getName()); } - public void cpuStateChangedCallback(Cpu cpu){ + public void cpuStateChangedCallback(Cpu cpu, ResourceState old, ResourceState cur){ Msg.info("Trace: Cpu state changed "+cpu.getName()); } - public void cpuActionStateChangedCallback(CpuAction action){ + public void cpuActionStateChangedCallback(CpuAction action, ActionState old, ActionState cur){ Msg.info("Trace: CpuAction state changed "+action.getModel().getName()); } @@ -50,11 +50,11 @@ public class ReservationPlugin extends Plugin { Msg.info("Trace: NetworkLink destructed "+link.getName()); } - public void networkLinkStateChangedCallback(NetworkLink link){ + public void networkLinkStateChangedCallback(NetworkLink link, ResourceState old, ResourceState cur){ Msg.info("Trace: NetworkLink state changed "+link.getName()); } - public void networkActionStateChangedCallback(NetworkAction action){ + public void networkActionStateChangedCallback(NetworkAction action, ActionState old, ActionState cur){ Msg.info("Trace: NetworkAction state changed "+action.getModel().getName()); } diff --git a/examples/java/surfPlugin/TracePlugin.java b/examples/java/surfPlugin/TracePlugin.java index 6de18235e8..0d1fec44d2 100644 --- a/examples/java/surfPlugin/TracePlugin.java +++ b/examples/java/surfPlugin/TracePlugin.java @@ -26,11 +26,11 @@ public class TracePlugin extends Plugin { Msg.info("Trace: Cpu destructed "+cpu.getName()); } - public void cpuStateChangedCallback(Cpu cpu){ + public void cpuStateChangedCallback(Cpu cpu, ResourceState old, ResourceState cur){ Msg.info("Trace: Cpu state changed "+cpu.getName()); } - public void cpuActionStateChangedCallback(CpuAction action){ + public void cpuActionStateChangedCallback(CpuAction action, ActionState old, ActionState cur){ Msg.info("Trace: CpuAction state changed "+action.getModel().getName()); } @@ -42,11 +42,11 @@ public class TracePlugin extends Plugin { Msg.info("Trace: NetworkLink destructed "+link.getName()); } - public void networkLinkStateChangedCallback(NetworkLink link){ + public void networkLinkStateChangedCallback(NetworkLink link, ResourceState old, ResourceState cur){ Msg.info("Trace: NetworkLink state changed "+link.getName()); } - public void networkActionStateChangedCallback(NetworkAction action){ + public void networkActionStateChangedCallback(NetworkAction action, ActionState old, ActionState cur){ Msg.info("Trace: NetworkAction state changed "+action.getModel().getName()); } diff --git a/src/bindings/java/surf.i b/src/bindings/java/surf.i index d860b98256..4f247b16f1 100644 --- a/src/bindings/java/surf.i +++ b/src/bindings/java/surf.i @@ -111,3 +111,20 @@ struct s_xbt_dict { char *getValue(char *key) {return (char*)xbt_dict_get_or_null($self, key);} } }; + +%rename e_surf_action_state_t ActionState; +typedef enum { + SURF_ACTION_READY = 0, /**< Ready */ + SURF_ACTION_RUNNING, /**< Running */ + SURF_ACTION_FAILED, /**< Task Failure */ + SURF_ACTION_DONE, /**< Completed */ + SURF_ACTION_TO_FREE, /**< Action to free in next cleanup */ + SURF_ACTION_NOT_IN_THE_SYSTEM + /**< Not in the system anymore. Why did you ask ? */ +} e_surf_action_state_t; + +%rename e_surf_resource_state_t ResourceState; +typedef enum { + SURF_RESOURCE_ON = 1, /**< Up & ready */ + SURF_RESOURCE_OFF = 0 /**< Down & broken */ +} e_surf_resource_state_t; diff --git a/src/bindings/java/surf_swig.cpp b/src/bindings/java/surf_swig.cpp index 32f557f819..5432d48d4d 100644 --- a/src/bindings/java/surf_swig.cpp +++ b/src/bindings/java/surf_swig.cpp @@ -39,11 +39,11 @@ void Plugin::activateCpuDestructedCallback(){ } void Plugin::activateCpuStateChangedCallback(){ - surf_callback_connect(cpuStateChangedCallbacks, boost::bind(&Plugin::cpuStateChangedCallback, this, _1)); + surf_callback_connect(cpuStateChangedCallbacks, boost::bind(&Plugin::cpuStateChangedCallback, this, _1, _2, _3)); } void Plugin::activateCpuActionStateChangedCallback(){ - surf_callback_connect(cpuActionStateChangedCallbacks, boost::bind(&Plugin::cpuActionStateChangedCallback, this, _1)); + surf_callback_connect(cpuActionStateChangedCallbacks, boost::bind(&Plugin::cpuActionStateChangedCallback, this, _1, _2, _3)); } @@ -56,11 +56,11 @@ void Plugin::activateNetworkLinkDestructedCallback(){ } void Plugin::activateNetworkLinkStateChangedCallback(){ - surf_callback_connect(networkLinkStateChangedCallbacks, boost::bind(&Plugin::networkLinkStateChangedCallback, this, _1)); + surf_callback_connect(networkLinkStateChangedCallbacks, boost::bind(&Plugin::networkLinkStateChangedCallback, this, _1, _2, _3)); } void Plugin::activateNetworkActionStateChangedCallback(){ - surf_callback_connect(networkActionStateChangedCallbacks, boost::bind(&Plugin::networkActionStateChangedCallback, this, _1)); + surf_callback_connect(networkActionStateChangedCallbacks, boost::bind(&Plugin::networkActionStateChangedCallback, this, _1, _2, _3)); } diff --git a/src/bindings/java/surf_swig.hpp b/src/bindings/java/surf_swig.hpp index 1c51c7b6c8..2fad2c3e20 100644 --- a/src/bindings/java/surf_swig.hpp +++ b/src/bindings/java/surf_swig.hpp @@ -25,10 +25,10 @@ public: virtual void cpuDestructedCallback(Cpu *cpu) {} void activateCpuStateChangedCallback(); - virtual void cpuStateChangedCallback(Cpu *cpu) {} + virtual void cpuStateChangedCallback(Cpu *cpu, e_surf_resource_state_t, e_surf_resource_state_t) {} void activateCpuActionStateChangedCallback(); - virtual void cpuActionStateChangedCallback(CpuAction *action) {} + virtual void cpuActionStateChangedCallback(CpuAction *action, e_surf_action_state_t, e_surf_action_state_t) {} void activateNetworkLinkCreatedCallback(); @@ -38,10 +38,10 @@ public: virtual void networkLinkDestructedCallback(NetworkLink *link) {} void activateNetworkLinkStateChangedCallback(); - virtual void networkLinkStateChangedCallback(NetworkLink *link) {} + virtual void networkLinkStateChangedCallback(NetworkLink *link, e_surf_resource_state_t, e_surf_resource_state_t) {} void activateNetworkActionStateChangedCallback(); - virtual void networkActionStateChangedCallback(NetworkAction *action) {} + virtual void networkActionStateChangedCallback(NetworkAction *action, e_surf_action_state_t old, e_surf_action_state_t cur) {} }; diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 736b29ee87..246f48ff16 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -25,8 +25,8 @@ CpuPtr getActionCpu(CpuActionPtr action) { surf_callback(void, CpuPtr) cpuCreatedCallbacks; surf_callback(void, CpuPtr) cpuDestructedCallbacks; -surf_callback(void, CpuPtr) cpuStateChangedCallbacks; -surf_callback(void, CpuActionPtr) cpuActionStateChangedCallbacks; +surf_callback(void, CpuPtr, e_surf_resource_state_t, e_surf_resource_state_t) cpuStateChangedCallbacks; +surf_callback(void, CpuActionPtr, e_surf_action_state_t, e_surf_action_state_t) cpuActionStateChangedCallbacks; /********* * Model * @@ -203,8 +203,9 @@ int Cpu::getCore() void Cpu::setState(e_surf_resource_state_t state) { + e_surf_resource_state_t old = Resource::getState(); Resource::setState(state); - surf_callback_emit(cpuStateChangedCallbacks, this); + surf_callback_emit(cpuStateChangedCallbacks, this, old, state); } /********** * Action * @@ -309,6 +310,7 @@ void CpuAction::setAffinity(CpuPtr cpu, unsigned long mask) } void CpuAction::setState(e_surf_action_state_t state){ + e_surf_action_state_t old = getState(); Action::setState(state); - surf_callback_emit(cpuActionStateChangedCallbacks, this); + surf_callback_emit(cpuActionStateChangedCallbacks, this, old, state); } diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index c72e0f5a40..7e2203f05c 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -31,28 +31,28 @@ typedef CpuPlugin *CpuPluginPtr; CpuPtr getActionCpu(CpuActionPtr action); /** @ingroup SURF_callbacks - * @brief Callbacks handler which emit the callbacks after Cpu creation * + * @brief Callbacks handler which emit the callbacks after Cpu creation * * @details Callback functions have the following signature: `void(CpuPtr)` */ extern surf_callback(void, CpuPtr) cpuCreatedCallbacks; /** @ingroup SURF_callbacks - * @brief Callbacks handler which emit the callbacks after Cpu destruction * + * @brief Callbacks handler which emit the callbacks after Cpu destruction * * @details Callback functions have the following signature: `void(CpuPtr)` */ extern surf_callback(void, CpuPtr) cpuDestructedCallbacks; /** @ingroup SURF_callbacks - * @brief Callbacks handler which emit the callbacks after Cpu State changed * - * @details Callback functions have the following signature: `void(CpuActionPtr)` + * @brief Callbacks handler which emit the callbacks after Cpu State changed * + * @details Callback functions have the following signature: `void(CpuActionPtr action, e_surf_resource_state_t old, e_surf_resource_state_t current)` */ -extern surf_callback(void, CpuPtr) cpuStateChangedCallbacks; +extern surf_callback(void, CpuPtr, e_surf_resource_state_t, e_surf_resource_state_t) cpuStateChangedCallbacks; /** @ingroup SURF_callbacks - * @brief Callbacks handler which emit the callbacks after CpuAction State changed * - * @details Callback functions have the following signature: `void(CpuActionPtr)` + * @brief Callbacks handler which emit the callbacks after CpuAction State changed * + * @details Callback functions have the following signature: `void(CpuActionPtr action, e_surf_action_state_t old, e_surf_action_state_t current)` */ -extern surf_callback(void, CpuActionPtr) cpuActionStateChangedCallbacks; +extern surf_callback(void, CpuActionPtr, e_surf_action_state_t, e_surf_action_state_t) cpuActionStateChangedCallbacks; /********* * Model * @@ -66,16 +66,16 @@ class CpuModel : public Model { public: /** * @brief CpuModel constructor - * + * * @param name The name of the model */ CpuModel(const char *name) : Model(name) {}; /** * @brief Create a Cpu - * + * * @param name The name of the Cpu - * + * * @return The created Cpu */ CpuPtr createResource(string name); @@ -105,7 +105,7 @@ public: /** * @brief Cpu constructor - * + * * @param model The CpuModel associated to this Cpu * @param name The name of the Cpu * @param props Dictionary of properties associated to this Cpu @@ -119,7 +119,7 @@ public: /** * @brief Cpu constructor - * + * * @param model The CpuModel associated to this Cpu * @param name The name of the Cpu * @param props Dictionary of properties associated to this Cpu @@ -137,7 +137,7 @@ public: /** * @brief Execute some quantity of computation - * + * * @param size The value of the processing amount (in flop) needed to process * @return The CpuAction corresponding to the processing */ @@ -145,7 +145,7 @@ public: /** * @brief Make a process sleep for duration (in seconds) - * + * * @param duration The number of seconds to sleep * @return The CpuAction corresponding to the sleeping */ @@ -153,7 +153,7 @@ public: /** * @brief Get the number of cores of the current Cpu - * + * * @return The number of cores of the current Cpu */ virtual int getCore(); @@ -161,9 +161,9 @@ public: /** * @brief Get the speed of the current Cpu * @details [TODO] load * m_powerPeak - * + * * @param load [TODO] - * + * * @return The speed of the current Cpu */ virtual double getSpeed(double load); @@ -171,23 +171,23 @@ public: /** * @brief Get the available speed of the current Cpu * @details [TODO] - * + * * @return The available speed of the current Cpu */ virtual double getAvailableSpeed(); /** * @brief Get the current Cpu power peak - * + * * @return The current Cpu power peak */ virtual double getCurrentPowerPeak()=0; virtual double getPowerPeakAt(int pstate_index)=0; - + virtual int getNbPstates()=0; - + virtual void setPowerPeakAt(int pstate_index)=0; void setState(e_surf_resource_state_t state); @@ -220,7 +220,7 @@ public: /** * @brief CpuAction constructor - * + * * @param model The CpuModel associated to this CpuAction * @param cost [TODO] * @param failed [TODO] @@ -230,7 +230,7 @@ public: /** * @brief CpuAction constructor - * + * * @param model The CpuModel associated to this CpuAction * @param cost [TODO] * @param failed [TODO] @@ -242,7 +242,7 @@ public: /** * @brief Set the affinity of the current CpuAction * @details [TODO] - * + * * @param cpu [TODO] * @param mask [TODO] */ diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 49e4c6d248..f6d186321b 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -19,8 +19,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network, surf, surf_callback(void, NetworkLinkPtr) networkLinkCreatedCallbacks; surf_callback(void, NetworkLinkPtr) networkLinkDestructedCallbacks; -surf_callback(void, NetworkLinkPtr) networkLinkStateChangedCallbacks; -surf_callback(void, NetworkActionPtr) networkActionStateChangedCallbacks; +surf_callback(void, NetworkLinkPtr, e_surf_resource_state_t, e_surf_resource_state_t) networkLinkStateChangedCallbacks; +surf_callback(void, NetworkActionPtr, e_surf_action_state_t, e_surf_action_state_t) networkActionStateChangedCallbacks; /********* * Model * @@ -89,8 +89,9 @@ bool NetworkLink::isShared() } void NetworkLink::setState(e_surf_resource_state_t state){ + e_surf_resource_state_t old = Resource::getState(); Resource::setState(state); - surf_callback_emit(networkLinkStateChangedCallbacks, this); + surf_callback_emit(networkLinkStateChangedCallbacks, this, old, state); } /********** @@ -98,8 +99,10 @@ void NetworkLink::setState(e_surf_resource_state_t state){ **********/ void NetworkAction::setState(e_surf_action_state_t state){ + e_surf_action_state_t old = getState(); Action::setState(state); - surf_callback_emit(networkActionStateChangedCallbacks, this); + surf_callback_emit(networkActionStateChangedCallbacks, this, old, state); + } #endif /* NETWORK_INTERFACE_CPP_ */ diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 8988357d7c..37241e44bc 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -27,28 +27,28 @@ typedef NetworkAction *NetworkActionPtr; *************/ /** @ingroup SURF_callbacks - * @brief Callbacks handler which emit the callbacks after NetworkLink creation * + * @brief Callbacks handler which emit the callbacks after NetworkLink creation * @details Callback functions have the following signature: `void(NetworkLinkPtr)` */ extern surf_callback(void, NetworkLinkPtr) networkLinkCreatedCallbacks; /** @ingroup SURF_callbacks - * @brief Callbacks handler which emit the callbacks after NetworkLink destruction * + * @brief Callbacks handler which emit the callbacks after NetworkLink destruction * @details Callback functions have the following signature: `void(NetworkLinkPtr)` */ extern surf_callback(void, NetworkLinkPtr) networkLinkDestructedCallbacks; /** @ingroup SURF_callbacks - * @brief Callbacks handler which emit the callbacks after NetworkLink State changed * - * @details Callback functions have the following signature: `void(NetworkLinkActionPtr)` + * @brief Callbacks handler which emit the callbacks after NetworkLink State changed + * @details Callback functions have the following signature: `void(NetworkLinkActionPtr action, e_surf_resource_state_t old, e_surf_resource_state_t current)` */ -extern surf_callback(void, NetworkLinkPtr) networkLinkStateChangedCallbacks; +extern surf_callback(void, NetworkLinkPtr, e_surf_resource_state_t, e_surf_resource_state_t) networkLinkStateChangedCallbacks; /** @ingroup SURF_callbacks - * @brief Callbacks handler which emit the callbacks after NetworkAction State changed * - * @details Callback functions have the following signature: `void(NetworkActionPtr)` + * @brief Callbacks handler which emit the callbacks after NetworkAction State changed + * @details Callback functions have the following signature: `void(NetworkActionPtr action, e_surf_action_state_t old, e_surf_action_state_t current)` */ -extern surf_callback(void, NetworkActionPtr) networkActionStateChangedCallbacks; +extern surf_callback(void, NetworkActionPtr, e_surf_action_state_t, e_surf_action_state_t) networkActionStateChangedCallbacks; /********* * Tools * @@ -73,7 +73,7 @@ public: /** * @brief NetworkModel constructor - * + * * @param name The name of the NetworkModel */ NetworkModel(const char *name) : Model(name) { @@ -95,7 +95,7 @@ public: /** * @brief Create a NetworkLink - * + * * @param name The name of the NetworkLink * @param bw_initial The initial bandwidth of the NetworkLink in bytes per second * @param bw_trace The trace associated to the NetworkLink bandwidth [TODO] @@ -123,11 +123,11 @@ public: /** * @brief Create a communication between two [TODO] * @details [TODO] - * + * * @param src The source [TODO] * @param dst The destination [TODO] * @param size The size of the communication in bytes - * @param rate The + * @param rate The * @return The action representing the communication */ virtual ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst, @@ -135,7 +135,7 @@ public: /** * @brief Function pointer to the function to use to solve the lmm_system_t - * + * * @param system The lmm_system_t to solve */ void (*f_networkSolve)(lmm_system_t); @@ -143,7 +143,7 @@ public: /** * @brief [brief description] * @details [long description] - * + * * @param size [description] * @return [description] */ @@ -152,7 +152,7 @@ public: /** * @brief [brief description] * @details [long description] - * + * * @param size [description] * @return [description] */ @@ -161,7 +161,7 @@ public: /** * @brief [brief description] * @details [long description] - * + * * @param rate [description] * @param bound [description] * @param size [description] @@ -182,7 +182,7 @@ class NetworkLink : public Resource { public: /** * @brief NetworkLink constructor - * + * * @param model The CpuModel associated to this NetworkLink * @param name The name of the NetworkLink * @param props Dictionary of properties associated to this NetworkLink @@ -191,7 +191,7 @@ public: /** * @brief NetworkLink constructor - * + * * @param model The CpuModel associated to this NetworkLink * @param name The name of the NetworkLink * @param props Dictionary of properties associated to this NetworkLink @@ -211,14 +211,14 @@ public: /** * @brief Get the bandwidth in bytes per second of current NetworkLink - * + * * @return The bandwith in bytes per second of the current NetworkLink */ virtual double getBandwidth(); /** * @brief Get the latency in seconds of current NetworkLink - * + * * @return The latency in seconds of the current NetworkLink */ virtual double getLatency(); @@ -226,14 +226,14 @@ public: /** * @brief Check if the NetworkLink is shared * @details [long description] - * + * * @return true if the current NetwokrLink is shared, false otherwise */ virtual bool isShared(); /** * @brief Check if the NetworkLink is used - * + * * @return true if the current NetwokrLink is used, false otherwise */ bool isUsed(); @@ -261,7 +261,7 @@ class NetworkAction : public Action { public: /** * @brief NetworkAction constructor - * + * * @param model The NetworkModel associated to this NetworkAction * @param cost The cost of this NetworkAction in [TODO] * @param failed [description] @@ -271,7 +271,7 @@ public: /** * @brief NetworkAction constructor - * + * * @param model The NetworkModel associated to this NetworkAction * @param cost The cost of this NetworkAction in [TODO] * @param failed [description] diff --git a/src/surf/plugins/energy.cpp b/src/surf/plugins/energy.cpp index 993ac0b7ed..4fd94acf79 100644 --- a/src/surf/plugins/energy.cpp +++ b/src/surf/plugins/energy.cpp @@ -8,8 +8,8 @@ #include "../cpu_cas01.hpp" /** @addtogroup SURF_plugin_energy - * - * + * + * * BlaBla energy */ @@ -31,7 +31,7 @@ static void energyCpuDestructedCallback(CpuPtr cpu){ surf_energy->erase(cpuIt); } -static void energyCpuActionStateChangedCallback(CpuActionPtr action){ +static void energyCpuActionStateChangedCallback(CpuActionPtr action, e_surf_action_state_t old, e_surf_action_state_t cur){ CpuPtr cpu = getActionCpu(action); CpuEnergyPtr cpu_energy = (*surf_energy)[cpu]; diff --git a/src/surf/storage_interface.cpp b/src/surf/storage_interface.cpp index 5e1ef7340f..d1c824d2fb 100644 --- a/src/surf/storage_interface.cpp +++ b/src/surf/storage_interface.cpp @@ -26,8 +26,8 @@ StorageModelPtr surf_storage_model = NULL; surf_callback(void, StoragePtr) storageCreatedCallbacks; surf_callback(void, StoragePtr) storageDestructedCallbacks; -surf_callback(void, StoragePtr) storageStateChangedCallbacks; -surf_callback(void, StorageActionPtr) storageActionStateChangedCallbacks; +surf_callback(void, StoragePtr, e_surf_resource_state_t, e_surf_resource_state_t) storageStateChangedCallbacks; +surf_callback(void, StorageActionPtr, e_surf_action_state_t, e_surf_action_state_t) storageActionStateChangedCallbacks; /********* * Model * @@ -138,8 +138,9 @@ void Storage::updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, d void Storage::setState(e_surf_resource_state_t state) { + e_surf_resource_state_t old = Resource::getState(); Resource::setState(state); - surf_callback_emit(storageStateChangedCallbacks, this); + surf_callback_emit(storageStateChangedCallbacks, this, old, state); } xbt_dict_t Storage::getContent() @@ -179,6 +180,7 @@ StorageAction::StorageAction(ModelPtr model, double cost, bool failed, lmm_varia } void StorageAction::setState(e_surf_action_state_t state){ + e_surf_action_state_t old = getState(); Action::setState(state); - surf_callback_emit(storageActionStateChangedCallbacks, this); + surf_callback_emit(storageActionStateChangedCallbacks, this, old, state); } diff --git a/src/surf/storage_interface.hpp b/src/surf/storage_interface.hpp index c63d044a69..d0e7df6038 100644 --- a/src/surf/storage_interface.hpp +++ b/src/surf/storage_interface.hpp @@ -48,15 +48,15 @@ extern surf_callback(void, StoragePtr) storageDestructedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after Storage State changed * - * @details Callback functions have the following signature: `void(StorageActionPtr)` + * @details Callback functions have the following signature: `void(StorageActionPtr action, e_surf_resource_state_t old, e_surf_resource_state_t current)` */ -extern surf_callback(void, StoragePtr) storageStateChangedCallbacks; +extern surf_callback(void, StoragePtr, e_surf_resource_state_t, e_surf_resource_state_t) storageStateChangedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after StorageAction State changed * - * @details Callback functions have the following signature: `void(StorageActionPtr)` + * @details Callback functions have the following signature: `void(StorageActionPtr action, e_surf_action_state_t old, e_surf_action_state_t current)` */ -extern surf_callback(void, StorageActionPtr) storageActionStateChangedCallbacks; +extern surf_callback(void, StorageActionPtr, e_surf_action_state_t, e_surf_action_state_t) storageActionStateChangedCallbacks; /********* * Model * @@ -79,7 +79,7 @@ public: /** * @brief Create a Storage - * + * * @param id [description] * @param type_id [description] * @param content_name [description] @@ -109,7 +109,7 @@ class Storage : public Resource { public: /** * @brief Storage constructor - * + * * @param model StorageModel associated to this Storage * @param name The name of the Storage * @param props Dictionary of properties associated to this Storage @@ -124,7 +124,7 @@ public: /** * @brief Storage constructor - * + * * @param model StorageModel associated to this Storage * @param name The name of the Storage * @param props Dictionary of properties associated to this Storage @@ -151,14 +151,14 @@ public: /** * @brief Check if the Storage is used - * + * * @return true if the current Storage is used, false otherwise */ bool isUsed(); /** * @brief Update the state of the current Storage - * + * * @param event_type [description] * @param value [description] * @param date [description] @@ -176,17 +176,17 @@ public: /** * @brief Open a file - * + * * @param mount The mount point * @param path The path to the file - * + * * @return The StorageAction corresponding to the opening */ virtual StorageActionPtr open(const char* mount, const char* path)=0; /** * @brief Close a file - * + * * @param fd The file descriptor to close * @return The StorageAction corresponding to the closing */ @@ -195,7 +195,7 @@ public: /** * @brief List directory contents of a path * @details [long description] - * + * * @param path The path to the directory * @return The StorageAction corresponding to the ls action */ @@ -203,7 +203,7 @@ public: /** * @brief Read a file - * + * * @param fd The file descriptor to read * @param size The size in bytes to read * @return The StorageAction corresponding to the reading @@ -212,7 +212,7 @@ public: /** * @brief Write a file - * + * * @param fd The file descriptor to write * @param size The size in bytes to write * @return The StorageAction corresponding to the writing @@ -221,14 +221,14 @@ public: /** * @brief Get the content of the current Storage - * + * * @return A xbt_dict_t with path as keys and size in bytes as values */ virtual xbt_dict_t getContent(); /** * @brief Get the size in bytes of the current Storage - * + * * @return The size in bytes of the current Storage */ virtual sg_size_t getSize(); @@ -269,7 +269,7 @@ public: /** * @brief StorageAction constructor - * + * * @param model The StorageModel associated to this StorageAction * @param cost The cost of this NetworkAction in [TODO] * @param failed [description] @@ -281,7 +281,7 @@ public: /** * @brief StorageAction constructor - * + * * @param model The StorageModel associated to this StorageAction * @param cost The cost of this StorageAction in [TODO] * @param failed [description] diff --git a/src/surf/workstation_interface.cpp b/src/surf/workstation_interface.cpp index b04b7195d8..dae99c941d 100644 --- a/src/surf/workstation_interface.cpp +++ b/src/surf/workstation_interface.cpp @@ -22,8 +22,8 @@ WorkstationModelPtr surf_workstation_model = NULL; surf_callback(void, WorkstationPtr) workstationCreatedCallbacks; surf_callback(void, WorkstationPtr) workstationDestructedCallbacks; -surf_callback(void, WorkstationPtr) workstationStateChangedCallbacks; -surf_callback(void, WorkstationActionPtr) workstationActionStateChangedCallbacks; +surf_callback(void, WorkstationPtr, e_surf_resource_state_t, e_surf_resource_state_t) workstationStateChangedCallbacks; +surf_callback(void, WorkstationActionPtr, e_surf_action_state_t, e_surf_action_state_t) workstationActionStateChangedCallbacks; /********* * Model * @@ -112,8 +112,9 @@ Workstation::~Workstation(){ } void Workstation::setState(e_surf_resource_state_t state){ + e_surf_resource_state_t old = Resource::getState(); Resource::setState(state); - surf_callback_emit(workstationStateChangedCallbacks, this); + surf_callback_emit(workstationStateChangedCallbacks, this, old, state); } int Workstation::getCore(){ @@ -507,6 +508,7 @@ void Workstation::setParams(ws_params_t params) **********/ void WorkstationAction::setState(e_surf_action_state_t state){ + e_surf_action_state_t old = getState(); Action::setState(state); - surf_callback_emit(workstationActionStateChangedCallbacks, this); + surf_callback_emit(workstationActionStateChangedCallbacks, this, old, state); } diff --git a/src/surf/workstation_interface.hpp b/src/surf/workstation_interface.hpp index c472d377c6..799ee13ac9 100644 --- a/src/surf/workstation_interface.hpp +++ b/src/surf/workstation_interface.hpp @@ -43,15 +43,15 @@ extern surf_callback(void, WorkstationPtr) workstationDestructedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after Workstation State changed * - * @details Callback functions have the following signature: `void(WorkstationActionPtr)` + * @details Callback functions have the following signature: `void(WorkstationActionPtr action, e_surf_resource_state_t old, e_surf_resource_state_t current)` */ -extern surf_callback(void, WorkstationPtr) workstationStateChangedCallbacks; +extern surf_callback(void, WorkstationPtr, e_surf_resource_state_t, e_surf_resource_state_t) workstationStateChangedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after WorkstationAction State changed * - * @details Callback functions have the following signature: `void(WorkstationActionPtr)` + * @details Callback functions have the following signature: `void(WorkstationActionPtr action, e_surf_resource_state_t old, e_surf_resource_state_t current)` */ -extern surf_callback(void, WorkstationActionPtr) workstationActionStateChangedCallbacks; +extern surf_callback(void, WorkstationActionPtr, e_surf_action_state_t, e_surf_action_state_t) workstationActionStateChangedCallbacks; /********* * Tools * @@ -67,9 +67,9 @@ extern WorkstationModelPtr surf_workstation_model; */ class WorkstationModel : public Model { public: - /** + /** * @brief WorkstationModel constructor - * + * * @param name the name of the model */ WorkstationModel(const char *name); @@ -89,11 +89,11 @@ public: * @details [long description] */ virtual void adjustWeightOfDummyCpuActions(); - + /** * @brief [brief description] * @details [long description] - * + * * @param workstation_nb [description] * @param workstation_list [description] * @param computation_amount [description] @@ -110,7 +110,7 @@ public: /** * @brief [brief description] * @details [long description] - * + * * @param src [description] * @param dst [description] * @param size [description] @@ -138,7 +138,7 @@ public: /** * @brief Workstation constructor - * + * * @param model WorkstationModel associated to this Workstation * @param name The name of the Workstation * @param props Dictionary of properties associated to this Workstation @@ -151,7 +151,7 @@ public: /** * @brief Workstation constructor - * + * * @param model WorkstationModel associated to this Workstation * @param name The name of the Workstation * @param props Dictionary of properties associated to this Workstation @@ -179,7 +179,7 @@ public: /** * @brief Execute some quantity of computation - * + * * @param size The value of the processing amount (in flop) needed to process * @return The CpuAction corresponding to the processing * @see Cpu @@ -188,7 +188,7 @@ public: /** * @brief Make a process sleep for duration seconds - * + * * @param duration The number of seconds to sleep * @return The CpuAction corresponding to the sleeping * @see Cpu @@ -197,7 +197,7 @@ public: /** * @brief Get the number of cores of the associated Cpu - * + * * @return The number of cores of the associated Cpu * @see Cpu */ @@ -205,7 +205,7 @@ public: /** * @brief Get the speed of the associated Cpu - * + * * @param load [TODO] * @return The speed of the associated Cpu * @see Cpu @@ -215,7 +215,7 @@ public: /** * @brief Get the available speed of the associated Cpu * @details [TODO] - * + * * @return The available speed of the associated Cpu * @see Cpu */ @@ -223,7 +223,7 @@ public: /** * @brief Get the associated Cpu power peak - * + * * @return The associated Cpu power peak * @see Cpu */ @@ -235,7 +235,7 @@ public: /** * @brief Return the storage of corresponding mount point - * + * * @param storage The mount point * @return The corresponding Storage */ @@ -243,7 +243,7 @@ public: /** * @brief Get the xbt_dict_t of mount_point: Storage - * + * * @return The xbt_dict_t of mount_point: Storage */ virtual xbt_dict_t getMountedStorageList(); @@ -257,16 +257,16 @@ public: /** * @brief Open a file - * + * * @param fullpath The full path to the file - * + * * @return The StorageAction corresponding to the opening */ virtual ActionPtr open(const char* fullpath); /** * @brief Close a file - * + * * @param fd The file descriptor to close * @return The StorageAction corresponding to the closing */ @@ -275,7 +275,7 @@ public: /** * @brief Unlink a file * @details [long description] - * + * * @param fd [description] * @return [description] */ @@ -284,7 +284,7 @@ public: /** * @brief List directory contents of a path * @details [long description] - * + * * @param mount [description] * @param path The path to the directory * @return The StorageAction corresponding to the ls action @@ -293,7 +293,7 @@ public: /** * @brief Get the size in bytes of the file - * + * * @param fd The file descriptor to read * @return The size in bytes of the file */ @@ -301,7 +301,7 @@ public: /** * @brief Read a file - * + * * @param fd The file descriptor to read * @param size The size in bytes to read * @return The StorageAction corresponding to the reading @@ -310,7 +310,7 @@ public: /** * @brief Write a file - * + * * @param fd The file descriptor to write * @param size The size in bytes to write * @return The StorageAction corresponding to the writing @@ -325,7 +325,7 @@ public: * - the storage name, * - the storage typeId, * - the storage content type - * + * * @param fd The file descriptor * @return An xbt_dynar_t with the file informations */ @@ -333,15 +333,15 @@ public: /** * @brief Get the current position of the file descriptor - * + * * @param fd The file descriptor * @return The current position of the file descriptor */ virtual sg_size_t fileTell(surf_file_t fd); /** - * @brief Get the available space of the storage at the mount point - * + * @brief Get the available space of the storage at the mount point + * * @param name The mount point * @return The amount of availble space in bytes */ @@ -349,7 +349,7 @@ public: /** * @brief Get the used space of the storage at the mount point - * + * * @param name The mount point * @return The amount of used space in bytes */ @@ -358,7 +358,7 @@ public: /** * @brief Set the position indictator assiociated with the file descriptor to a new position * @details [long description] - * + * * @param fd The file descriptor * @param offset The offset from the origin * @param origin Position used as a reference for the offset @@ -398,7 +398,7 @@ public: /** * @brief Get the list of virtual machines on the current Workstation - * + * * @return The list of VMs */ xbt_dynar_t getVms(); @@ -407,7 +407,7 @@ public: /** * @brief [brief description] * @details [long description] - * + * * @param params [description] */ void getParams(ws_params_t params); @@ -415,7 +415,7 @@ public: /** * @brief [brief description] * @details [long description] - * + * * @param params [description] */ void setParams(ws_params_t params); @@ -433,7 +433,7 @@ class WorkstationAction : public Action { public: /** * @brief WorkstationAction constructor - * + * * @param model The WorkstationModel associated to this WorkstationAction * @param cost The cost of this WorkstationAction in [TODO] * @param failed [description] @@ -443,7 +443,7 @@ public: /** * @brief WorkstationAction constructor - * + * * @param model The WorkstationModel associated to this WorkstationAction * @param cost The cost of this WorkstationAction in [TODO] * @param failed [description] -- 2.20.1