From: Martin Quinson Date: Tue, 6 Dec 2016 20:14:58 +0000 (+0100) Subject: move NetCard to its own header file X-Git-Tag: v3_14~104 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/877fd76c223fe2fba051129f3ba0339bb5566bce move NetCard to its own header file --- diff --git a/src/kernel/routing/AsCluster.cpp b/src/kernel/routing/AsCluster.cpp index 7d90a512bf..879429231d 100644 --- a/src/kernel/routing/AsCluster.cpp +++ b/src/kernel/routing/AsCluster.cpp @@ -4,6 +4,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "src/kernel/routing/AsCluster.hpp" +#include "src/kernel/routing/NetCard.hpp" #include "src/surf/network_interface.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf"); diff --git a/src/kernel/routing/AsClusterDragonfly.cpp b/src/kernel/routing/AsClusterDragonfly.cpp index 9fb2d04302..abe03acbc9 100644 --- a/src/kernel/routing/AsClusterDragonfly.cpp +++ b/src/kernel/routing/AsClusterDragonfly.cpp @@ -4,6 +4,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "src/kernel/routing/AsClusterDragonfly.hpp" +#include "src/kernel/routing/NetCard.hpp" #include "src/surf/network_interface.hpp" #include "src/surf/xml/platf.hpp" // FIXME: move that back to the parsing area diff --git a/src/kernel/routing/AsClusterFatTree.cpp b/src/kernel/routing/AsClusterFatTree.cpp index 169497d99b..d8d19e0794 100644 --- a/src/kernel/routing/AsClusterFatTree.cpp +++ b/src/kernel/routing/AsClusterFatTree.cpp @@ -7,6 +7,7 @@ #include #include "src/kernel/routing/AsClusterFatTree.hpp" +#include "src/kernel/routing/NetCard.hpp" #include "src/surf/network_interface.hpp" #include "xbt/lib.h" diff --git a/src/kernel/routing/AsClusterTorus.cpp b/src/kernel/routing/AsClusterTorus.cpp index 9bbb806ed0..8690cdc72b 100644 --- a/src/kernel/routing/AsClusterTorus.cpp +++ b/src/kernel/routing/AsClusterTorus.cpp @@ -4,6 +4,8 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "src/kernel/routing/AsClusterTorus.hpp" +#include "src/kernel/routing/NetCard.hpp" + #include "src/surf/network_interface.hpp" #include "src/surf/xml/platf.hpp" // FIXME: move that back to the parsing area diff --git a/src/kernel/routing/AsDijkstra.cpp b/src/kernel/routing/AsDijkstra.cpp index 2102994f06..af507338ff 100644 --- a/src/kernel/routing/AsDijkstra.cpp +++ b/src/kernel/routing/AsDijkstra.cpp @@ -4,6 +4,8 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "src/kernel/routing/AsDijkstra.hpp" +#include "src/kernel/routing/NetCard.hpp" + #include "src/surf/network_interface.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_dijkstra, surf, "Routing part of surf -- dijkstra routing logic"); diff --git a/src/kernel/routing/AsFloyd.cpp b/src/kernel/routing/AsFloyd.cpp index 4821b05136..b9d098db3f 100644 --- a/src/kernel/routing/AsFloyd.cpp +++ b/src/kernel/routing/AsFloyd.cpp @@ -5,9 +5,10 @@ #include -#include "xbt/log.h" #include "src/kernel/routing/AsFloyd.hpp" +#include "src/kernel/routing/NetCard.hpp" #include "src/surf/network_interface.hpp" +#include "xbt/log.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_floyd, surf, "Routing part of surf"); diff --git a/src/kernel/routing/AsFull.cpp b/src/kernel/routing/AsFull.cpp index 1a116db547..eb84b0c392 100644 --- a/src/kernel/routing/AsFull.cpp +++ b/src/kernel/routing/AsFull.cpp @@ -4,6 +4,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "src/kernel/routing/AsFull.hpp" +#include "src/kernel/routing/NetCard.hpp" #include "src/surf/network_interface.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_full, surf, "Routing part of surf"); diff --git a/src/kernel/routing/AsImpl.cpp b/src/kernel/routing/AsImpl.cpp index 80d84427e2..31b9e016bc 100644 --- a/src/kernel/routing/AsImpl.cpp +++ b/src/kernel/routing/AsImpl.cpp @@ -7,6 +7,7 @@ #include "simgrid/s4u/host.hpp" #include "src/kernel/routing/AsImpl.hpp" +#include "src/kernel/routing/NetCard.hpp" #include "src/surf/cpu_interface.hpp" #include "src/surf/network_interface.hpp" diff --git a/src/kernel/routing/AsRoutedGraph.cpp b/src/kernel/routing/AsRoutedGraph.cpp index 8dc559fbd7..6e56149618 100644 --- a/src/kernel/routing/AsRoutedGraph.cpp +++ b/src/kernel/routing/AsRoutedGraph.cpp @@ -10,6 +10,7 @@ #include "xbt/graph.h" #include "src/kernel/routing/AsRoutedGraph.hpp" +#include "src/kernel/routing/NetCard.hpp" #include "src/surf/network_interface.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_routing_generic, surf_route, "Generic implementation of the surf routing"); diff --git a/src/kernel/routing/AsVivaldi.cpp b/src/kernel/routing/AsVivaldi.cpp index 915e8077f1..e048015a28 100644 --- a/src/kernel/routing/AsVivaldi.cpp +++ b/src/kernel/routing/AsVivaldi.cpp @@ -8,6 +8,7 @@ #include #include "src/kernel/routing/AsVivaldi.hpp" +#include "src/kernel/routing/NetCard.hpp" #include "src/surf/network_interface.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_vivaldi, surf, "Routing part of surf"); diff --git a/src/kernel/routing/NetCard.hpp b/src/kernel/routing/NetCard.hpp new file mode 100644 index 0000000000..7a78c0ad7e --- /dev/null +++ b/src/kernel/routing/NetCard.hpp @@ -0,0 +1,61 @@ +/* Copyright (c) 2013-2016. The SimGrid Team. All rights reserved. */ + +/* This program is free software; you can redistribute it and/or modify it + * under the terms of the license (GNU LGPL) which comes with this package. */ + +#ifndef KERNEL_ROUTING_NETCARD_HPP_ +#define KERNEL_ROUTING_NETCARD_HPP_ + +#include +#include + +#include "src/kernel/routing/AsImpl.hpp" +/* +#include +#include +*/ +namespace simgrid { +namespace kernel { +namespace routing { +XBT_PUBLIC_DATA(simgrid::xbt::signal) netcardCreatedCallbacks; + +/** @ingroup SURF_routing_interface + * @brief Network cards are the vertices in the graph representing the network, used to compute paths between nodes. + * + * @details This represents a position in the network. One can route information between two netcards + */ +class NetCard { +public: + enum class Type { Host, Router, As }; + + NetCard(std::string name, NetCard::Type componentType, AsImpl* containingAS) + : name_(name), componentType_(componentType), containingAS_(containingAS) + { + if (containingAS != nullptr) + id_ = containingAS->addComponent(this); + simgrid::kernel::routing::netcardCreatedCallbacks(this); + } + ~NetCard() = default; + + // Our rank in the vertices_ array of our containing AS. + unsigned int id() { return id_; } + std::string name() { return name_; } + const char* cname() { return name_.c_str(); } + // This is the AS in which I am + AsImpl* containingAS() { return containingAS_; } + + bool isAS() { return componentType_ == Type::As; } + bool isHost() { return componentType_ == Type::Host; } + bool isRouter() { return componentType_ == Type::Router; } + +private: + unsigned int id_; + std::string name_; + NetCard::Type componentType_; + AsImpl* containingAS_; +}; +} +} +} + +#endif /* KERNEL_ROUTING_NETCARD_HPP_ */ diff --git a/src/s4u/s4u_as.cpp b/src/s4u/s4u_as.cpp index 4700b238f5..435572c084 100644 --- a/src/s4u/s4u_as.cpp +++ b/src/s4u/s4u_as.cpp @@ -9,8 +9,9 @@ #include #include -#include "src/surf/surf_routing.hpp" +#include "src/kernel/routing/NetCard.hpp" #include "src/surf/network_interface.hpp" // Link FIXME: move to proper header +#include "src/surf/surf_routing.hpp" XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_as,"S4U autonomous systems"); diff --git a/src/s4u/s4u_host.cpp b/src/s4u/s4u_host.cpp index 3d8550f137..254dba7721 100644 --- a/src/s4u/s4u_host.cpp +++ b/src/s4u/s4u_host.cpp @@ -10,15 +10,16 @@ #include +#include "simgrid/s4u/host.hpp" +#include "simgrid/s4u/storage.hpp" #include "simgrid/simix.hpp" -#include "src/surf/HostImpl.hpp" -#include "xbt/log.h" +#include "src/kernel/routing/NetCard.hpp" #include "src/msg/msg_private.h" #include "src/simix/ActorImpl.hpp" #include "src/simix/smx_private.h" +#include "src/surf/HostImpl.hpp" #include "src/surf/cpu_interface.hpp" -#include "simgrid/s4u/host.hpp" -#include "simgrid/s4u/storage.hpp" +#include "xbt/log.h" XBT_LOG_EXTERNAL_CATEGORY(surf_route); diff --git a/src/simgrid/host.cpp b/src/simgrid/host.cpp index 77e84c3818..70e54c4256 100644 --- a/src/simgrid/host.cpp +++ b/src/simgrid/host.cpp @@ -11,13 +11,13 @@ #include #include +#include "src/kernel/routing/NetCard.hpp" #include "src/surf/HostImpl.hpp" -#include "surf/surf.h" // routing_get_network_element_type FIXME:killme XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sg_host, sd, "Logging specific to sg_hosts"); extern std::unordered_map - host_list; // FIXME: don't dupplicate the content of s4u::Host this way + host_list; // FIXME: don't duplicate the content of s4u::Host this way void sg_host_exit() { diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index d5b877e5f2..f0ec983771 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -14,10 +14,11 @@ #include "ns3/ns3_simulator.h" #include "network_ns3.hpp" -#include "src/surf/HostImpl.hpp" -#include "src/surf/surf_private.h" #include "simgrid/sg_config.h" #include "src/instr/instr_private.h" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals +#include "src/kernel/routing/NetCard.hpp" +#include "src/surf/HostImpl.hpp" +#include "src/surf/surf_private.h" #include "simgrid/s4u/As.hpp" #include "simgrid/s4u/engine.hpp" diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 58c5190ff0..9b41ea4ebf 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -25,16 +25,17 @@ #include "src/surf/cpu_interface.hpp" #include "src/surf/network_interface.hpp" -#include "src/kernel/routing/AsImpl.hpp" #include "src/kernel/routing/AsCluster.hpp" -#include "src/kernel/routing/AsClusterTorus.hpp" -#include "src/kernel/routing/AsClusterFatTree.hpp" #include "src/kernel/routing/AsClusterDragonfly.hpp" +#include "src/kernel/routing/AsClusterFatTree.hpp" +#include "src/kernel/routing/AsClusterTorus.hpp" #include "src/kernel/routing/AsDijkstra.hpp" #include "src/kernel/routing/AsFloyd.hpp" #include "src/kernel/routing/AsFull.hpp" +#include "src/kernel/routing/AsImpl.hpp" #include "src/kernel/routing/AsNone.hpp" #include "src/kernel/routing/AsVivaldi.hpp" +#include "src/kernel/routing/NetCard.hpp" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_parse); diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index d5b6319510..3062d0cb5b 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -12,10 +12,10 @@ #include "simgrid/sg_config.h" #include "src/instr/instr_private.h" // TRACE_is_enabled(). FIXME: remove by subscribing tracing to the surf signals #include "src/internal_config.h" +#include "src/kernel/routing/NetCard.hpp" #include "src/simix/smx_host_private.h" #include "src/surf/HostImpl.hpp" #include "surf_private.h" -#include "surf_routing.hpp" #include XBT_LOG_NEW_CATEGORY(surf, "All SURF categories"); diff --git a/src/surf/surf_routing.hpp b/src/surf/surf_routing.hpp index 72680dc90b..6f570ba767 100644 --- a/src/surf/surf_routing.hpp +++ b/src/surf/surf_routing.hpp @@ -25,7 +25,6 @@ namespace kernel { namespace routing { XBT_PUBLIC_DATA(simgrid::xbt::signal) asCreatedCallbacks; - XBT_PUBLIC_DATA(simgrid::xbt::signal) netcardCreatedCallbacks; /*********** * Classes * @@ -34,45 +33,6 @@ namespace routing { class XBT_PRIVATE Onelink; class RoutingPlatf; -/** @ingroup SURF_routing_interface - * @brief Network cards are the vertices in the graph representing the network, used to compute paths between nodes. - * - * @details This represents a position in the network. One can route information between two netcards - */ -class NetCard { -public: - enum class Type { - Host, Router, As - }; - - NetCard(std::string name, NetCard::Type componentType, AsImpl* containingAS) - : name_(name), componentType_(componentType), containingAS_(containingAS) - { - if (containingAS != nullptr) - id_ = containingAS->addComponent(this); - simgrid::kernel::routing::netcardCreatedCallbacks(this); - } - ~NetCard() = default; - - // Our rank in the vertices_ array of our containing AS. - unsigned int id() {return id_;} - std::string name() { return name_; } - const char* cname() { return name_.c_str(); } - // This is the AS in which I am - AsImpl *containingAS() {return containingAS_;} - - bool isAS() {return componentType_ == Type::As;} - bool isHost() {return componentType_ == Type::Host;} - bool isRouter() {return componentType_ == Type::Router;} - - -private: - unsigned int id_; - std::string name_; - NetCard::Type componentType_; - AsImpl *containingAS_; -}; - class AsRoute { public: explicit AsRoute(NetCard* gwSrc, NetCard* gwDst) : gw_src(gwSrc), gw_dst(gwDst) {} diff --git a/teshsuite/simdag/flatifier/flatifier.cpp b/teshsuite/simdag/flatifier/flatifier.cpp index d88fef02d4..259d24a24e 100644 --- a/teshsuite/simdag/flatifier/flatifier.cpp +++ b/teshsuite/simdag/flatifier/flatifier.cpp @@ -18,6 +18,7 @@ #include +#include "src/kernel/routing/NetCard.hpp" #include "src/surf/network_interface.hpp" diff --git a/teshsuite/simdag/is-router/is-router.cpp b/teshsuite/simdag/is-router/is-router.cpp index 4e2bc761a0..2aa9ccf0a4 100644 --- a/teshsuite/simdag/is-router/is-router.cpp +++ b/teshsuite/simdag/is-router/is-router.cpp @@ -3,11 +3,11 @@ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include +#include "simgrid/s4u/host.hpp" #include "simgrid/simdag.h" +#include "src/kernel/routing/NetCard.hpp" #include "src/surf/surf_routing.hpp" -#include "simgrid/s4u/host.hpp" - +#include int main(int argc, char **argv) { diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 14884e6202..7e9dc7c668 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -74,6 +74,7 @@ set(EXTRA_DIST src/kernel/routing/AsRoutedGraph.hpp src/kernel/routing/AsNone.hpp src/kernel/routing/AsVivaldi.hpp + src/kernel/routing/NetCard.hpp src/surf/storage_interface.hpp src/surf/storage_n11.hpp