* Callbacks *
*************/
-simgrid::surf::signal<void(simgrid::surf::Storage*)> storageCreatedCallbacks;
-simgrid::surf::signal<void(simgrid::surf::Storage*)> storageDestructedCallbacks;
-simgrid::surf::signal<void(simgrid::surf::Storage*, e_surf_resource_state_t, e_surf_resource_state_t)> storageStateChangedCallbacks;
-simgrid::surf::signal<void(simgrid::surf::StorageAction*, e_surf_action_state_t, e_surf_action_state_t)> storageActionStateChangedCallbacks;
+simgrid::xbt::signal<void(simgrid::surf::Storage*)> storageCreatedCallbacks;
+simgrid::xbt::signal<void(simgrid::surf::Storage*)> storageDestructedCallbacks;
+simgrid::xbt::signal<void(simgrid::surf::Storage*, int, int)> storageStateChangedCallbacks; // signature: wasOn, isOn
+simgrid::xbt::signal<void(simgrid::surf::StorageAction*, e_surf_action_state_t, e_surf_action_state_t)> storageActionStateChangedCallbacks;
/*********
* Model *
, p_writeActions(xbt_dynar_new(sizeof(Action*),NULL))
{
p_content = parseContent(content_name);
- setState(SURF_RESOURCE_ON);
+ turnOn();
}
Storage::Storage(Model *model, const char *name, xbt_dict_t props,
lmm_system_t maxminSystem, double bread, double bwrite,
double bconnection, const char* type_id, const char *content_name,
const char *content_type, sg_size_t size, const char *attach)
- : Storage(model, name, props, type_id, content_name, content_type, size)
+ : Resource(model, name, lmm_constraint_new(maxminSystem, this, bconnection))
+ , PropertyHolder(props)
+ , p_contentType(xbt_strdup(content_type))
+ , m_size(size), m_usedSize(0)
+ , p_typeId(xbt_strdup(type_id))
+ , p_writeActions(xbt_dynar_new(sizeof(Action*),NULL))
{
+ p_content = parseContent(content_name);
p_attach = xbt_strdup(attach);
+ turnOn();
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);
THROW_UNIMPLEMENTED;
}
-void Storage::setState(e_surf_resource_state_t state)
-{
- e_surf_resource_state_t old = Resource::getState();
- Resource::setState(state);
- storageStateChangedCallbacks(this, old, state);
+void Storage::turnOn() {
+ if (isOff()) {
+ Resource::turnOn();
+ storageStateChangedCallbacks(this, 0, 1);
+ }
+}
+void Storage::turnOff() {
+ if (isOn()) {
+ Resource::turnOff();
+ storageStateChangedCallbacks(this, 1, 0);
+ }
}
xbt_dict_t Storage::getContent()