Logo AND Algorithmique Numérique Distribuée

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