Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
I/O factors: noise for disks.
[simgrid.git] / src / s4u / s4u_Disk.cpp
index 07c2012..d3f3a46 100644 (file)
@@ -20,10 +20,14 @@ xbt::signal<void(Disk&)> Disk::on_creation;
 xbt::signal<void(Disk const&)> Disk::on_destruction;
 xbt::signal<void(Disk const&)> Disk::on_state_change;
 
-Disk* Disk::set_name(const std::string& name)
+const std::string& Disk::get_name() const
 {
-  name_ = name;
-  return this;
+  return pimpl_->get_name();
+}
+
+const char* Disk::get_cname() const
+{
+  return pimpl_->get_cname();
 }
 
 Disk* Disk::set_read_bandwidth(double read_bw)
@@ -69,9 +73,37 @@ const char* Disk::get_property(const std::string& key) const
   return pimpl_->get_property(key);
 }
 
-void Disk::set_property(const std::string& key, const std::string& value)
+Disk* Disk::set_property(const std::string& key, const std::string& value)
 {
   kernel::actor::simcall([this, &key, &value] { this->pimpl_->set_property(key, value); });
+  return this;
+}
+
+Disk* Disk::set_properties(const std::unordered_map<std::string, std::string>& properties)
+{
+  kernel::actor::simcall([this, properties] { this->pimpl_->set_properties(properties); });
+  return this;
+}
+
+Disk* Disk::set_state_profile(kernel::profile::Profile* profile)
+{
+  xbt_assert(not pimpl_->is_sealed(), "Cannot set a state profile once the Disk is sealed");
+  kernel::actor::simcall([this, profile]() { this->pimpl_->set_state_profile(profile); });
+  return this;
+}
+
+Disk* Disk::set_read_bandwidth_profile(kernel::profile::Profile* profile)
+{
+  xbt_assert(not pimpl_->is_sealed(), "Cannot set a bandwidth profile once the Disk is sealed");
+  kernel::actor::simcall([this, profile]() { this->pimpl_->set_read_bandwidth_profile(profile); });
+  return this;
+}
+
+Disk* Disk::set_write_bandwidth_profile(kernel::profile::Profile* profile)
+{
+  xbt_assert(not pimpl_->is_sealed(), "Cannot set a bandwidth profile once the Disk is sealed");
+  kernel::actor::simcall([this, profile]() { this->pimpl_->set_write_bandwidth_profile(profile); });
+  return this;
 }
 
 IoPtr Disk::io_init(sg_size_t size, Io::OpType type) const
@@ -99,11 +131,28 @@ sg_size_t Disk::write(sg_size_t size) const
   return IoPtr(io_init(size, Io::OpType::WRITE))->vetoable_start()->wait()->get_performed_ioops();
 }
 
-void Disk::seal()
+Disk* Disk::set_sharing_policy(Disk::Operation op, Disk::SharingPolicy policy, const NonLinearResourceCb& cb)
+{
+  kernel::actor::simcall([this, op, policy, &cb] { pimpl_->set_sharing_policy(op, policy, cb); });
+  return this;
+}
+
+Disk::SharingPolicy Disk::get_sharing_policy(Operation op) const
+{
+  return this->pimpl_->get_sharing_policy(op);
+}
+
+Disk* Disk::set_factor_cb(const std::function<IoFactorCb>& cb)
+{
+  kernel::actor::simcall([this, &cb] { pimpl_->set_factor_cb(cb); });
+  return this;
+}
+
+Disk* Disk::seal()
 {
   kernel::actor::simcall([this]{ pimpl_->seal(); });
-  get_host()->add_disk(this);
   Disk::on_creation(*this);
+  return this;
 }
 } // namespace s4u
 } // namespace simgrid