#ifndef CONF_PARAM_HPP
#define CONF_PARAM_HPP

#include<iostream>

using namespace std;

class ConfParameter{
	
	public:
		ConfParameter()
			:chronosyncSyncPrefix("ndn/nlsr/sync")
			,chronosyncLsaPrefix("/ndn/nlsr/LSA")
		{
			adjBuildFlag=0;
        		adjBuildCount=0;
        		isBuildAdjLsaSheduled=0;
        		isRouteCalculationScheduled=0;
			isRoutingTableCalculating=0;
        		isStrictHierchicalKeyCheck=0;

			interestRetryNumber=3;
			interestResendTime=5;
			infoInterestInterval=60;
			lsaRefreshTime=1800;
			routerDeadInterval=3600;
			maxFacesPerPrefix=0;
			tunnelType=0;
			detailedLogging=0;
        		debugging=0;
			isHyperbolicCalc=0;
			
			
		}

		void setRouterName(const string& rn){  
			routerName=rn;
		}

		string getRouterName(){
			return routerName;
		}

		void setSiteName(const string& sn){  
			siteName=sn;
		}

		string getSiteName(){
			return siteName;
		}

		void setNetwork(const string& nn){  
			network=nn;
		}

		string getNetwork(){
			return network;
		}

		void buildRouterPrefix(){
			routerPrefix="/"+network+"/"+siteName+"/"+routerName;
		}
		
		string getRouterPrefix(){
			return routerPrefix;
		}

		void setInterestRetryNumber(int irn){
			interestRetryNumber=irn;
		}

		int getInterestRetryNumber(){
			return interestRetryNumber;
		}

		void setInterestResendTime(int irt){
			interestResendTime=irt;
		}

		int getInterestResendTime(){
			return interestResendTime;
		}

		void setLsaRefreshTime(int lrt){
			lsaRefreshTime=lrt;
			routerDeadInterval=2*lsaRefreshTime;
		}

		int getLsaRefreshTime(){
			return lsaRefreshTime;
		}

		void setRouterDeadInterval(int rdt){
			routerDeadInterval=rdt;
		}

		long int setRouterDeadInterval(){
			return routerDeadInterval;
		}

		void setMaxFacesPerPrefix(int mfpp){
			maxFacesPerPrefix=mfpp;
		}

		int getMaxFacesPerPrefix(){
			return maxFacesPerPrefix;
		}

		void setLogDir(string ld){
			logDir=ld;
		}
		
		string getLogDir(){
			return logDir;
		}

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

		int getDetailedLogging(){
			return detailedLogging;
		}

		void setDebugging(int d){
			debugging=d;
		}
		
		int getDebugging(){
			return debugging;
		}

		void setIsHyperbolicCalc(int ihc){
			isHyperbolicCalc=ihc;
		}

		int getIsHyperbolicCalc(){
			return isHyperbolicCalc;
		}

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

		double getCorR(){
			return corR;
		}

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

		double getCorTheta(){
			return corTheta;
		}

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

		int getTunnelType(){
			return tunnelType;
		}

		void setChronosyncSyncPrefix(const string& csp){
			chronosyncSyncPrefix=csp;
		} 

		string getChronosyncSyncPrefix(){
			return chronosyncSyncPrefix;
		}

		int getInfoInterestInterval(){
			return infoInterestInterval;
		}

		void setInfoInterestInterval(int iii){
			infoInterestInterval=iii;
		}

	private:
        string routerName;
        string siteName;
        string network;

        string routerPrefix;
        string lsaRouterPrefix;

        string chronosyncSyncPrefix;
        string chronosyncLsaPrefix;             

        int interestRetryNumber;
        int interestResendTime;
		int infoInterestInterval;
        int lsaRefreshTime;
        int routerDeadInterval;
        
        int maxFacesPerPrefix;
        string logDir;
        string logFile;
        int detailedLogging;
        int debugging;

        int isHyperbolicCalc;
        double corR;
        double corTheta;

		int tunnelType;

		int adjBuildFlag;
        long int adjBuildCount;
        int isBuildAdjLsaSheduled;
        int isRouteCalculationScheduled;

        int isRoutingTableCalculating;
        int isStrictHierchicalKeyCheck;

        

};

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

#endif
