Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a s4u::Link class, at least
[simgrid.git] / include / simgrid / s4u / link.hpp
1 /* Copyright (c) 2004-2017. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef S4U_LINK_HPP_
7 #define S4U_LINK_HPP_
8
9 #include <xbt/base.h>
10
11 #include <unordered_map>
12
13 #include "xbt/dict.h"
14 #include "xbt/fifo.h"
15
16 #include "simgrid/link.h"
17
18 /***********
19  * Classes *
20  ***********/
21
22 namespace simgrid {
23 namespace surf {
24 class LinkImpl;
25 }
26 namespace s4u {
27 /** @brief A Link represents the network facilities between [hosts](\ref simgrid::s4u::Host) */
28 class Link {
29   friend simgrid::surf::LinkImpl;
30
31 private:
32   // Links are created from the NetZone, and destroyed by their private implementation when the simulation ends
33   explicit Link(surf::LinkImpl* pimpl) : pimpl_(pimpl) {}
34   virtual ~Link() = default;
35   // The private implementation, that never changes
36   surf::LinkImpl* const pimpl_;
37
38 public:
39   /** @brief Retrieve a link from its name */
40   static Link* byName(const char* name);
41
42   /** @brief Get da name */
43   const char* name();
44
45   /** @brief Get the bandwidth in bytes per second of current Link */
46   double bandwidth();
47
48   /** @brief Get the latency in seconds of current Link */
49   double latency();
50
51   /** @brief The sharing policy is a @{link e_surf_link_sharing_policy_t::EType} (0: FATPIPE, 1: SHARED, 2: FULLDUPLEX)
52    */
53   int sharingPolicy();
54
55   /** @brief Check if the Link is used */
56   bool isUsed();
57
58   void turnOn();
59   void turnOff();
60
61   void* getData();
62   void setData(void* d);
63
64   void setStateTrace(tmgr_trace_t trace); /*< setup the trace file with states events (ON or OFF). Trace must contain
65                                              boolean values. */
66   void
67   setBandwidthTrace(tmgr_trace_t trace);    /*< setup the trace file with bandwidth events (peak speed changes due to
68                                                external load). Trace must contain percentages (value between 0 and 1). */
69   void setLatencyTrace(tmgr_trace_t trace); /*< setup the trace file with latency events (peak latency changes due to
70                                                external load). Trace must contain absolute values */
71 };
72 }
73 }
74
75 #endif /* SURF_NETWORK_INTERFACE_HPP_ */
76
77 /* Blueprint for the s4u/kernel split
78
79 namespace s4u {
80   class Link {
81   public:
82     Link(kernel::Link* pimpl) : pimpl_(pimpl) {}
83   private:
84     kernel::Link* pimpl_;
85   };
86 }
87
88 namespace kernel  {
89   class Link : public util::refcounted<Link> {
90   private:
91     s4u::Link user_;
92   };
93 }
94  */