Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
codacy
[simgrid.git] / src / mc / ChunkedData.hpp
index ae6efb1..9652ea1 100644 (file)
 namespace simgrid {
 namespace mc {
 
-/** A byte-string represented as a sequence of chunks from a PageStor */
+/** A byte-string represented as a sequence of chunks from a PageStore
+ *
+ *  In order to save memory when taking memory snapshots, a given byte-string
+ *  is split in fixed-size chunks. Identical chunks (either from the same
+ *  snapshot or more probably from different snpashots) share the same memory
+ *  storage.
+ *
+ *  Thus a chunked is represented as a sequence of indices of each chunk.
+ */
 class ChunkedData {
+  /** This is where we store the chunks */
   PageStore* store_ = nullptr;
-  /** Indices of the chunks */
+  /** Indices of the chunks in the `PageStore` */
   std::vector<std::size_t> pagenos_;
 public:
 
-  ChunkedData() {}
+  ChunkedData() = default;
   void clear()
   {
     for (std::size_t pageno : pagenos_)
@@ -40,9 +49,10 @@ public:
 
   // Copy and move
   ChunkedData(ChunkedData const& that)
+     : store_ (that.store_)
+     , pagenos_(that.pagenos_)
+
   {
-    store_ = that.store_;
-    pagenos_ = that.pagenos_;
     for (std::size_t pageno : pagenos_)
       store_->ref_page(pageno);
   }
@@ -72,10 +82,16 @@ public:
     return *this;
   }
 
+  /** How many pages are used */
   std::size_t page_count()          const { return pagenos_.size(); }
+
+  /** Get a chunk index */
   std::size_t pageno(std::size_t i) const { return pagenos_[i]; }
+
+  /** Get a view of the chunk indices */
   const std::size_t* pagenos()      const { return pagenos_.data(); }
 
+  /** Get a a pointer to a chunk */
   const void* page(std::size_t i) const
   {
     return store_->get_page(pagenos_[i]);