Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
assume a dumb tracker (and please travis)
[simgrid.git] / examples / s4u / app-bittorrent / s4u_bittorrent.cpp
1 /* Copyright (c) 2012-2017. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "s4u_bittorrent.hpp"
8 #include "s4u_peer.hpp"
9 #include "s4u_tracker.hpp"
10
11 simgrid::xbt::Extension<simgrid::s4u::Host, HostBittorrent> HostBittorrent::EXTENSION_ID;
12
13 int main(int argc, char* argv[])
14 {
15   simgrid::s4u::Engine* e = new simgrid::s4u::Engine(&argc, argv);
16
17   /* Check the arguments */
18   xbt_assert(argc > 2, "Usage: %s platform_file deployment_file", argv[0]);
19
20   e->loadPlatform(argv[1]);
21
22   HostBittorrent::EXTENSION_ID = simgrid::s4u::Host::extension_create<HostBittorrent>();
23
24   std::vector<simgrid::s4u::Host*> list;
25   simgrid::s4u::Engine::getInstance()->getHostList(&list);
26   for (auto host : list)
27     host->extension_set(new HostBittorrent(host));
28
29   e->registerFunction<Tracker>("tracker");
30   e->registerFunction<Peer>("peer");
31   e->loadDeployment(argv[2]);
32
33   e->run();
34
35   delete e;
36   return 0;
37 }