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_NETCARD_HPP_
7 #define KERNEL_ROUTING_NETCARD_HPP_
9 #include <xbt/Extendable.hpp>
11 #include <xbt/signal.hpp>
13 #include "src/kernel/routing/NetZoneImpl.hpp"
22 /** @ingroup SURF_routing_interface
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 route information between two netcards
27 class NetCard : public simgrid::xbt::Extendable<NetCard> {
30 enum class Type { Host, Router, As };
32 NetCard(std::string name, NetCard::Type componentType, AsImpl* containingAS)
33 : name_(name), componentType_(componentType), containingAS_(containingAS)
35 if (containingAS != nullptr)
36 id_ = containingAS->addComponent(this);
37 simgrid::kernel::routing::NetCard::onCreation(this);
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 // This is the AS in which I am
46 AsImpl* containingAS() { return containingAS_; }
48 bool isAS() { return componentType_ == Type::As; }
49 bool isHost() { return componentType_ == Type::Host; }
50 bool isRouter() { return componentType_ == Type::Router; }
52 static simgrid::xbt::signal<void(NetCard*)> onCreation;
57 NetCard::Type componentType_;
58 AsImpl* containingAS_;
64 XBT_PUBLIC(sg_netcard_t) sg_netcard_by_name_or_null(const char* name);
66 #endif /* KERNEL_ROUTING_NETCARD_HPP_ */