Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill Onelink now that NS3 does not use it anymore
[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/base.h>
10 #include <xbt/signal.hpp>
11
12 #include "src/kernel/routing/AsImpl.hpp"
13 /*
14 #include <float.h>
15 #include <vector>
16 */
17 namespace simgrid {
18 namespace kernel {
19 namespace routing {
20 XBT_PUBLIC_DATA(simgrid::xbt::signal<void(NetCard*)>) netcardCreatedCallbacks;
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 {
28 public:
29   enum class Type { Host, Router, As };
30
31   NetCard(std::string name, NetCard::Type componentType, AsImpl* containingAS)
32       : name_(name), componentType_(componentType), containingAS_(containingAS)
33   {
34     if (containingAS != nullptr)
35       id_ = containingAS->addComponent(this);
36     simgrid::kernel::routing::netcardCreatedCallbacks(this);
37   }
38   ~NetCard() = default;
39
40   // Our rank in the vertices_ array of our containing AS.
41   unsigned int id() { return id_; }
42   std::string name() { return name_; }
43   const char* cname() { return name_.c_str(); }
44   // This is the AS in which I am
45   AsImpl* containingAS() { return containingAS_; }
46
47   bool isAS() { return componentType_ == Type::As; }
48   bool isHost() { return componentType_ == Type::Host; }
49   bool isRouter() { return componentType_ == Type::Router; }
50
51 private:
52   unsigned int id_;
53   std::string name_;
54   NetCard::Type componentType_;
55   AsImpl* containingAS_;
56 };
57 }
58 }
59 }
60
61 #endif /* KERNEL_ROUTING_NETCARD_HPP_ */