]> AND Public Git Repository - simgrid.git/blobdiff - examples/s4u/app-bittorrent/s4u-tracker.hpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Pull simgrid/master and a subsequent merge
[simgrid.git] / examples / s4u / app-bittorrent / s4u-tracker.hpp
index 4755919f0836b647f32375a5bcc2d83504c1325d..acdb12937987218bc5e4786b0bec5c1ccd7feb6a 100644 (file)
@@ -1,11 +1,11 @@
-/* Copyright (c) 2012-2019. 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
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#ifndef BITTORRENT_TRACKER_HPP_
-#define BITTORRENT_TRACKER_HPP_
+#ifndef BITTORRENT_TRACKER_HPP
+#define BITTORRENT_TRACKER_HPP
 
 #include "s4u-bittorrent.hpp"
 #include <set>
@@ -17,26 +17,22 @@ class TrackerQuery {
 public:
   explicit TrackerQuery(int peer_id, simgrid::s4u::Mailbox* return_mailbox)
       : peer_id(peer_id), return_mailbox(return_mailbox){};
-  ~TrackerQuery() = default;
-  int getPeerId() { return peer_id; }
-  simgrid::s4u::Mailbox* getReturnMailbox() { return return_mailbox; }
+  int getPeerId() const { return peer_id; }
+  simgrid::s4u::Mailbox* getReturnMailbox() const { return return_mailbox; }
 };
 
 class TrackerAnswer {
   // int interval; // how often the peer should contact the tracker (unused for now)
-  std::set<int>* peers; // the peer list the peer has asked for.
+  std::set<int> peers; // the peer list the peer has asked for.
 public:
-  explicit TrackerAnswer(int /*interval*/) /*: interval(interval)*/ { peers = new std::set<int>; }
-  TrackerAnswer(const TrackerAnswer&)                                       = delete;
-  TrackerAnswer& operator=(const TrackerAnswer&) = delete;
-  ~TrackerAnswer() { delete peers; };
-  void addPeer(int peer) { peers->insert(peer); }
-  std::set<int>* getPeers() { return peers; }
+  explicit TrackerAnswer(int /*interval*/) /*: interval(interval)*/ {}
+  void addPeer(int peer) { peers.insert(peer); }
+  const std::set<int>& getPeers() const { return peers; }
 };
 
 class Tracker {
   double deadline;
-  RngStream stream;
+  simgrid::xbt::random::XbtRandom random{42};
   simgrid::s4u::Mailbox* mailbox;
   std::set<int> known_peers;