Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Depricated gtnets header, compability with old gtnets versions still granted.
[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(){return ID_;};
31   bool is_router();
32   bool include(int);
33   void print_hosts();
34
35  private:
36   int ID_;
37   int is_router_;
38   set<int> hosts_; //simgrid hosts
39 };
40
41 class GTNETS_Link{
42
43  public:
44   GTNETS_Link();
45   GTNETS_Link(int id);
46   GTNETS_Link(const GTNETS_Link&);
47   ~GTNETS_Link();
48
49   GTNETS_Node* src_node();
50   GTNETS_Node* dst_node();
51   int peer_node(int);
52   int id(){return ID_;};
53   void print_link_status();
54   int add_src(GTNETS_Node*);
55   int add_dst(GTNETS_Node*);
56   bool route_exists();
57
58  private:
59   int ID_;
60   GTNETS_Node* src_node_;
61   GTNETS_Node* dst_node_;
62
63 };
64
65 // To create a topology:
66 // 1. add links
67 // 2. add routers
68 // 3. add onehop links
69 class GTNETS_Topology{
70  public:
71   GTNETS_Topology();
72   ~GTNETS_Topology();
73
74   bool is_router(int id);
75   int peer_node_id(int linkid, int cur_id);
76   int add_link(int id);
77   int add_router(int id);
78   int add_onehop_route(int src, int dst, int link);
79   
80   int nodeid_from_hostid(int);
81   int link_size();
82   int node_size();
83   void print_topology();
84   const vector<GTNETS_Node*>& nodes();
85   const map<int, GTNETS_Link*>& links();
86   
87  private:
88
89   int nodeID_;
90   map<int, GTNETS_Link*> links_;
91   vector<GTNETS_Node*> nodes_;
92
93   map<int, int> hosts_; //hostid->nodeid
94
95   set<int> routers_;
96 };
97
98 #endif