1 /* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef KERNEL_ROUTING_NETPOINT_HPP_
7 #define KERNEL_ROUTING_NETPOINT_HPP_
9 #include <xbt/Extendable.hpp>
11 #include <xbt/signal.hpp>
13 #include <simgrid/kernel/routing/NetZoneImpl.hpp>
19 /** @ingroup ROUTING_API
20 * @brief Network cards are the vertices in the graph representing the network, used to compute paths between nodes.
22 * @details This represents a position in the network. One can send information between two netpoints
24 class NetPoint : public simgrid::xbt::Extendable<NetPoint> {
27 enum class Type { Host, Router, NetZone };
29 NetPoint(const std::string& name, NetPoint::Type component_type, NetZoneImpl* netzone_p);
30 ~NetPoint() = default;
32 // Our rank in the vertices_ array of the netzone that contains us.
33 unsigned int id() { return id_; }
34 const std::string& get_name() const { return name_; }
35 const char* get_cname() const { return name_.c_str(); }
36 /** @brief the NetZone in which this NetPoint is included */
37 NetZoneImpl* get_englobing_zone() { return englobing_zone_; }
39 bool is_netzone() { return component_type_ == Type::NetZone; }
40 bool is_host() { return component_type_ == Type::Host; }
41 bool is_router() { return component_type_ == Type::Router; }
43 static simgrid::xbt::signal<void(NetPoint*)> on_creation;
45 bool operator<(const NetPoint& rhs) const { return name_ < rhs.name_; }
50 NetPoint::Type component_type_;
51 NetZoneImpl* englobing_zone_;
53 } // namespace routing
55 } // namespace simgrid
57 XBT_PUBLIC simgrid::kernel::routing::NetPoint* sg_netpoint_by_name_or_null(const char* name);
59 #endif /* KERNEL_ROUTING_NETPOINT_HPP_ */