Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
*** empty log message ***
[simgrid.git] / src / surf / gtnets / gtnets_topology.h
1
2
3 #ifndef _GTNETS_TOPOLOGY_H
4 #define _GTNETS_TOPOLOGY_H
5
6 #include <map>
7 #include <vector>
8 #include <iostream>
9
10 #define LEFTSIDE 0
11 #define RIGHTSIDE 1
12
13 using namespace std;
14
15 class SGLink;
16
17 class SGNode{
18
19  public:
20   SGNode(int id, int hostid);
21   ~SGNode();
22
23   void add_link(SGLink*);
24
25   //get other link than the link with the given id.
26   //Note it's only for the case the node has two links.
27   SGLink* other_link(int);
28
29   bool has_link(SGLink*); //TODO can do const SGLink*?
30   void print_links();
31   void print_hosts();
32   
33   vector<SGLink*>& links();
34   vector<int>& hosts();
35   int id(){return ID_;};
36
37  private:
38   int ID_;
39   bool ishost_;
40   vector<int> hosts_; //simgrid hosts
41   vector<SGLink*> links_;
42 };
43
44 class SGLink{
45
46  public:
47   SGLink(int id, SGNode* left, SGNode* right);
48   ~SGLink();
49
50   //for a temporary link set, that is, a link has at most two neibours.
51   SGLink* left_link();
52   SGLink* right_link();
53
54
55   SGNode* left_node();
56   SGNode* right_node();
57
58   bool is_inleft(SGLink*);
59   bool is_inright(SGLink*);
60
61   void add_left_link(SGLink*, int side);
62   void add_right_link(SGLink*, int side);
63
64   int id(){return ID_;};
65
66   void print();
67
68  private:
69   int ID_;
70   SGNode* left_node_;
71   SGNode* right_node_;
72
73 };
74
75
76 class SGTopology{
77  public:
78   SGTopology();
79   ~SGTopology();
80
81   void add_link(int src, int dst, int* links, int nsize);
82
83   void create_tmplink(int src, int dst, int* links, int nsize);
84
85   void merge_link(SGLink*);
86
87   void add_tmplink_to_links(map<int, SGLink*> tmplink); //???
88
89   void print_topology();
90   
91   void create_gtnets_topology();
92
93   map<int, SGLink*>& get_links();
94
95  private:
96   int nodeID_;
97   map<int, SGLink*> links_;
98   map<int, SGNode*> nodes_;
99 };
100
101 #endif