1 /* Copyright (c) 2013-2016. 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 "src/kernel/routing/NetZoneImpl.hpp"
22 /** @ingroup ROUTING_API
23 * @brief Network cards are the vertices in the graph representing the network, used to compute paths between nodes.
25 * @details This represents a position in the network. One can send information between two netpoints
27 class NetPoint : public simgrid::xbt::Extendable<NetPoint> {
30 enum class Type { Host, Router, NetZone };
32 NetPoint(std::string name, NetPoint::Type componentType, NetZoneImpl* netzone_p);
33 ~NetPoint() = default;
35 // Our rank in the vertices_ array of the netzone that contains us.
36 unsigned int id() { return id_; }
37 std::string name() { return name_; }
38 const char* cname() { return name_.c_str(); }
39 /** @brief the NetZone in which this NetPoint is included */
40 NetZoneImpl* netzone() { return netzone_; }
42 bool isNetZone() { return componentType_ == Type::NetZone; }
43 bool isHost() { return componentType_ == Type::Host; }
44 bool isRouter() { return componentType_ == Type::Router; }
46 static simgrid::xbt::signal<void(NetPoint*)> onCreation;
48 bool operator<(const NetPoint& rhs) const { return name_ < rhs.name_; }
53 NetPoint::Type componentType_;
54 NetZoneImpl* netzone_;
60 XBT_PUBLIC(sg_netpoint_t) sg_netpoint_by_name_or_null(const char* name);
62 #endif /* KERNEL_ROUTING_NETPOINT_HPP_ */