Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Coding style: camel case RemotePtr
[simgrid.git] / src / mc / ChunkedData.hpp
index 0ec1cb2..3c414be 100644 (file)
@@ -1,30 +1,33 @@
+/* Copyright (c) 2014-2015. 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. */
+
 #ifndef SIMGRID_MC_CHUNKED_DATA_HPP
 #define SIMGRID_MC_CHUNKED_DATA_HPP
 
 #include <cstddef>
 #include <cstdint>
 
+#include <utility>
 #include <vector>
 
-#include <mc/mc_forward.hpp>
-#include <mc/AddressSpace.hpp>
-#include <mc/PageStore.hpp>
+#include "src/mc/mc_forward.hpp"
+#include "src/mc/AddressSpace.hpp"
+#include "src/mc/PageStore.hpp"
 
 namespace simgrid {
 namespace mc {
 
+/** A byte-string represented as a sequence of chunks from a PageStor */
 class ChunkedData {
-  PageStore* store_;
+  PageStore* store_ = nullptr;
+  /** Indices of the chunks */
   std::vector<std::size_t> pagenos_;
 public:
-  ChunkedData() : store_(nullptr) {}
-  ChunkedData(ChunkedData const& that)
-  {
-    store_ = that.store_;
-    pagenos_ = that.pagenos_;
-    for (std::size_t pageno : pagenos_)
-      store_->ref_page(pageno);
-  }
+
+  ChunkedData() {}
   void clear()
   {
     for (std::size_t pageno : pagenos_)
@@ -36,6 +39,14 @@ public:
     clear();
   }
 
+  // Copy and move
+  ChunkedData(ChunkedData const& that)
+  {
+    store_ = that.store_;
+    pagenos_ = that.pagenos_;
+    for (std::size_t pageno : pagenos_)
+      store_->ref_page(pageno);
+  }
   ChunkedData(ChunkedData&& that)
   {
     store_ = that.store_;
@@ -65,7 +76,6 @@ public:
   std::size_t page_count()          const { return pagenos_.size(); }
   std::size_t pageno(std::size_t i) const { return pagenos_[i]; }
   const std::size_t* pagenos()      const { return pagenos_.data(); }
-  std::size_t*       pagenos()            { return pagenos_.data(); }
 
   const void* page(std::size_t i) const
   {
@@ -73,7 +83,7 @@ public:
   }
 
   ChunkedData(PageStore& store, AddressSpace& as,
-    remote_ptr<void> addr, std::size_t page_count,
+    RemotePtr<void> addr, std::size_t page_count,
     const std::size_t* ref_page_numbers, const std::uint64_t* pagemap);
 };