Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
tidy up PropertyHolder
[simgrid.git] / include / simgrid / s4u / NetZone.hpp
1 /* Copyright (c) 2016-2019. 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 SIMGRID_S4U_NETZONE_HPP
7 #define SIMGRID_S4U_NETZONE_HPP
8
9 #include <simgrid/forward.h>
10 #include <xbt/signal.hpp>
11
12 #include <string>
13 #include <unordered_map>
14 #include <utility>
15 #include <vector>
16
17 namespace simgrid {
18 namespace s4u {
19
20 /** @brief Networking Zones
21  *
22  * A netzone is a network container, in charge of routing information between elements (hosts) and to the nearby
23  * netzones. In SimGrid, there is a hierarchy of netzones, with a unique root zone (that you can retrieve from the
24  * s4u::Engine).
25  */
26 class XBT_PUBLIC NetZone {
27 protected:
28   friend kernel::routing::NetZoneImpl;
29
30   explicit NetZone(kernel::routing::NetZoneImpl* impl) : pimpl_(impl) {}
31
32 public:
33   /** @brief Retrieves the name of that netzone as a C++ string */
34   const std::string& get_name() const;
35   /** @brief Retrieves the name of that netzone as a C string */
36   const char* get_cname() const;
37
38   NetZone* get_father();
39
40   std::vector<Host*> get_all_hosts();
41   int get_host_count();
42
43   kernel::routing::NetZoneImpl* get_impl() const { return pimpl_; }
44
45 private:
46   kernel::routing::NetZoneImpl* const pimpl_;
47
48 public:
49   /** Get the properties assigned to a netzone */
50   const std::unordered_map<std::string, std::string>* get_properties() const;
51   /** Retrieve the property value (or nullptr if not set) */
52   const char* get_property(const std::string& key) const;
53   void set_property(const std::string& key, const std::string& value);
54
55   std::vector<NetZone*> get_children();
56
57   /* Add content to the netzone, at parsing time. It should be sealed afterward. */
58   int add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
59   void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst, kernel::routing::NetPoint* gw_src,
60                  kernel::routing::NetPoint* gw_dst, std::vector<kernel::resource::LinkImpl*>& link_list,
61                  bool symmetrical);
62   void add_bypass_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
63                         kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
64                         std::vector<kernel::resource::LinkImpl*>& link_list, bool symmetrical);
65
66   /*** Called on each newly created regular route (not on bypass routes) */
67   static xbt::signal<void(bool symmetrical, kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
68                           kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
69                           std::vector<kernel::resource::LinkImpl*> const& link_list)>
70       on_route_creation;
71   static xbt::signal<void(NetZone const&)> on_creation;
72   static xbt::signal<void(NetZone const&)> on_seal;
73 };
74
75 } // namespace s4u
76 } // namespace simgrid
77
78 #endif /* SIMGRID_S4U_NETZONE_HPP */