Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use pimpl/piface combo for s4u storage
[simgrid.git] / src / surf / StorageImpl.cpp
index 3eb9910..d15ab37 100644 (file)
@@ -31,6 +31,17 @@ simgrid::xbt::signal<void(StorageImpl*)> storageDestructedCallbacks;
 simgrid::xbt::signal<void(StorageImpl*, int, int)> storageStateChangedCallbacks; // signature: wasOn, isOn
 simgrid::xbt::signal<void(StorageAction*, Action::State, Action::State)> storageActionStateChangedCallbacks;
 
+/* List of storages */
+std::unordered_map<std::string, StorageImpl*>* StorageImpl::storages =
+    new std::unordered_map<std::string, StorageImpl*>();
+
+StorageImpl* StorageImpl::byName(const char* name)
+{
+  if (storages->find(name) == storages->end())
+    return nullptr;
+  return storages->at(name);
+}
+
 /*********
  * Model *
  *********/
@@ -53,6 +64,7 @@ StorageModel::~StorageModel()
 StorageImpl::StorageImpl(Model* model, const char* name, lmm_system_t maxminSystem, double bread, double bwrite,
                          const char* type_id, const char* content_name, sg_size_t size, const char* attach)
     : Resource(model, name, lmm_constraint_new(maxminSystem, this, MAX(bread, bwrite)))
+    , piface_(this)
     , size_(size)
     , usedSize_(0)
     , typeId_(xbt_strdup(type_id))
@@ -64,6 +76,7 @@ StorageImpl::StorageImpl(Model* model, const char* name, lmm_system_t maxminSyst
   XBT_DEBUG("Create resource with Bread '%f' Bwrite '%f' and Size '%llu'", bread, bwrite, size);
   constraintRead_  = lmm_constraint_new(maxminSystem, this, bread);
   constraintWrite_ = lmm_constraint_new(maxminSystem, this, bwrite);
+  storages->insert({name, this});
 }
 
 StorageImpl::~StorageImpl()