#ifndef NLSR_LSDB_HPP
#define NLSR_LSDB_HPP

#include <utility>
#include "nlsr_lsa.hpp"

namespace nlsr
{

    using namespace std;

    class Nlsr;

    class Lsdb
    {
    public:
        Lsdb()
            : lsaRefreshTime(0)
        {
        }


        bool doesLsaExist(string key, int lsType);
        // function related to Name LSDB
        bool buildAndInstallOwnNameLsa(Nlsr& pnlsr);
        std::pair<NameLsa&, bool>  getNameLsa(string key);
        bool installNameLsa(Nlsr& pnlsr, NameLsa &nlsa);
        bool removeNameLsa(Nlsr& pnlsr, string& key);
        bool isNameLsaNew(string key, uint64_t seqNo);
        void printNameLsdb(); //debugging

        //function related to Cor LSDB
        bool buildAndInstallOwnCorLsa(Nlsr& pnlsr);
        std::pair<CorLsa&, bool> getCorLsa(string key);
        bool installCorLsa(Nlsr& pnlsr, CorLsa &clsa);
        bool removeCorLsa(Nlsr& pnlsr, string& key);
        bool isCorLsaNew(string key, uint64_t seqNo);
        void printCorLsdb(); //debugging

        //function related to Adj LSDB
        void scheduledAdjLsaBuild(Nlsr& pnlsr);
        bool buildAndInstallOwnAdjLsa(Nlsr& pnlsr);
        bool removeAdjLsa(Nlsr& pnlsr, string& key);
        bool isAdjLsaNew(string key, uint64_t seqNo);
        bool installAdjLsa(Nlsr& pnlsr, AdjLsa &alsa);
        std::pair<AdjLsa& , bool> getAdjLsa(string key);
        std::list<AdjLsa>& getAdjLsdb();
        void printAdjLsdb();

        //void scheduleRefreshLsdb(Nlsr& pnlsr, int interval);
        void setLsaRefreshTime(int lrt);
        void setThisRouterPrefix(string trp);

    private:
        bool addNameLsa(NameLsa &nlsa);
        bool doesNameLsaExist(string key);


        bool addCorLsa(CorLsa& clsa);
        bool doesCorLsaExist(string key);

        bool addAdjLsa(AdjLsa &alsa);
        bool doesAdjLsaExist(string key);

        ndn::EventId
        scheduleNameLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime);
        void exprireOrRefreshNameLsa(Nlsr& pnlsr, string lsaKey, int seqNo);
        ndn::EventId
        scheduleAdjLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime);
        void exprireOrRefreshAdjLsa(Nlsr& pnlsr, string lsaKey, int seqNo);
        ndn::EventId
        scheduleCorLsaExpiration(Nlsr& pnlsr, string key, int seqNo, int expTime);
        void exprireOrRefreshCorLsa(Nlsr& pnlsr, string lsaKey, int seqNo);


    private:
        void cancelScheduleLsaExpiringEvent(Nlsr& pnlsr, EventId eid);

        std::list<NameLsa> nameLsdb;
        std::list<AdjLsa> adjLsdb;
        std::list<CorLsa> corLsdb;

        int lsaRefreshTime;
        string thisRouterPrefix;

    };

}//namespace nlsr

#endif
