Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
actually, BypassRoute can be made private to AsImpl
[simgrid.git] / include / simgrid / s4u / As.hpp
index 445424f..f025657 100644 (file)
@@ -6,21 +6,28 @@
 #ifndef SIMGRID_S4U_AS_HPP
 #define SIMGRID_S4U_AS_HPP
 
-#include "xbt/base.h"
-#include "xbt/graph.h"
-
-#include "simgrid/s4u/forward.hpp"
-#include <vector>
 #include <map>
+#include <string>
+#include <utility>
+#include <vector>
+
+#include <xbt/base.h>
+#include <xbt/graph.h>
+
+#include <simgrid/s4u/forward.hpp>
 
 #include "src/surf/xml/platf_private.hpp" // FIXME: kill sg_platf_route_cbarg_t to remove that UGLY include
 
 namespace simgrid {
 
 namespace surf {
-  class AsImpl;
   class Link;
-  class NetCard;
+}
+namespace kernel {
+  namespace routing {
+    class AsImpl;
+    class NetCard;
+  }
 }
 namespace s4u {
 
@@ -31,9 +38,9 @@ namespace s4u {
  */
 XBT_PUBLIC_CLASS As {
 protected:
-  friend simgrid::surf::AsImpl;
+  friend simgrid::kernel::routing::AsImpl;
 
-  explicit As(const char *name);
+  explicit As(As * father, const char* name);
   virtual ~As();
   
 public:
@@ -42,24 +49,30 @@ public:
   char *name();
   As *father();;
   xbt_dict_t children(); // Sub AS
-  xbt_dynar_t hosts();   // my content
+  xbt_dynar_t hosts();   // my content as a dynar
 
-  As *father_ = nullptr; // FIXME: hide me
 public:
   /* Add content to the AS, at parsing time. It should be sealed afterward. */
-  virtual int addComponent(surf::NetCard *elm); /* A host, a router or an AS, whatever */
+  virtual int addComponent(kernel::routing::NetCard *elm); /* A host, a router or an AS, whatever */
   virtual void addRoute(sg_platf_route_cbarg_t route);
-  void addBypassRoute(sg_platf_route_cbarg_t e_route);
+  virtual void addBypassRoute(sg_platf_route_cbarg_t e_route) = 0;
 
-protected:
-  char *name_ = nullptr;
-  xbt_dict_t children_ = xbt_dict_new_homogeneous(nullptr); // sub-ASes
-  xbt_dynar_t vertices_ = xbt_dynar_new(sizeof(char*),nullptr); // our content, as known to our graph routing algorithm (maps vertexId -> vertex)
+  /*** Called on each newly created regular route (not on bypass routes) */
+  static simgrid::xbt::signal<void(bool symmetrical, kernel::routing::NetCard* src, kernel::routing::NetCard* dst,
+                                   kernel::routing::NetCard* gw_src, kernel::routing::NetCard* gw_dst,
+                                   std::vector<Link*>* link_list)>
+      onRouteCreation;
 
-  std::map<std::pair<std::string, std::string>, std::vector<surf::Link*>*> bypassRoutes_; // srcName x dstName -> route
+protected:
+  std::vector<kernel::routing::NetCard*> vertices_; // our content, as known to our graph routing algorithm (maps vertexId -> vertex)
 
 private:
+  As* father_ = nullptr;
+  char* name_ = nullptr;
+
   bool sealed_ = false; // We cannot add more content when sealed
+
+  xbt_dict_t children_ = xbt_dict_new_homogeneous(nullptr);                               // sub-ASes
 };
 
 }}; // Namespace simgrid::s4u