Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix Memleaks
[simgrid.git] / src / surf / surf_routing.hpp
index 2e5e36b..d0ae19b 100644 (file)
@@ -1,20 +1,26 @@
 #include "surf.hpp"
+#include <float.h>
 
 #ifndef NETWORK_ROUTING_HPP_
 #define NETWORK_ROUTING_HPP_
 
 void routing_model_create( void *loopback);
 
+/* ************************************************************************** */
+/* ************************* GRAPH EXPORTING FUNCTIONS ********************** */
+xbt_node_t new_xbt_graph_node (xbt_graph_t graph, const char *name, xbt_dict_t nodes);
+xbt_edge_t new_xbt_graph_edge (xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xbt_dict_t edges);
+
 /***********
  * Classes *
  ***********/
-class As;
+struct As;
 typedef As *AsPtr;
 
 class RoutingModelDescription;
 typedef RoutingModelDescription *RoutingModelDescriptionPtr;
 
-class RoutingEdge;
+struct RoutingEdge;
 typedef RoutingEdge *RoutingEdgePtr;
 
 class Onelink;
@@ -23,15 +29,7 @@ typedef Onelink *OnelinkPtr;
 class RoutingPlatf;
 typedef RoutingPlatf *RoutingPlatfPtr;
 
-
-/*FIXME:class RoutingModelDescription {
-  const char *p_name;
-  const char *p_desc;
-  AsPtr create();
-  void end(AsPtr as);
-};*/
-
-class As {
+struct As {
 public:
   xbt_dynar_t p_indexNetworkElm;
   xbt_dict_t p_bypassRoutes;    /* store bypass routes */
@@ -44,7 +42,9 @@ public:
   xbt_dynar_t p_linkUpDownList;
 
   As(){};
-  ~As(){};
+  virtual ~As(){
+       xbt_free(p_name);
+  };
 
   virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency)=0;
   virtual xbt_dynar_t getOneLinkRoutes()=0;
@@ -62,8 +62,9 @@ public:
   virtual void parseBypassroute(sg_platf_route_cbarg_t e_route)=0;
 };
 
-class RoutingEdge {
+struct RoutingEdge {
 public:
+  ~RoutingEdge() { xbt_free(p_name);};
   AsPtr p_rcComponent;
   e_surf_network_element_type_t p_rcType;
   int m_id;
@@ -75,13 +76,16 @@ public:
  */
 class Onelink {
 public:
+  Onelink(void *link, RoutingEdgePtr src, RoutingEdgePtr dst)
+    : p_src(src), p_dst(dst), p_link(link) {};
   RoutingEdgePtr p_src;
   RoutingEdgePtr p_dst;
-  void *p_linkPtr;
+  void *p_link;
 };
 
 class RoutingPlatf {
 public:
+  ~RoutingPlatf();
   AsPtr p_root;
   void *p_loopback;
   xbt_dynar_t p_lastRoute;