Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move the NetCard related functions into a NetCard.cpp
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 8 Dec 2016 10:29:49 +0000 (11:29 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 8 Dec 2016 10:29:49 +0000 (11:29 +0100)
src/kernel/routing/NetCard.cpp [new file with mode: 0644]
src/kernel/routing/NetCard.hpp
src/surf/network_ns3.cpp
src/surf/surf_routing.cpp
tools/cmake/DefinePackages.cmake

diff --git a/src/kernel/routing/NetCard.cpp b/src/kernel/routing/NetCard.cpp
new file mode 100644 (file)
index 0000000..cf30e12
--- /dev/null
@@ -0,0 +1,33 @@
+/* Copyright (c) 2009-2011, 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. */
+
+#include "src/kernel/routing/NetCard.hpp"
+#include "src/surf/surf_routing.hpp"
+#include <simgrid/s4u/host.hpp>
+
+XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_route);
+
+namespace simgrid {
+namespace kernel {
+namespace routing {
+
+simgrid::xbt::signal<void(NetCard*)> NetCard::onCreation;
+}
+}
+} // namespace simgrid::kernel::routing
+
+/** @brief Retrieve a netcard from its name
+ *
+ * Netcards are the thing that connect host or routers to the network
+ */
+simgrid::kernel::routing::NetCard* sg_netcard_by_name_or_null(const char* name)
+{
+  sg_host_t h                                = sg_host_by_name(name);
+  simgrid::kernel::routing::NetCard* netcard = h == nullptr ? nullptr : h->pimpl_netcard;
+  if (!netcard)
+    netcard = (simgrid::kernel::routing::NetCard*)xbt_lib_get_or_null(as_router_lib, name, ROUTING_ASR_LEVEL);
+  return netcard;
+}
index 7a78c0a..9213dd4 100644 (file)
@@ -17,7 +17,6 @@
 namespace simgrid {
 namespace kernel {
 namespace routing {
-XBT_PUBLIC_DATA(simgrid::xbt::signal<void(NetCard*)>) netcardCreatedCallbacks;
 
 /** @ingroup SURF_routing_interface
  * @brief Network cards are the vertices in the graph representing the network, used to compute paths between nodes.
@@ -33,7 +32,7 @@ public:
   {
     if (containingAS != nullptr)
       id_ = containingAS->addComponent(this);
-    simgrid::kernel::routing::netcardCreatedCallbacks(this);
+    simgrid::kernel::routing::NetCard::onCreation(this);
   }
   ~NetCard() = default;
 
@@ -48,6 +47,8 @@ public:
   bool isHost() { return componentType_ == Type::Host; }
   bool isRouter() { return componentType_ == Type::Router; }
 
+  static simgrid::xbt::signal<void(NetCard*)> onCreation;
+
 private:
   unsigned int id_;
   std::string name_;
index 5797b32..24dee57 100644 (file)
@@ -177,7 +177,7 @@ NetworkNS3Model::NetworkNS3Model() : NetworkModel() {
   ns3_initialize(ns3_tcp_model.get().c_str());
 
   simgrid::s4u::Host::onCreation.connect(ns3_add_host);
-  simgrid::kernel::routing::netcardCreatedCallbacks.connect(ns3_add_netcard);
+  simgrid::kernel::routing::NetCard::onCreation.connect(ns3_add_netcard);
   simgrid::surf::on_cluster.connect (&parse_ns3_add_cluster);
   simgrid::surf::on_postparse.connect(&postparse_cb);
   simgrid::s4u::As::onRouteCreation.connect(&routeCreation_cb);
index 1d90650..155243a 100644 (file)
@@ -25,7 +25,6 @@ namespace kernel {
 namespace routing {
 
   /* Callbacks */
-  simgrid::xbt::signal<void(NetCard*)> netcardCreatedCallbacks;
   simgrid::xbt::signal<void(s4u::As*)> asCreatedCallbacks;
 
 }}} // namespace simgrid::kernel::routing
@@ -46,19 +45,6 @@ int COORD_ASR_LEVEL = -1;            //Coordinates level
 int NS3_ASR_LEVEL = -1;              //host node for ns3
 int ROUTING_PROP_ASR_LEVEL = -1;     //Where the properties are stored
 
-/** @brief Retrieve a netcard from its name
- *
- * Netcards are the thing that connect host or routers to the network
- */
-simgrid::kernel::routing::NetCard *sg_netcard_by_name_or_null(const char *name)
-{
-  sg_host_t h = sg_host_by_name(name);
-  simgrid::kernel::routing::NetCard *netcard = h==nullptr ? nullptr: h->pimpl_netcard;
-  if (!netcard)
-    netcard = (simgrid::kernel::routing::NetCard*) xbt_lib_get_or_null(as_router_lib, name, ROUTING_ASR_LEVEL);
-  return netcard;
-}
-
 void sg_platf_new_trace(sg_platf_trace_cbarg_t trace)
 {
   tmgr_trace_t tmgr_trace;
index 7e9dc7c..e91b841 100644 (file)
@@ -306,6 +306,7 @@ set(SURF_SRC
   src/kernel/routing/AsRoutedGraph.cpp
   src/kernel/routing/AsNone.cpp
   src/kernel/routing/AsVivaldi.cpp
+  src/kernel/routing/NetCard.cpp
 
   src/kernel/EngineImpl.cpp
   src/kernel/EngineImpl.hpp