akmhoque | 79d355f | 2014-02-04 15:11:16 -0600 | [diff] [blame^] | 1 | #include <iostream> |
| 2 | #include "nlsr_lsdb.hpp" |
| 3 | #include "nlsr_rtc.hpp" |
| 4 | #include "nlsr_map.hpp" |
| 5 | #include "nlsr_lsa.hpp" |
| 6 | #include "nlsr.hpp" |
| 7 | |
| 8 | using namespace std; |
| 9 | |
| 10 | void |
| 11 | RoutingTableCalculator::allocateAdjMatrix() |
| 12 | { |
| 13 | adjMatrix = new double*[numOfRouter]; |
| 14 | for(int i = 0; i < numOfRouter; ++i) |
| 15 | { |
| 16 | adjMatrix[i] = new double[numOfRouter]; |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | void |
| 21 | RoutingTableCalculator::makeAdjMatrix(nlsr& pnlsr, Map pMap) |
| 22 | { |
| 23 | std::list<AdjLsa> adjLsdb=pnlsr.getLsdb().getAdjLsdb(); |
| 24 | for( std::list<AdjLsa>::iterator it=adjLsdb.begin(); |
| 25 | it!= adjLsdb.end() ; it++) |
| 26 | { |
| 27 | string linkStartRouter=(*it).getOrigRouter(); |
| 28 | int row=pMap.getMappingNoByRouterName(linkStartRouter); |
| 29 | std::list<Adjacent> adl=(*it).getAdl().getAdjList(); |
| 30 | for( std::list<Adjacent>::iterator itAdl=adl.begin(); |
| 31 | itAdl!= adl.end() ; itAdl++) |
| 32 | { |
| 33 | string linkEndRouter=(*itAdl).getAdjacentName(); |
| 34 | int col=pMap.getMappingNoByRouterName(linkEndRouter); |
| 35 | double cost=(*itAdl).getLinkCost(); |
| 36 | if ( (row >= 0 && row<numOfRouter) && (col >= 0 && col<numOfRouter) ) |
| 37 | { |
| 38 | adjMatrix[row][col]=cost; |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | void |
| 46 | RoutingTableCalculator::freeAdjMatrix() |
| 47 | { |
| 48 | for(int i = 0; i < numOfRouter; ++i) |
| 49 | { |
| 50 | delete [] adjMatrix[i]; |
| 51 | } |
| 52 | delete [] adjMatrix; |
| 53 | } |
| 54 | |
| 55 | void |
| 56 | LinkStateRoutingTableCalculator::calculatePath(Map& pMap, RoutingTable& rt, nlsr& pnlsr) |
| 57 | { |
| 58 | } |
| 59 | |
| 60 | void |
| 61 | HypRoutingTableCalculator::calculatePath(Map& pMap, RoutingTable& rt, nlsr& pnlsr) |
| 62 | { |
| 63 | } |
| 64 | |
| 65 | void |
| 66 | HypDryRoutingTableCalculator::calculatePath(Map& pMap, RoutingTable& rt, nlsr& pnlsr) |
| 67 | { |
| 68 | } |
| 69 | |