#ifndef NLSR_FE_HPP
#define NLSR_FE_HPP

#include<list>
#include <iostream>
#include <ndn-cpp-dev/util/scheduler.hpp>

#include "nlsr_nexthop.hpp"
#include "nlsr_nhl.hpp"

namespace nlsr
{

  using namespace std;

  class FibEntry
  {
  public:
    FibEntry()
      : name()
      , timeToRefresh(0)
      , feSeqNo(0)
      , nhl()
    {
    }

    FibEntry(string n)
      : timeToRefresh(0)
      , feSeqNo(0)
      , nhl()
    {
      name=n;
    }

    string getName()
    {
      return name;
    }

    Nhl& getNhl()
    {
      return nhl;
    }

    int getTimeToRefresh()
    {
      return timeToRefresh;
    }

    void setTimeToRefresh(int ttr)
    {
      timeToRefresh=ttr;
    }

    void setFeExpiringEventId(ndn::EventId feid)
    {
      feExpiringEventId=feid;
    }

    ndn::EventId getFeExpiringEventId()
    {
      return feExpiringEventId;
    }

    void setFeSeqNo(int fsn)
    {
      feSeqNo=fsn;
    }

    int getFeSeqNo()
    {
      return feSeqNo;
    }

    bool isEqualNextHops(Nhl &nhlOther);

  private:
    string name;
    int timeToRefresh;
    ndn::EventId feExpiringEventId;
    int feSeqNo;
    Nhl nhl;
  };

  ostream& operator<<(ostream& os,FibEntry fe);

} //namespace nlsr

#endif
