Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
9213dd45400b83332f748dfe4c3872f0c4409cb1
[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
21 /** @ingroup SURF_routing_interface
22  * @brief Network cards are the vertices in the graph representing the network, used to compute paths between nodes.
23  *
24  * @details This represents a position in the network. One can route information between two netcards
25  */
26 class NetCard {
27 public:
28   enum class Type { Host, Router, As };
29
30   NetCard(std::string name, NetCard::Type componentType, AsImpl* containingAS)
31       : name_(name), componentType_(componentType), containingAS_(containingAS)
32   {
33     if (containingAS != nullptr)
34       id_ = containingAS->addComponent(this);
35     simgrid::kernel::routing::NetCard::onCreation(this);
36   }
37   ~NetCard() = default;
38
39   // Our rank in the vertices_ array of our containing AS.
40   unsigned int id() { return id_; }
41   std::string name() { return name_; }
42   const char* cname() { return name_.c_str(); }
43   // This is the AS in which I am
44   AsImpl* containingAS() { return containingAS_; }
45
46   bool isAS() { return componentType_ == Type::As; }
47   bool isHost() { return componentType_ == Type::Host; }
48   bool isRouter() { return componentType_ == Type::Router; }
49
50   static simgrid::xbt::signal<void(NetCard*)> onCreation;
51
52 private:
53   unsigned int id_;
54   std::string name_;
55   NetCard::Type componentType_;
56   AsImpl* containingAS_;
57 };
58 }
59 }
60 }
61
62 #endif /* KERNEL_ROUTING_NETCARD_HPP_ */