+/* $ID$ */
+
+/* Copyright (c) 2007 Kayo Fujiwara. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
#ifndef _GTNETS_TOPOLOGY_H
#include <map>
#include <vector>
+#include <set>
#include <iostream>
-#define LEFTSIDE 0
-#define RIGHTSIDE 1
-
using namespace std;
-class SGLink;
+class GTNETS_Link;
-class SGNode{
+class GTNETS_Node{
public:
- SGNode(int id, int hostid);
- ~SGNode();
-
- void add_link(SGLink*);
+ GTNETS_Node(int);
+ GTNETS_Node(const GTNETS_Node& node);
+ ~GTNETS_Node();
- //get other link than the link with the given id.
- //Note it's only for the case the node has two links.
- SGLink* other_link(int);
-
- bool has_link(SGLink*); //TODO can do const SGLink*?
- void print_links();
- void print_hosts();
-
- vector<SGLink*>& links();
- vector<int>& hosts();
+ int add_host(int);
+ int add_router(int);
int id(){return ID_;};
+ bool is_router();
+ bool include(int);
+ void print_hosts();
private:
int ID_;
- bool ishost_;
- vector<int> hosts_; //simgrid hosts
- vector<SGLink*> links_;
+ int is_router_;
+ set<int> hosts_; //simgrid hosts
};
-class SGLink{
+class GTNETS_Link{
public:
- SGLink(int id, SGNode* left, SGNode* right);
- ~SGLink();
-
- //for a temporary link set, that is, a link has at most two neibours.
- SGLink* left_link();
- SGLink* right_link();
-
-
- SGNode* left_node();
- SGNode* right_node();
-
- bool is_inleft(SGLink*);
- bool is_inright(SGLink*);
-
- void add_left_link(SGLink*, int side);
- void add_right_link(SGLink*, int side);
-
+ GTNETS_Link();
+ GTNETS_Link(int id);
+ GTNETS_Link(const GTNETS_Link&);
+ ~GTNETS_Link();
+
+ GTNETS_Node* src_node();
+ GTNETS_Node* dst_node();
+ int peer_node(int);
int id(){return ID_;};
-
- void print();
+ void print_link_status();
+ int add_src(GTNETS_Node*);
+ int add_dst(GTNETS_Node*);
+ bool route_exists();
private:
int ID_;
- SGNode* left_node_;
- SGNode* right_node_;
+ GTNETS_Node* src_node_;
+ GTNETS_Node* dst_node_;
};
-
-class SGTopology{
+// To create a topology:
+// 1. add links
+// 2. add routers
+// 3. add onehop links
+class GTNETS_Topology{
public:
- SGTopology();
- ~SGTopology();
-
- void add_link(int src, int dst, int* links, int nsize);
-
- void create_tmplink(int src, int dst, int* links, int nsize);
-
- void merge_link(SGLink*);
-
- void add_tmplink_to_links(map<int, SGLink*> tmplink); //???
-
+ GTNETS_Topology();
+ ~GTNETS_Topology();
+
+ bool is_router(int id);
+ int peer_node_id(int linkid, int cur_id);
+ int add_link(int id);
+ int add_router(int id);
+ int add_onehop_route(int src, int dst, int link);
+
+ int nodeid_from_hostid(int);
+ int link_size();
+ int node_size();
void print_topology();
+ const vector<GTNETS_Node*>& nodes();
+ const map<int, GTNETS_Link*>& links();
- void create_gtnets_topology();
-
- map<int, SGLink*>& get_links();
-
private:
+
int nodeID_;
- map<int, SGLink*> links_;
- map<int, SGNode*> nodes_;
+ map<int, GTNETS_Link*> links_;
+ vector<GTNETS_Node*> nodes_;
+
+ map<int, int> hosts_; //hostid->nodeid
+
+ set<int> routers_;
};
#endif