#ifndef NLSR_ROUTING_TABLE_CALCULATOR_HPP
#define NLSR_ROUTING_TABLE_CALCULATOR_HPP

#include <list>
#include <iostream>
#include <boost/cstdint.hpp>

namespace nlsr {

class Map;
class RoutingTable;
class Nlsr;

class RoutingTableCalculator
{
public:
  RoutingTableCalculator()
  {
  }
  RoutingTableCalculator(int rn)
  {
    numOfRouter = rn;
  }
protected:
  void
  allocateAdjMatrix();

  void
  initMatrix();

  void
  makeAdjMatrix(Nlsr& pnlsr, Map pMap);

  void
  printAdjMatrix();

  int
  getNumOfLinkfromAdjMatrix(int sRouter);

  void
  freeAdjMatrix();

  void
  adjustAdMatrix(int source, int link, double linkCost);

  void
  getLinksFromAdjMatrix(int* links, double* linkCosts, int source);

  void
  allocateLinks();

  void
  allocateLinkCosts();

  void
  freeLinks();

  void
  freeLinksCosts();

  void
  setNoLink(int nl)
  {
    vNoLink = nl;
  }

protected:
  double** adjMatrix;
  int numOfRouter;

  int vNoLink;
  int* links;
  double* linkCosts;
};

class LinkStateRoutingTableCalculator: public RoutingTableCalculator
{
public:
  LinkStateRoutingTableCalculator(int rn)
    : EMPTY_PARENT(-12345)
    , INF_DISTANCE(2147483647)
    , NO_MAPPING_NUM(-1)
    , NO_NEXT_HOP(-12345)
  {
    numOfRouter = rn;
  }


  void
  calculatePath(Map& pMap, RoutingTable& rt, Nlsr& pnlsr);


private:
  void
  doDijkstraPathCalculation(int sourceRouter);

  void
  sortQueueByDistance(int* Q, double* dist, int start, int element);

  int
  isNotExplored(int* Q, int u, int start, int element);

  void
  printAllLsPath(int sourceRouter);

  void
  printLsPath(int destRouter);

  void
  addAllLsNextHopsToRoutingTable(Nlsr& pnlsr, RoutingTable& rt,
                                 Map& pMap, int sourceRouter);

  int
  getLsNextHop(int dest, int source);

  void
  allocateParent();

  void
  allocateDistance();

  void
  freeParent();

  void
  freeDistance();




private:
  int* m_parent;
  double* m_distance;


  const int EMPTY_PARENT;
  const double INF_DISTANCE;
  const int NO_MAPPING_NUM;
  const int NO_NEXT_HOP;

};

class HypRoutingTableCalculator: public RoutingTableCalculator
{
public:
  HypRoutingTableCalculator(int rn)
    :  MATH_PI(3.141592654)
  {
    numOfRouter = rn;
    m_isDryRun = 0;
  }

  HypRoutingTableCalculator(int rn, int idr)
    :  MATH_PI(3.141592654)
  {
    numOfRouter = rn;
    m_isDryRun = idr;
  }

  void
  calculatePath(Map& pMap, RoutingTable& rt, Nlsr& pnlsr);

private:
  void
  allocateLinkFaces();

  void
  allocateDistanceToNeighbor();

  void
  allocateDistFromNbrToDest();

  void
  freeLinkFaces();

  void
  freeDistanceToNeighbor();

  void
  freeDistFromNbrToDest();

  double
  getHyperbolicDistance(Nlsr& pnlsr, Map& pMap, int src, int dest);

  void
  addHypNextHopsToRoutingTable(Nlsr& pnlsr, Map& pMap,
                               RoutingTable& rt, int noFaces, int dest);

private:
  bool m_isDryRun;

  int* m_linkFaces;
  double* m_distanceToNeighbor;
  double* m_distFromNbrToDest;

  const double MATH_PI;

};

}//namespace nlsr

#endif //NLSR_ROUTING_TABLE_CALCULATOR_HPP
