Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
[simgrid.git] / src / s4u / s4u_Disk.cpp
index 806e090..10b19e4 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2019-2021. 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. */
@@ -7,12 +7,12 @@
 #include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "simgrid/s4u/Io.hpp"
+#include "simgrid/simix.hpp"
 #include "src/kernel/resource/DiskImpl.hpp"
 
 namespace simgrid {
-namespace xbt {
-template class Extendable<s4u::Disk>;
-} // namespace xbt
+
+template class xbt::Extendable<s4u::Disk>;
 
 namespace s4u {
 
@@ -25,12 +25,12 @@ double Disk::get_read_bandwidth() const
   return this->pimpl_->get_read_bandwidth();
 }
 
-double Disk::get_write_bandwidth()
+double Disk::get_write_bandwidth() const
 {
   return pimpl_->get_write_bandwidth();
 }
 
-Host* Disk::get_host()
+Host* Disk::get_host() const
 {
   return pimpl_->get_host();
 }
@@ -52,7 +52,7 @@ void Disk::set_property(const std::string& key, const std::string& value)
 
 IoPtr Disk::io_init(sg_size_t size, Io::OpType type)
 {
-  return IoPtr(new Io(this, size, type));
+  return Io::init()->set_disk(this)->set_size(size)->set_op_type(type);
 }
 
 IoPtr Disk::read_async(sg_size_t size)
@@ -77,3 +77,44 @@ sg_size_t Disk::write(sg_size_t size)
 
 } // namespace s4u
 } // namespace simgrid
+
+/* **************************** Public C interface *************************** */
+
+const char* sg_disk_get_name(const_sg_disk_t disk)
+{
+  return disk->get_cname();
+}
+
+sg_host_t sg_disk_get_host(const_sg_disk_t disk)
+{
+  return disk->get_host();
+}
+
+double sg_disk_read_bandwidth(const_sg_disk_t disk)
+{
+  return disk->get_read_bandwidth();
+}
+
+double sg_disk_write_bandwidth(const_sg_disk_t disk)
+{
+  return disk->get_write_bandwidth();
+}
+
+sg_size_t sg_disk_read(sg_disk_t disk, sg_size_t size)
+{
+  return disk->read(size);
+}
+sg_size_t sg_disk_write(sg_disk_t disk, sg_size_t size)
+{
+  return disk->write(size);
+}
+
+void* sg_disk_get_data(const_sg_disk_t disk)
+{
+  return disk->get_data();
+}
+
+void sg_disk_set_data(sg_disk_t disk, void* data)
+{
+  disk->set_data(data);
+}