Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Factorized better debugging output.
[simgrid.git] / src / surf / gtnets / gtnets_topology.h
1 /* $ID$ */
2
3 /* Copyright (c) 2007 Kayo Fujiwara. All rights reserved.                  */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8
9 #ifndef _GTNETS_TOPOLOGY_H
10 #define _GTNETS_TOPOLOGY_H
11
12 #include <map>
13 #include <vector>
14 #include <set>
15 #include <iostream>
16
17 using namespace std;
18
19 class GTNETS_Link;
20
21 class GTNETS_Node {
22
23 public:
24   GTNETS_Node(int);
25     GTNETS_Node(const GTNETS_Node & node);
26    ~GTNETS_Node();
27
28   int add_host(int);
29   int add_router(int);
30   int id() {
31     return ID_;
32   };
33   bool is_router();
34   bool include(int);
35   void print_hosts();
36
37 private:
38   int ID_;
39   int is_router_;
40   set < int >hosts_;            //simgrid hosts
41 };
42
43 class GTNETS_Link {
44
45 public:
46   GTNETS_Link();
47   GTNETS_Link(int id);
48     GTNETS_Link(const GTNETS_Link &);
49    ~GTNETS_Link();
50
51   GTNETS_Node *src_node();
52   GTNETS_Node *dst_node();
53   int peer_node(int);
54   int id() {
55     return ID_;
56   };
57   void print_link_status();
58   int add_src(GTNETS_Node *);
59   int add_dst(GTNETS_Node *);
60   bool route_exists();
61
62 private:
63   int ID_;
64   GTNETS_Node *src_node_;
65   GTNETS_Node *dst_node_;
66
67 };
68
69 // To create a topology:
70 // 1. add links
71 // 2. add routers
72 // 3. add onehop links
73 class GTNETS_Topology {
74 public:
75   GTNETS_Topology();
76   ~GTNETS_Topology();
77
78   bool is_router(int id);
79   int peer_node_id(int linkid, int cur_id);
80   int add_link(int id);
81   int add_router(int id);
82   int add_onehop_route(int src, int dst, int link);
83
84   int nodeid_from_hostid(int);
85   int link_size();
86   int node_size();
87   void print_topology();
88   const vector < GTNETS_Node * >&nodes();
89   const map < int, GTNETS_Link * >&links();
90
91 private:
92
93   int nodeID_;
94     map < int, GTNETS_Link * >links_;
95     vector < GTNETS_Node * >nodes_;
96
97     map < int, int >hosts_;     //hostid->nodeid
98
99     set < int >routers_;
100 };
101
102 #endif