Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Clearly state that we don't care about the return code of actors
[simgrid.git] / examples / s4u / dht-kademlia / answer.hpp
index 0e678a8..34896d6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2018. The SimGrid Team.
+/* Copyright (c) 2012-2020. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
 #include <set>
 
 namespace kademlia {
-bool sortbydistance(const std::pair<unsigned int, unsigned int>& a, const std::pair<unsigned int, unsigned int>& b);
-
 /* Node query answer. contains the elements closest to the id given. */
 class Answer {
   unsigned int destination_id_;
-  unsigned int size_ = 0;
+  std::vector<std::pair<unsigned int, unsigned int>> nodes_;
 
 public:
-  std::vector<std::pair<unsigned int, unsigned int>> nodes;
   explicit Answer(unsigned int destination_id) : destination_id_(destination_id) {}
   virtual ~Answer() = default;
-  unsigned int getDestinationId() { return destination_id_; }
-  unsigned int getSize() { return size_; }
+  unsigned int getDestinationId() const { return destination_id_; }
+  size_t getSize() const { return nodes_.size(); }
+  const std::vector<std::pair<unsigned int, unsigned int>>& getNodes() const { return nodes_; }
   void print();
-  unsigned int merge(Answer* a);
+  unsigned int merge(const Answer* a);
   void trim();
-  bool destinationFound();
-  void addBucket(kademlia::Bucket* bucket);
+  bool destinationFound() const;
+  void addBucket(const kademlia::Bucket* bucket);
 };
 }