#ifndef CONF_PARAMETER_HPP
#define CONF_PARAMETER_HPP

#include <iostream>
#include <boost/cstdint.hpp>
#include <ndn-cxx/common.hpp>
#include <ndn-cxx/face.hpp>

namespace nlsr {
class ConfParameter
{

public:
  ConfParameter()
    : m_chronosyncSyncPrefix("ndn/nlsr/sync")
    , m_chronosyncLsaPrefix("/ndn/nlsr/LSA")
    , m_rootKeyPrefix("/ndn/keys")
    , m_interestRetryNumber(3)
    , m_interestResendTime(5)
    , m_infoInterestInterval(60)
    , m_lsaRefreshTime(1800)
    , m_routerDeadInterval(3600)
    , m_maxFacesPerPrefix(0)
    , m_tunnelType(0)
    , m_detailedLogging(0)
    , m_certDir()
    , m_debugging(0)
    , m_seqFileDir()
    , m_isHyperbolicCalc(0)
    , m_corR(0)
    , m_corTheta(0)
  {}

  void
  setRouterName(const std::string& rn)
  {
    m_routerName = ndn::Name(rn);
  }

  const ndn::Name&
  getRouterName()
  {
    return m_routerName;
  }

  void
  setSiteName(const std::string& sn)
  {
    m_siteName = ndn::Name(sn);
  }

  const ndn::Name&
  getSiteName()
  {
    return m_siteName;
  }

  void
  setNetwork(const std::string& nn)
  {
    m_network = ndn::Name(nn);
  }

  const ndn::Name&
  getNetwork()
  {
    return m_network;
  }

  void
  buildRouterPrefix()
  {
    //m_routerPrefix = "/" + m_network + "/" + m_siteName + "/" + m_routerName;
    m_routerPrefix = m_network;
    m_routerPrefix.append(m_siteName);
    m_routerPrefix.append(m_routerName);
  }

  const ndn::Name&
  getRouterPrefix()
  {
    return m_routerPrefix;
  }

  const ndn::Name&
  getRootKeyPrefix()
  {
    return m_rootKeyPrefix;
  }

  void
  setRootKeyPrefix(std::string rkp)
  {
    m_rootKeyPrefix = ndn::Name(rkp);
  }

  void
  setInterestRetryNumber(uint32_t irn)
  {
    m_interestRetryNumber = irn;
  }

  uint32_t
  getInterestRetryNumber()
  {
    return m_interestRetryNumber;
  }

  void
  setInterestResendTime(int32_t irt)
  {
    m_interestResendTime = irt;
  }

  int32_t
  getInterestResendTime()
  {
    return m_interestResendTime;
  }

  void
  setLsaRefreshTime(int32_t lrt)
  {
    m_lsaRefreshTime = lrt;
    m_routerDeadInterval = 2 * m_lsaRefreshTime;
  }

  int32_t
  getLsaRefreshTime()
  {
    return m_lsaRefreshTime;
  }

  void
  setRouterDeadInterval(int64_t rdt)
  {
    m_routerDeadInterval = rdt;
  }

  int64_t
  getRouterDeadInterval()
  {
    return m_routerDeadInterval;
  }

  void
  setMaxFacesPerPrefix(int32_t mfpp)
  {
    m_maxFacesPerPrefix = mfpp;
  }

  int32_t
  getMaxFacesPerPrefix()
  {
    return m_maxFacesPerPrefix;
  }

  void
  setLogDir(const std::string& ld)
  {
    m_logDir = ld;
  }

  std::string
  getLogDir()
  {
    return m_logDir;
  }

  void
  setCertDir(const std::string& cd)
  {
    m_certDir = cd;
  }

  const std::string&
  getCertDir()
  {
    return m_certDir;
  }

  void
  setSeqFileDir(const std::string& ssfd)
  {
    m_seqFileDir = ssfd;
  }

  const std::string&
  getSeqFileDir()
  {
    return m_seqFileDir;
  }

  void
  setDetailedLogging(int dl)
  {
    m_detailedLogging = dl;
  }

  int
  getDetailedLogging()
  {
    return m_detailedLogging;
  }

  void
  setDebugging(int32_t d)
  {
    m_debugging = d;
  }

  int32_t
  getDebugging()
  {
    return m_debugging;
  }

  void
  setIsHyperbolicCalc(int32_t ihc)
  {
    m_isHyperbolicCalc = ihc;
  }

  int32_t
  getIsHyperbolicCalc()
  {
    return m_isHyperbolicCalc;
  }

  void
  setCorR(double cr)
  {
    m_corR = cr;
  }

  double
  getCorR()
  {
    return m_corR;
  }

  void
  setCorTheta(double ct)
  {
    m_corTheta = ct;
  }

  double
  getCorTheta()
  {
    return m_corTheta;
  }

  void
  setTunnelType(int tt)
  {
    m_tunnelType = tt;
  }

  int32_t
  getTunnelType()
  {
    return m_tunnelType;
  }

  void
  setChronosyncSyncPrefix(const std::string& csp)
  {
    m_chronosyncSyncPrefix = ndn::Name(csp);
  }

  const ndn::Name&
  getChronosyncSyncPrefix()
  {
    return m_chronosyncSyncPrefix;
  }

  void
  setChronosyncLsaPrefix(const std::string& clp)
  {
    m_chronosyncLsaPrefix = ndn::Name(clp);
  }

  const ndn::Name&
  getChronosyncLsaPrefix()
  {
    return m_chronosyncLsaPrefix;
  }

  int32_t
  getInfoInterestInterval()
  {
    return m_infoInterestInterval;
  }

  void
  setInfoInterestInterval(int32_t iii)
  {
    m_infoInterestInterval = iii;
  }

private:
  ndn::Name m_routerName;
  ndn::Name m_siteName;
  ndn::Name m_network;

  ndn::Name m_routerPrefix;
  ndn::Name m_lsaRouterPrefix;

  ndn::Name m_chronosyncSyncPrefix;
  ndn::Name m_chronosyncLsaPrefix;
  ndn::Name m_rootKeyPrefix;

  uint32_t m_interestRetryNumber;
  int32_t m_interestResendTime;
  int32_t m_infoInterestInterval;
  int32_t m_lsaRefreshTime;
  int64_t m_routerDeadInterval;

  int32_t m_maxFacesPerPrefix;
  int32_t m_tunnelType;
  int32_t m_detailedLogging;

  std::string m_certDir;
  int32_t m_debugging;
  std::string m_seqFileDir;

  int32_t m_isHyperbolicCalc;
  double m_corR;
  double m_corTheta;

  std::string m_logFile;
  std::string m_logDir;

};

std::ostream&
operator<<(std::ostream& os, ConfParameter& cfp);

} // namespace nlsr

#endif //CONF_PARAMETER_HPP
