Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into actor-priority
[simgrid.git] / src / kernel / routing / NetPoint.hpp
1 /* Copyright (c) 2013-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 KERNEL_ROUTING_NETPOINT_HPP_
7 #define KERNEL_ROUTING_NETPOINT_HPP_
8
9 #include <xbt/Extendable.hpp>
10 #include <xbt/base.h>
11 #include <xbt/signal.hpp>
12
13 #include "src/kernel/routing/NetZoneImpl.hpp"
14
15 namespace simgrid {
16 namespace kernel {
17 namespace routing {
18
19 /** @ingroup ROUTING_API
20  *  @brief Network cards are the vertices in the graph representing the network, used to compute paths between nodes.
21  *
22  * @details This represents a position in the network. One can send information between two netpoints
23  */
24 class NetPoint : public simgrid::xbt::Extendable<NetPoint> {
25
26 public:
27   enum class Type { Host, Router, NetZone };
28
29   NetPoint(std::string name, NetPoint::Type componentType, NetZoneImpl* netzone_p);
30   ~NetPoint() = default;
31
32   // Our rank in the vertices_ array of the netzone that contains us.
33   unsigned int id() { return id_; }
34   const std::string& getName() const { return name_; }
35   const char* getCname() const { return name_.c_str(); }
36   /** @brief the NetZone in which this NetPoint is included */
37   NetZoneImpl* netzone() { return netzone_; }
38
39   bool isNetZone() { return componentType_ == Type::NetZone; }
40   bool isHost() { return componentType_ == Type::Host; }
41   bool isRouter() { return componentType_ == Type::Router; }
42
43   static simgrid::xbt::signal<void(NetPoint*)> onCreation;
44
45   bool operator<(const NetPoint& rhs) const { return name_ < rhs.name_; }
46
47 private:
48   unsigned int id_;
49   std::string name_;
50   NetPoint::Type componentType_;
51   NetZoneImpl* netzone_;
52 };
53 }
54 }
55 }
56
57 XBT_PUBLIC(sg_netpoint_t) sg_netpoint_by_name_or_null(const char* name);
58
59 #endif /* KERNEL_ROUTING_NETPOINT_HPP_ */