Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
update function documentation and variable names in the As -> NetZone transition
[simgrid.git] / src / kernel / routing / NetCard.hpp
1 /* Copyright (c) 2013-2016. 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_NETCARD_HPP_
7 #define KERNEL_ROUTING_NETCARD_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 #include <float.h>
16 #include <vector>
17 */
18 namespace simgrid {
19 namespace kernel {
20 namespace routing {
21
22 /** @ingroup SURF_routing_interface
23  * @brief Network cards are the vertices in the graph representing the network, used to compute paths between nodes.
24  *
25  * @details This represents a position in the network. One can route information between two netcards
26  */
27 class NetCard : public simgrid::xbt::Extendable<NetCard> {
28
29 public:
30   enum class Type { Host, Router, NetZone };
31
32   NetCard(std::string name, NetCard::Type componentType, NetZoneImpl* netzone_p)
33       : name_(name), componentType_(componentType), netzone_(netzone_p)
34   {
35     if (netzone_p != nullptr)
36       id_ = netzone_p->addComponent(this);
37     simgrid::kernel::routing::NetCard::onCreation(this);
38   }
39   ~NetCard() = default;
40
41   // Our rank in the vertices_ array of our containing AS.
42   unsigned int id() { return id_; }
43   std::string name() { return name_; }
44   const char* cname() { return name_.c_str(); }
45   /** @brief the NetZone in which this netcard is included */
46   NetZoneImpl* netzone() { return netzone_; }
47
48   bool isNetZone() { return componentType_ == Type::NetZone; }
49   bool isHost() { return componentType_ == Type::Host; }
50   bool isRouter() { return componentType_ == Type::Router; }
51
52   static simgrid::xbt::signal<void(NetCard*)> onCreation;
53
54 private:
55   unsigned int id_;
56   std::string name_;
57   NetCard::Type componentType_;
58   NetZoneImpl* netzone_;
59 };
60 }
61 }
62 }
63
64 XBT_PUBLIC(sg_netcard_t) sg_netcard_by_name_or_null(const char* name);
65
66 #endif /* KERNEL_ROUTING_NETCARD_HPP_ */